sclab 0.4.0__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sclab-0.4.0 → sclab-0.4.2}/PKG-INFO +3 -3
- {sclab-0.4.0 → sclab-0.4.2}/pyproject.toml +11 -10
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/__init__.py +1 -1
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_transfer_metadata.py +15 -2
- sclab-0.4.2/src/sclab/tools/__init__.py +7 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/_density_dynamics.py +1 -1
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/utils/density_nd.py +1 -1
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/utils/periodic_genes.py +9 -2
- sclab-0.4.2/src/sclab/tools/differential_expression/__init__.py +11 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/differential_expression/_pseudobulk_edger.py +20 -5
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/differential_expression/_pseudobulk_limma.py +20 -5
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/doublet_detection/_scdblfinder.py +19 -5
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/labeling/sctype.py +12 -0
- sclab-0.4.2/src/sclab/tools/utils/__init__.py +7 -0
- sclab-0.4.2/src/sclab/tools/utils/_call_differential_expression.py +88 -0
- sclab-0.4.0/src/sclab/tools/differential_expression/__init__.py +0 -7
- sclab-0.4.0/src/sclab/tools/imputation/__init__.py +0 -0
- sclab-0.4.0/src/sclab/tools/utils/__init__.py +0 -5
- {sclab-0.4.0 → sclab-0.4.2}/LICENSE +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/README.md +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/_io.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/_methods_registry.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/_sclab.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/_dataset.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/_exceptions.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/plotter/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/plotter/_controls.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/plotter/_plotter.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/plotter/_utils.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/_processor.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/_results_panel.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/step/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/step/_basic_processor_step.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/dataset/processor/step/_processor_step_base.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/event/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/event/_broker.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/event/_client.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/event/_utils.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_cluster.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_differential_expression.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_doublet_detection.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_gene_expression.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_integration.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_neighbors.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_pca.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_preprocess.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_qc.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/examples/processor_steps/_umap.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/gui/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/gui/components/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/gui/components/_guided_pseudotime.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/gui/components/_transfer_metadata.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/methods/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_cca.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_cca_integrate.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_filter_obs.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_harmony.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_harmony_integrate.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_mcca.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_mcca2.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_normalize_weighted.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_pca.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_preprocess.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_qc.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_rpca.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_subset.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_transform.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/preprocess/_utils.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/_compat.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/_settings.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/logging.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/plotting/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/plotting/_rcmod.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/plotting/palettes.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/scanpy/readwrite.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/_expression_dynamics.py +0 -0
- {sclab-0.4.0/src/sclab/tools → sclab-0.4.2/src/sclab/tools/cellflow/_pseudotime}/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/_pseudotime/_pseudotime.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/_pseudotime/_timeseries.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/pseudotime_tools/__init__.py +0 -0
- {sclab-0.4.0/src/sclab/tools/cellflow/_pseudotime → sclab-0.4.2/src/sclab/tools/cellflow/utils}/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/utils/interpolate.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/utils/smoothen.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/cellflow/utils/times.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/differential_expression/_pseudobulk_helpers.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/doublet_detection/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/doublet_detection/_doubletdetection.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/doublet_detection/_scrublet.py +0 -0
- {sclab-0.4.0/src/sclab/tools/cellflow/utils → sclab-0.4.2/src/sclab/tools/embedding}/__init__.py +0 -0
- {sclab-0.4.0/src/sclab/tools/embedding → sclab-0.4.2/src/sclab/tools/imputation}/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/imputation/_alra.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/labeling/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/tools/utils/_aggregate_and_filter.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/utils/__init__.py +0 -0
- {sclab-0.4.0 → sclab-0.4.2}/src/sclab/utils/_write_excel.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sclab
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: sclab
|
|
5
5
|
Author-email: Argenis Arriojas <ArriojasMaldonado001@umb.edu>
|
|
6
6
|
Requires-Python: >=3.10,<=3.13
|
|
@@ -21,8 +21,8 @@ Requires-Dist: matplotlib
|
|
|
21
21
|
Requires-Dist: numpy
|
|
22
22
|
Requires-Dist: pandas
|
|
23
23
|
Requires-Dist: plotly<6.0
|
|
24
|
+
Requires-Dist: pydeseq2>=0.5.2
|
|
24
25
|
Requires-Dist: requests
|
|
25
|
-
Requires-Dist: ripser>=0.6.12
|
|
26
26
|
Requires-Dist: scikit-learn
|
|
27
27
|
Requires-Dist: scipy
|
|
28
28
|
Requires-Dist: svgpathtools
|
|
@@ -34,7 +34,7 @@ Requires-Dist: scanpy[leiden, skmisc]>=1.10 ; extra == "scanpy"
|
|
|
34
34
|
Requires-Dist: pytest>=8.3.4 ; extra == "test"
|
|
35
35
|
Project-URL: Bug Tracker, https://github.com/umbibio/sclab/issues
|
|
36
36
|
Project-URL: Changelog, https://github.com/umbibio/sclab/blob/main/CHANGELOG.md
|
|
37
|
-
Project-URL: Documentation, https://
|
|
37
|
+
Project-URL: Documentation, https://sclab.readthedocs.io
|
|
38
38
|
Project-URL: Homepage, https://github.com/umbibio/sclab
|
|
39
39
|
Project-URL: Repository, https://github.com/umbibio/sclab.git
|
|
40
40
|
Provides-Extra: jupyter
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sclab"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "sclab"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -25,8 +25,8 @@ dependencies = [
|
|
|
25
25
|
"numpy",
|
|
26
26
|
"pandas",
|
|
27
27
|
"plotly<6.0",
|
|
28
|
+
"pydeseq2>=0.5.2",
|
|
28
29
|
"requests",
|
|
29
|
-
"ripser>=0.6.12",
|
|
30
30
|
"scikit-learn",
|
|
31
31
|
"scipy",
|
|
32
32
|
"svgpathtools",
|
|
@@ -35,7 +35,7 @@ dependencies = [
|
|
|
35
35
|
|
|
36
36
|
[project.urls]
|
|
37
37
|
"Repository" = "https://github.com/umbibio/sclab.git"
|
|
38
|
-
"Documentation" = "https://
|
|
38
|
+
"Documentation" = "https://sclab.readthedocs.io"
|
|
39
39
|
"Homepage" = "https://github.com/umbibio/sclab"
|
|
40
40
|
"Bug Tracker" = "https://github.com/umbibio/sclab/issues"
|
|
41
41
|
"Changelog" = "https://github.com/umbibio/sclab/blob/main/CHANGELOG.md"
|
|
@@ -54,23 +54,24 @@ build-backend = "flit_core.buildapi"
|
|
|
54
54
|
name = "sclab"
|
|
55
55
|
source = "src/sclab"
|
|
56
56
|
|
|
57
|
-
[tool.uv.sources]
|
|
58
|
-
sclab-tools = { path = "../sclab-tools" }
|
|
59
|
-
|
|
60
57
|
[dependency-groups]
|
|
58
|
+
docs = [
|
|
59
|
+
"mkdocs>=1.6.1",
|
|
60
|
+
"mkdocs-material>=9.6.3",
|
|
61
|
+
"mkdocs-jupyter>=0.25.1",
|
|
62
|
+
"mkdocstrings[python]>=1.0.3",
|
|
63
|
+
]
|
|
61
64
|
dev = [
|
|
62
65
|
"bump-my-version>=0.31.1",
|
|
63
66
|
"pre-commit>=4.1.0",
|
|
64
67
|
"ruff>=0.9.4",
|
|
65
68
|
"nox>=2024.1.29",
|
|
66
69
|
"pytest>=8.3.4",
|
|
67
|
-
"mkdocs>=1.6.1",
|
|
68
|
-
"mkdocs-material>=9.6.3",
|
|
69
|
-
"mkdocs-jupyter>=0.25.1",
|
|
70
70
|
"scanpy[harmony,leiden,scrublet,skmisc]>=1.10.4",
|
|
71
71
|
"jupyterlab>=4.3.6",
|
|
72
|
-
"sclab-tools",
|
|
73
72
|
"scrublet>=0.2.3",
|
|
74
73
|
"doubletdetection>=4.3.0.post1",
|
|
75
74
|
"sclab[jupyter,r,scanpy]",
|
|
75
|
+
"ripser>=0.6.12",
|
|
76
|
+
{ include-group = "docs" },
|
|
76
77
|
]
|
|
@@ -238,12 +238,25 @@ def _assign_categorical(values: pd.Series, weights: NDArray):
|
|
|
238
238
|
def _assign_numerical(values: pd.Series, weights: NDArray):
|
|
239
239
|
# weighted mean and standard error
|
|
240
240
|
sum_w: float = weights.sum()
|
|
241
|
-
|
|
241
|
+
|
|
242
|
+
# If weights sum to 0, mean and error are undefined
|
|
243
|
+
if sum_w == 0:
|
|
244
|
+
return np.nan, np.nan
|
|
245
|
+
|
|
246
|
+
sum2_w: float = sum_w ** 2
|
|
242
247
|
sum_w2: float = (weights**2).sum()
|
|
243
248
|
n_eff: float = sum2_w / sum_w2
|
|
244
249
|
|
|
245
250
|
mean_x: float = (values * weights).sum() / sum_w
|
|
246
|
-
|
|
251
|
+
|
|
252
|
+
var_denom = sum2_w - sum_w2
|
|
253
|
+
|
|
254
|
+
# If effective sample size is 1, variance is undefined (denominator is 0)
|
|
255
|
+
# We use <= 0 to handle potential floating point inaccuracies
|
|
256
|
+
if var_denom <= 0:
|
|
257
|
+
return mean_x, np.nan
|
|
258
|
+
|
|
259
|
+
var_x: float = ((values - mean_x) ** 2 * weights).sum() * sum_w / var_denom
|
|
247
260
|
err_x: float = np.sqrt(var_x / n_eff)
|
|
248
261
|
|
|
249
262
|
return mean_x, err_x
|
|
@@ -184,7 +184,7 @@ def density_result_1d(
|
|
|
184
184
|
# we recover the original time vector and corresponding density
|
|
185
185
|
x = xx[histogram_nbins : 2 * histogram_nbins]
|
|
186
186
|
d = dd[histogram_nbins : 2 * histogram_nbins] * 3 # correct the density
|
|
187
|
-
ax.bar(x, d, width=
|
|
187
|
+
ax.bar(x, d, width=(tmax - tmin) / histogram_nbins, fill=False, linewidth=0.5)
|
|
188
188
|
|
|
189
189
|
x = np.linspace(tmin, tmax, 2**10 + 1)
|
|
190
190
|
if plot_density_fit:
|
|
@@ -18,6 +18,8 @@ def periodic_genes(
|
|
|
18
18
|
min_pct_power_below: float = 0.75,
|
|
19
19
|
layer: str | None = None,
|
|
20
20
|
):
|
|
21
|
+
import scanpy as sc
|
|
22
|
+
|
|
21
23
|
times = adata.obs[time_key].values.copy()
|
|
22
24
|
if layer is None or layer == "X":
|
|
23
25
|
X = adata.X
|
|
@@ -41,9 +43,10 @@ def periodic_genes(
|
|
|
41
43
|
make_stats=False,
|
|
42
44
|
make_dummies=False,
|
|
43
45
|
)
|
|
46
|
+
sc.pp.normalize_total(aggregated, target_sum=1e4)
|
|
44
47
|
log_cnts = np.log1p(aggregated.X)
|
|
45
48
|
profiles = pd.DataFrame(log_cnts, index=labels, columns=aggregated.var_names)
|
|
46
|
-
ps = power_spectrum_df(profiles)
|
|
49
|
+
ps = power_spectrum_df(profiles, window="boxcar", detrend="constant")
|
|
47
50
|
pp = pct_power_below(ps, 1 / period)
|
|
48
51
|
|
|
49
52
|
adata.varm["profile"] = profiles.T
|
|
@@ -69,7 +72,11 @@ def infer_dt_from_index(idx: pd.Index) -> float:
|
|
|
69
72
|
return dt
|
|
70
73
|
|
|
71
74
|
|
|
72
|
-
def power_spectrum_df(
|
|
75
|
+
def power_spectrum_df(
|
|
76
|
+
X: pd.DataFrame,
|
|
77
|
+
window: str = "boxcar",
|
|
78
|
+
detrend: str = "constant",
|
|
79
|
+
):
|
|
73
80
|
# X: rows=timepoints, columns=variables
|
|
74
81
|
Xd = X - X.mean() # remove DC so percent computations are stable
|
|
75
82
|
dt = infer_dt_from_index(X.index) if X.index.size > 1 else 1.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from ..utils._call_differential_expression import call_differential_expression
|
|
2
|
+
from ._pseudobulk_edger import edger_is_available, pseudobulk_edger
|
|
3
|
+
from ._pseudobulk_limma import limma_is_available, pseudobulk_limma
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"call_differential_expression",
|
|
7
|
+
"pseudobulk_edger",
|
|
8
|
+
"pseudobulk_limma",
|
|
9
|
+
"edger_is_available",
|
|
10
|
+
"limma_is_available",
|
|
11
|
+
]
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
from importlib.util import find_spec
|
|
2
|
+
|
|
1
3
|
import pandas as pd
|
|
2
4
|
from anndata import AnnData
|
|
3
5
|
|
|
4
6
|
from ..utils import aggregate_and_filter
|
|
5
7
|
|
|
8
|
+
PYTHON_DEPENDENCIES = ["rpy2", "anndata2ri"]
|
|
9
|
+
R_DEPENDENCIES = ["edgeR", "MAST", "SingleCellExperiment"]
|
|
10
|
+
|
|
6
11
|
|
|
7
12
|
def edger_is_available() -> bool:
|
|
8
|
-
|
|
9
|
-
_try_imports()
|
|
10
|
-
except ImportError:
|
|
11
|
-
return False
|
|
12
|
-
return True
|
|
13
|
+
return _python_deps_available() and _r_deps_available()
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def pseudobulk_edger(
|
|
@@ -315,3 +316,17 @@ def _try_imports():
|
|
|
315
316
|
)
|
|
316
317
|
print(message)
|
|
317
318
|
raise ImportError(message)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def _python_deps_available() -> bool:
|
|
322
|
+
return all([find_spec(dep) is not None for dep in PYTHON_DEPENDENCIES])
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _r_deps_available() -> bool:
|
|
326
|
+
if not find_spec("rpy2"):
|
|
327
|
+
return False
|
|
328
|
+
|
|
329
|
+
from rpy2.robjects import r
|
|
330
|
+
|
|
331
|
+
installed_packages = list(r("installed.packages()"))
|
|
332
|
+
return all([dep in installed_packages for dep in R_DEPENDENCIES])
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
from importlib.util import find_spec
|
|
2
|
+
|
|
1
3
|
import pandas as pd
|
|
2
4
|
from anndata import AnnData
|
|
3
5
|
|
|
4
6
|
from ..utils import aggregate_and_filter
|
|
5
7
|
|
|
8
|
+
PYTHON_DEPENDENCIES = ["rpy2", "anndata2ri"]
|
|
9
|
+
R_DEPENDENCIES = ["edgeR", "limma", "MAST", "SingleCellExperiment"]
|
|
10
|
+
|
|
6
11
|
|
|
7
12
|
def limma_is_available() -> bool:
|
|
8
|
-
|
|
9
|
-
_try_imports()
|
|
10
|
-
except ImportError:
|
|
11
|
-
return False
|
|
12
|
-
return True
|
|
13
|
+
return _python_deps_available() and _r_deps_available()
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def pseudobulk_limma(
|
|
@@ -327,3 +328,17 @@ def _try_imports():
|
|
|
327
328
|
)
|
|
328
329
|
print(message)
|
|
329
330
|
raise ImportError(message)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def _python_deps_available() -> bool:
|
|
334
|
+
return all([find_spec(dep) is not None for dep in PYTHON_DEPENDENCIES])
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def _r_deps_available() -> bool:
|
|
338
|
+
if not find_spec("rpy2"):
|
|
339
|
+
return False
|
|
340
|
+
|
|
341
|
+
from rpy2.robjects import r
|
|
342
|
+
|
|
343
|
+
installed_packages = list(r("installed.packages()"))
|
|
344
|
+
return all([dep in installed_packages for dep in R_DEPENDENCIES])
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
from importlib.util import find_spec
|
|
1
2
|
from typing import Literal
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
import pandas as pd
|
|
5
6
|
from anndata import AnnData
|
|
6
7
|
|
|
8
|
+
PYTHON_DEPENDENCIES = ["rpy2", "anndata2ri"]
|
|
9
|
+
R_DEPENDENCIES = ["scater", "scDblFinder", "BiocParallel", "SingleCellExperiment"]
|
|
10
|
+
|
|
7
11
|
|
|
8
12
|
def scdblfinder_is_available() -> bool:
|
|
9
|
-
|
|
10
|
-
_try_imports()
|
|
11
|
-
except ImportError:
|
|
12
|
-
return False
|
|
13
|
-
return True
|
|
13
|
+
return _python_deps_available() and _r_deps_available()
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def scdblfinder(
|
|
@@ -184,3 +184,17 @@ def _try_imports():
|
|
|
184
184
|
)
|
|
185
185
|
print(message)
|
|
186
186
|
raise ImportError(message)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _python_deps_available() -> bool:
|
|
190
|
+
return all([find_spec(dep) is not None for dep in PYTHON_DEPENDENCIES])
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _r_deps_available() -> bool:
|
|
194
|
+
if not find_spec("rpy2"):
|
|
195
|
+
return False
|
|
196
|
+
|
|
197
|
+
from rpy2.robjects import r
|
|
198
|
+
|
|
199
|
+
installed_packages = list(r("installed.packages()"))
|
|
200
|
+
return all([dep in installed_packages for dep in R_DEPENDENCIES])
|
|
@@ -144,6 +144,18 @@ def classify_cells(
|
|
|
144
144
|
distances in `adata.uns[neighbors_key]["distances"]`. Defaults to `None`.
|
|
145
145
|
save_scores
|
|
146
146
|
Whether to save the classification scores. Defaults to `False`
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
None
|
|
151
|
+
Results are written in place to `adata.obs[key_added]` (category
|
|
152
|
+
dtype, `pd.NA` for calls below `threshold`) and
|
|
153
|
+
`adata.obs[key_added + "_noNA"]` (best-guess label regardless of
|
|
154
|
+
confidence). `key_added` defaults to `marker_class_key` when not
|
|
155
|
+
given. If `save_scores=True`, also writes
|
|
156
|
+
`adata.obs[key_added + "_score"]` (max per-cell confidence score) and
|
|
157
|
+
`adata.obsm[key_added + "_scores"]` (full class-by-cell score
|
|
158
|
+
matrix).
|
|
147
159
|
"""
|
|
148
160
|
# cite("10.1038/s41467-022-28803-w", __package__)
|
|
149
161
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from pandas import DataFrame, Series
|
|
3
|
+
from scipy.stats import median_abs_deviation
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _robust_z(x: Series):
|
|
7
|
+
# DOI: 10.1080/01621459.1993.10476408
|
|
8
|
+
mad: float = median_abs_deviation(x)
|
|
9
|
+
Sr = 1.4826 * mad
|
|
10
|
+
Zr = (x - x.median()) / Sr
|
|
11
|
+
|
|
12
|
+
return Zr
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def call_differential_expression(
|
|
16
|
+
table: DataFrame,
|
|
17
|
+
pvalue_col: str,
|
|
18
|
+
logfc_col: str,
|
|
19
|
+
pct_col_prefix: str = "pct_",
|
|
20
|
+
max_pval: float = 0.05,
|
|
21
|
+
min_robust_z_level: float = 2.5,
|
|
22
|
+
min_pct: float = 0.05,
|
|
23
|
+
contrast_key: str | None = None,
|
|
24
|
+
copy: bool = False,
|
|
25
|
+
):
|
|
26
|
+
"""Call differentially expressed genes from robust Z-scores of log-fold-change.
|
|
27
|
+
|
|
28
|
+
Flags each row in `table` as up- or down-regulated by combining a p-value
|
|
29
|
+
cutoff, a robust Z-score threshold on `logfc_col` (median-absolute-deviation
|
|
30
|
+
based; DOI: 10.1080/01621459.1993.10476408), and a minimum expression
|
|
31
|
+
percentage across any `pct_*`-prefixed column.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
table : DataFrame
|
|
36
|
+
Differential expression results, one row per gene/feature.
|
|
37
|
+
pvalue_col : str
|
|
38
|
+
Column in `table` with (adjusted) p-values.
|
|
39
|
+
logfc_col : str
|
|
40
|
+
Column in `table` with log-fold-changes.
|
|
41
|
+
pct_col_prefix : str, optional
|
|
42
|
+
Prefix of columns giving percent-expressed values; the max across all
|
|
43
|
+
matching columns is used as the expression filter. Defaults to "pct_".
|
|
44
|
+
max_pval : float, optional
|
|
45
|
+
Maximum p-value for a gene to be called DE. Defaults to 0.05.
|
|
46
|
+
min_robust_z_level : float, optional
|
|
47
|
+
Minimum absolute robust Z-score of `logfc_col` for a gene to be called
|
|
48
|
+
DE. Defaults to 2.5.
|
|
49
|
+
min_pct : float, optional
|
|
50
|
+
Minimum percent-expressed value for a gene to be called DE. Defaults
|
|
51
|
+
to 0.05.
|
|
52
|
+
contrast_key : str or None, optional
|
|
53
|
+
If provided, robust Z-scores are computed independently within each
|
|
54
|
+
`table.groupby(contrast_key)` group rather than across the whole
|
|
55
|
+
table. Defaults to None.
|
|
56
|
+
copy : bool, optional
|
|
57
|
+
If True, operate on and return a copy of `table` instead of modifying
|
|
58
|
+
it in place. Defaults to False.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
DataFrame or None
|
|
63
|
+
`table` with two new columns: `robust_Z` (the computed robust
|
|
64
|
+
Z-score) and `DE` (1 up-regulated, -1 down-regulated, 0 not
|
|
65
|
+
significant). Returned only if `copy=True`; otherwise `table` is
|
|
66
|
+
modified in place and `None` is returned.
|
|
67
|
+
"""
|
|
68
|
+
if copy:
|
|
69
|
+
table = table.copy()
|
|
70
|
+
|
|
71
|
+
pct_expr_high = table.filter(regex=f"^{pct_col_prefix}").max(axis=1)
|
|
72
|
+
|
|
73
|
+
if contrast_key is not None:
|
|
74
|
+
table["robust_Z"] = (
|
|
75
|
+
table.groupby(contrast_key)[logfc_col].apply(_robust_z).droplevel(0)
|
|
76
|
+
)
|
|
77
|
+
else:
|
|
78
|
+
table["robust_Z"] = _robust_z(table[logfc_col])
|
|
79
|
+
|
|
80
|
+
mask = table[pvalue_col] < max_pval
|
|
81
|
+
mask &= table["robust_Z"].abs() > min_robust_z_level
|
|
82
|
+
mask &= pct_expr_high > min_pct
|
|
83
|
+
|
|
84
|
+
table["DE"] = 0
|
|
85
|
+
table.loc[mask, "DE"] = table["robust_Z"].map(np.sign).astype(int)
|
|
86
|
+
|
|
87
|
+
if copy:
|
|
88
|
+
return table
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sclab-0.4.0/src/sclab/tools → sclab-0.4.2/src/sclab/tools/cellflow/_pseudotime}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sclab-0.4.0/src/sclab/tools/cellflow/utils → sclab-0.4.2/src/sclab/tools/embedding}/__init__.py
RENAMED
|
File without changes
|
{sclab-0.4.0/src/sclab/tools/embedding → sclab-0.4.2/src/sclab/tools/imputation}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|