Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cff-version: 1.2.2
cff-version: 2.0.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Guignard"
given-names: "Léo"
orcid: "https://orcid.org/0000-0002-3686-1385"
title: "sc3D"
version: 1.2.2
version: 2.0.0
date-released: 2023-07-01
url: "https://github.com/GuignardLab/sc3D"
10 changes: 4 additions & 6 deletions notebooks/Embryo-Registration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"outputs": [],
"source": [
"import json\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"from sc3D import Embryo\n",
"from sc3D import SpatialOmicArray\n",
"\n",
"%matplotlib inline"
]
Expand Down Expand Up @@ -108,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"embryo = Embryo(\n",
"embryo = SpatialOmicArray(\n",
" data_path,\n",
" tissues_to_ignore,\n",
" corres_tissues,\n",
Expand Down Expand Up @@ -163,7 +161,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "sc3D",
"language": "python",
"name": "python3"
},
Expand All @@ -177,7 +175,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.5"
}
},
"nbformat": 4,
Expand Down
26 changes: 13 additions & 13 deletions notebooks/Spatial-differential-expression.ipynb

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions notebooks/Test-embryo.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ profile = "black"
line_length = 79

[tool.bumpver]
current_version = "1.2.2"
current_version = "2.0.0"
version_pattern = "MAJOR.MINOR.PATCH[-TAG]"
commit_message = "bump version {old_version} -> {new_version}"
commit = true
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = sc-3D
version = 1.2.2
version = 2.0.0
author = Leo Guignard
author_email = leo.guignard@univ-amu.fr
url = https://github.com/GuignardLab/sc3D
Expand Down
9 changes: 7 additions & 2 deletions src/sc3D/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
__version__ = "1.2.2"
__version__ = "2.0.0"

from .sc3D import Embryo
from .sc3D import SpatialOmicArray
from .transformations import transformations

__all__ = [
"SpatialOmicArray",
"transformations",
]
6 changes: 3 additions & 3 deletions src/sc3D/_tests/test_sc3D.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from sc3D import Embryo
from sc3D import SpatialOmicArray
import numpy as np


def test_sc3D():
em = Embryo("data/data_test.h5ad", store_anndata=True)
em = SpatialOmicArray("data/data_test.h5ad", store_anndata=True)
assert len(em.all_cells) == 120
em.smooth_data()
em.plot_coverslip(7)
Expand All @@ -15,7 +15,7 @@ def test_sc3D():
em.compute_volumes()
em.set_zpos()

em = Embryo(
em = SpatialOmicArray(
"data/DLPFC.h5ad",
tissue_id="layer_guess",
pos_id="spatial",
Expand Down
37 changes: 21 additions & 16 deletions src/sc3D/sc3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from sc3D.transformations import transformations as tr


class Embryo:
class SpatialOmicArray:
"""
Embryo class to handle samples from 3D spatial
SpatialOmicArray class to handle samples from 3D spatial
single cell omics. It was initially designed with
a specific dataset in mind but it should work
for other kinds of datasets.
Expand Down Expand Up @@ -187,7 +187,7 @@ def read_anndata(
elif genes_of_interest == "all":
genes_of_interest = data.var_names
self.all_genes = sorted(genes_of_interest)

if 0 < len(genes_of_interest):
raw_X = self._to_dense(data.raw[:, self.all_genes].X)
self.gene_expression = dict(zip(ids, np.array(raw_X)))
Expand Down Expand Up @@ -695,7 +695,7 @@ def smooth_data(self, inplace=True):
"""
Smooth the gene expression according to the spatial neighborhood relationship.
The spatial neighborhood relationship is computed as the Gabriel graph.
The smoothed expression (\(s_c \) of the gene $g$ of a cell $c$ which has
The smoothed expression ($s_c$) of the gene $g$ of a cell $c$ which has
a set of neighbors $N_c = \{n_i\}$ is computed as follow:
$$s_c = \\frac{\sum_{n_i \in N_c} ||n_i - c||.g_{n_i}}{\sum_{n_i \in N_c} ||n_i - c||}$$
where $||n_i - c||$ is the distance between $n_i$ and $c$ and $g_{n_i}$ is the measured
Expand Down Expand Up @@ -789,16 +789,21 @@ def downsample(self, spacing=10, pos_id="pos_3D"):
if 0 < len(v)
]
)

final_expr = np.array([
np.mean(
self._to_dense(self.anndata.raw[
mapping_from_removed[[cells[vi] for vi in v]]
].X),
axis=0,
)
for v in mapping if len(v) > 0
])

final_expr = np.array(
[
np.mean(
self._to_dense(
self.anndata.raw[
mapping_from_removed[[cells[vi] for vi in v]]
].X
),
axis=0,
)
for v in mapping
if len(v) > 0
]
)

nb_cells = np.array([len(v) for v in mapping if 0 < len(v)])
tissue = [
Expand Down Expand Up @@ -1945,7 +1950,7 @@ def neighbs(self, gene, sub_data, cells):
gene (int): gene id (position in the `self.anndata` array)
sub_data (ndarray): sliced version of `self.anndata` only containing
the beads corresponding to the tissue to analyse
cells (ndarray): ids of the cells in `Embryo` ordered similarly to
cells (ndarray): ids of the cells in `SpatialOmicArray` ordered similarly to
the `self.anndata` array (to do correspondancy)
Returns:
avg_nb_neighbs (float): average number of positive neighbors per
Expand Down Expand Up @@ -2428,7 +2433,7 @@ def __init__(
sample_list=None,
):
"""
Initialize an spatial single cell embryo
Initialize an spatial single cell SpatialOmicArray

Args:
data_path (str): path to the file containing the sc data (h5ad format)
Expand Down
Loading