sampledisco 0.4.2__tar.gz → 0.6.0__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.
- {sampledisco-0.4.2/src/sampledisco.egg-info → sampledisco-0.6.0}/PKG-INFO +41 -49
- {sampledisco-0.4.2 → sampledisco-0.6.0}/README.md +17 -45
- {sampledisco-0.4.2 → sampledisco-0.6.0}/pyproject.toml +25 -4
- {sampledisco-0.4.2 → sampledisco-0.6.0}/requirements.txt +8 -7
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/__init__.py +12 -3
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/config/config_demo.yaml +5 -5
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_cell_type_cpu.py +5 -3
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_cell_type_gpu.py +5 -3
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/RAISIN.py +7 -8
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/RAISIN_TEST.py +55 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_distance/ChiSquare.py +1 -1
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_distance/distance_test.py +40 -6
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_distance/jensenshannon.py +1 -1
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_distance/sample_distance.py +25 -16
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_embedding/blocks.py +5 -2
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_embedding/sample_embedding_gpu.py +8 -3
- sampledisco-0.6.0/src/sampledisco/sample_prediction/__init__.py +4 -0
- sampledisco-0.6.0/src/sampledisco/sample_prediction/prediction.py +186 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/CCA.py +12 -1
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/CCA_test.py +50 -14
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/trajectory_DGE_visualization.py +12 -5
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/trajectory_diff_gene.py +26 -0
- sampledisco-0.6.0/src/sampledisco/utils/cpus.py +23 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/embedding_keys.py +22 -8
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/harmony_compat.py +22 -1
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/merge_sample_meta.py +7 -5
- sampledisco-0.6.0/src/sampledisco/wrapper/__init__.py +34 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/wrapper/atac_wrapper.py +4 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/wrapper/multiomics_wrapper.py +15 -7
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/wrapper/rna_wrapper.py +4 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/wrapper/wrapper.py +28 -8
- {sampledisco-0.4.2 → sampledisco-0.6.0/src/sampledisco.egg-info}/PKG-INFO +41 -49
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco.egg-info/SOURCES.txt +6 -1
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco.egg-info/requires.txt +24 -0
- sampledisco-0.6.0/tests/test_sample_prediction.py +154 -0
- sampledisco-0.6.0/tests/test_tutorial_fixes.py +693 -0
- sampledisco-0.4.2/src/sampledisco/wrapper/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/LICENSE +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/setup.cfg +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/cli.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/ATAC_ArchR.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/ATAC_RNA_harmony.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/ATAC_gene_activity.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/ATAC_peak_annotation.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/RNA_name_convertor.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/pseudo_correlation.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/test_pseudo_correlation.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/gene_activity/validation.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/parameter_selection/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/parameter_selection/autotune.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/ATAC_cell_type.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/ATAC_cell_type_gpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/atac_preprocess_cpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/atac_preprocess_gpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/cell_type_cpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/cell_type_gpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_batch_correction.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_glue.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_merge.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/rna_preprocess_cpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/rna_preprocess_gpu.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_association/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_association/association.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/cluster.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/cluster_severity_reconcile.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_clustering/proportion_test.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_distance/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_embedding/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_embedding/sample_embedding.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/TSCAN.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/sample_trajectory/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/Grouping.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/batch_regress.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/imbalance_cell_type_handler.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/inspector.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/limma.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/random_seed.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/safe_save.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/slim_adata.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/subsample.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/subsample_generator.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/tf_idf.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/utils/unify_optimal.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/ATAC_visualization.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/DEG_visualization.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/__init__.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/multi_omics_visualization.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/visualization_embedding.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/visualization_helper.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/visualization/visualization_other.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco.egg-info/dependency_links.txt +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco.egg-info/entry_points.txt +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco.egg-info/top_level.txt +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/tests/test_config_validation.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/tests/test_inplace_uns_and_equal_weight.py +0 -0
- {sampledisco-0.4.2 → sampledisco-0.6.0}/tests/test_sample_embedding_equivalence.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sampledisco
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Cross-omics, cross-condition sample embedding for single-cell data (RNA
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Cross-omics, cross-condition sample embedding for single-cell data (RNA, ATAC, multi-omics)
|
|
5
5
|
Author: Hongkai Ji
|
|
6
6
|
Author-email: Harry Jiang <hjiang55@jh.edu>
|
|
7
7
|
License-Expression: MIT
|
|
8
|
-
Project-URL: Homepage, https://github.com/J041120h/
|
|
8
|
+
Project-URL: Homepage, https://github.com/J041120h/SampleDisco
|
|
9
9
|
Project-URL: Documentation, https://j041120h.github.io/SampleDisco_tutorial/
|
|
10
|
-
Project-URL: Repository, https://github.com/J041120h/
|
|
10
|
+
Project-URL: Repository, https://github.com/J041120h/SampleDisco
|
|
11
11
|
Keywords: single-cell,sample-embedding,multi-omics,scRNA-seq,scATAC-seq,bioinformatics
|
|
12
12
|
Classifier: Development Status :: 3 - Alpha
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -33,6 +33,7 @@ Requires-Dist: harmonypy==0.2.0
|
|
|
33
33
|
Requires-Dist: python-igraph>=0.10
|
|
34
34
|
Requires-Dist: leidenalg>=0.9
|
|
35
35
|
Requires-Dist: networkx>=3.0
|
|
36
|
+
Requires-Dist: pynndescent<0.7,>=0.5.13
|
|
36
37
|
Requires-Dist: POT>=0.9
|
|
37
38
|
Requires-Dist: pygam>=0.9
|
|
38
39
|
Requires-Dist: numba>=0.57
|
|
@@ -44,6 +45,25 @@ Requires-Dist: pybedtools>=0.9
|
|
|
44
45
|
Requires-Dist: pyensembl>=2.3
|
|
45
46
|
Requires-Dist: combat>=0.3
|
|
46
47
|
Requires-Dist: adjustText>=1.0
|
|
48
|
+
Provides-Extra: maxfuse
|
|
49
|
+
Requires-Dist: maxfuse==0.0.2; extra == "maxfuse"
|
|
50
|
+
Requires-Dist: anndata<0.13; extra == "maxfuse"
|
|
51
|
+
Provides-Extra: glue
|
|
52
|
+
Requires-Dist: scglue==0.3.2; extra == "glue"
|
|
53
|
+
Requires-Dist: harmony-pytorch==0.1.8; extra == "glue"
|
|
54
|
+
Requires-Dist: anndata<0.11; extra == "glue"
|
|
55
|
+
Requires-Dist: torch<2.7; extra == "glue"
|
|
56
|
+
Provides-Extra: multiomics
|
|
57
|
+
Requires-Dist: scglue==0.3.2; extra == "multiomics"
|
|
58
|
+
Requires-Dist: harmony-pytorch==0.1.8; extra == "multiomics"
|
|
59
|
+
Requires-Dist: anndata<0.11; extra == "multiomics"
|
|
60
|
+
Requires-Dist: torch<2.7; extra == "multiomics"
|
|
61
|
+
Provides-Extra: all
|
|
62
|
+
Requires-Dist: maxfuse==0.0.2; extra == "all"
|
|
63
|
+
Requires-Dist: scglue==0.3.2; extra == "all"
|
|
64
|
+
Requires-Dist: harmony-pytorch==0.1.8; extra == "all"
|
|
65
|
+
Requires-Dist: anndata<0.11; extra == "all"
|
|
66
|
+
Requires-Dist: torch<2.7; extra == "all"
|
|
47
67
|
Dynamic: license-file
|
|
48
68
|
|
|
49
69
|
# SampleDisco
|
|
@@ -72,14 +92,14 @@ It then assembles **four blocks** per sample (or per sample × modality for mult
|
|
|
72
92
|
3. **A3** — soft k-means composition at K_fine (≈300)
|
|
73
93
|
4. **RMD** — leave-one-out cell-type-resolved displacement on `Z_rmd`
|
|
74
94
|
|
|
75
|
-
The four blocks are inverse-variance weighted, Frobenius-stacked, PCA-reduced to 10 dimensions, and Harmony-corrected at sample level. The result is stored as `adata.uns['X_DR_sample']` and feeds every downstream module.
|
|
95
|
+
The four blocks are inverse-variance weighted, Frobenius-stacked, PCA-reduced to 10 dimensions (at most the number of samples − 1), and Harmony-corrected at sample level when there are at least 8 samples in more than one batch / modality group. The result is stored as `adata.uns['X_DR_sample']` and feeds every downstream module.
|
|
76
96
|
|
|
77
97
|
---
|
|
78
98
|
|
|
79
99
|
## Repository layout
|
|
80
100
|
|
|
81
101
|
```
|
|
82
|
-
|
|
102
|
+
./
|
|
83
103
|
├── pyproject.toml # package metadata; `pip install -e .` installs the `sampledisco` command
|
|
84
104
|
├── config/ # 10 YAML configs for the paper's datasets: covid / blood (1M-scBloodNL) / eye / heart / ENCODE / healthy-aging PBMC / long_covid / unpaired (+ RNA-tuned) / default
|
|
85
105
|
├── src/sampledisco/ # the package
|
|
@@ -106,9 +126,10 @@ code/
|
|
|
106
126
|
│ ├── parameter_selection/
|
|
107
127
|
│ │ └── autotune.py # Bayesian GP sweep over RMD α; adaptive proxy ensemble
|
|
108
128
|
│ ├── sample_distance/ # Pairwise sample distances (DR / EMD / chi-square / JS)
|
|
109
|
-
│ ├── sample_clustering/ #
|
|
129
|
+
│ ├── sample_clustering/ # K-means sample clusters, proportion test, RAISIN cluster DGE
|
|
110
130
|
│ ├── sample_trajectory/ # CCA (supervised) and TSCAN (unsupervised) + GAM-based trajectory DGE
|
|
111
131
|
│ ├── sample_association/ # Per-PC variance explained vs sample-level covariates (permutation FDR)
|
|
132
|
+
│ ├── sample_prediction/ # Cross-validated phenotype prediction from the PCs; kNN label transfer
|
|
112
133
|
│ ├── visualization/ # Embedding plots, dendrograms, DGE volcanos, modality-aware multi-omics scatters
|
|
113
134
|
│ ├── utils/ # Shared helpers: seed, safe h5ad I/O, limma, TF-IDF, batch regress, Grouping
|
|
114
135
|
│ └── gene_activity/ # ATAC peak → gene activity inference + RNA-ATAC validation
|
|
@@ -182,51 +203,22 @@ For multi-omics, the pipeline takes two separate h5ads (RNA + ATAC) and integrat
|
|
|
182
203
|
|
|
183
204
|
## Installation
|
|
184
205
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
detects and uses them at runtime. There is no separate "GPU build" of SampleDisco.
|
|
188
|
-
|
|
189
|
-
### 1. Core install (CPU)
|
|
206
|
+
One conda environment runs every part of the package: the RNA / ATAC / multi-omics
|
|
207
|
+
pipelines, scGLUE training (with `bedtools`), MaxFuse and all downstream analyses.
|
|
190
208
|
|
|
191
209
|
```bash
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
### 2. System prerequisite — bedtools
|
|
196
|
-
|
|
197
|
-
scGLUE (the multi-omics integrator) calls the `bedtools` binary, which pip cannot
|
|
198
|
-
provide:
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
conda install -c bioconda bedtools
|
|
202
|
-
```
|
|
210
|
+
# CPU (recommended)
|
|
211
|
+
conda env create -f environment-cpu.yml && conda activate sampledisco-cpu
|
|
203
212
|
|
|
204
|
-
|
|
213
|
+
# GPU (Linux + NVIDIA): the CPU environment + RAPIDS 24.12
|
|
214
|
+
conda env create -f environment-gpu.yml && conda activate sampledisco-gpu
|
|
215
|
+
pip install --no-deps rapids-singlecell==0.13.1 sampledisco==0.6.0
|
|
205
216
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
environment. RAPIDS is CUDA-driver-specific and conda-only, so you install it
|
|
209
|
-
separately, matching your driver (the pins below target a CUDA-12.5 driver such as
|
|
210
|
-
the cluster's GPU nodes):
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
conda install -c rapidsai -c conda-forge -c nvidia \
|
|
214
|
-
cuml=24.12 cudf=24.12 cugraph=24.12 rmm=24.12 cuvs=24.12 cupy=13 cuda-version=12.5
|
|
215
|
-
pip install rapids-singlecell==0.13.1 --no-deps
|
|
217
|
+
# pip only
|
|
218
|
+
pip install "sampledisco[all]" && conda install -c bioconda -c conda-forge bedtools
|
|
216
219
|
```
|
|
217
220
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
### One-command environments (recommended)
|
|
224
|
-
|
|
225
|
-
For a fully reproducible environment (including bedtools), use the provided conda
|
|
226
|
-
files instead of the manual steps above — see `INSTALL.md` for the driver/version
|
|
227
|
-
notes:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
conda env create -f environment-cpu.yml # CPU
|
|
231
|
-
conda env create -f environment-gpu.yml # GPU (RAPIDS 24.12)
|
|
232
|
-
```
|
|
221
|
+
`pip install sampledisco` alone gives the core pipeline; the extras `[glue]`, `[maxfuse]`
|
|
222
|
+
and `[all]` add scGLUE and MaxFuse. GPU acceleration runs only with `use_gpu: true` in the
|
|
223
|
+
config (otherwise, or when RAPIDS is missing, the CPU path runs). See `INSTALL.md` for the
|
|
224
|
+
version pins, driver notes and troubleshooting.
|
|
@@ -24,14 +24,14 @@ It then assembles **four blocks** per sample (or per sample × modality for mult
|
|
|
24
24
|
3. **A3** — soft k-means composition at K_fine (≈300)
|
|
25
25
|
4. **RMD** — leave-one-out cell-type-resolved displacement on `Z_rmd`
|
|
26
26
|
|
|
27
|
-
The four blocks are inverse-variance weighted, Frobenius-stacked, PCA-reduced to 10 dimensions, and Harmony-corrected at sample level. The result is stored as `adata.uns['X_DR_sample']` and feeds every downstream module.
|
|
27
|
+
The four blocks are inverse-variance weighted, Frobenius-stacked, PCA-reduced to 10 dimensions (at most the number of samples − 1), and Harmony-corrected at sample level when there are at least 8 samples in more than one batch / modality group. The result is stored as `adata.uns['X_DR_sample']` and feeds every downstream module.
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
31
|
## Repository layout
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
|
|
34
|
+
./
|
|
35
35
|
├── pyproject.toml # package metadata; `pip install -e .` installs the `sampledisco` command
|
|
36
36
|
├── config/ # 10 YAML configs for the paper's datasets: covid / blood (1M-scBloodNL) / eye / heart / ENCODE / healthy-aging PBMC / long_covid / unpaired (+ RNA-tuned) / default
|
|
37
37
|
├── src/sampledisco/ # the package
|
|
@@ -58,9 +58,10 @@ code/
|
|
|
58
58
|
│ ├── parameter_selection/
|
|
59
59
|
│ │ └── autotune.py # Bayesian GP sweep over RMD α; adaptive proxy ensemble
|
|
60
60
|
│ ├── sample_distance/ # Pairwise sample distances (DR / EMD / chi-square / JS)
|
|
61
|
-
│ ├── sample_clustering/ #
|
|
61
|
+
│ ├── sample_clustering/ # K-means sample clusters, proportion test, RAISIN cluster DGE
|
|
62
62
|
│ ├── sample_trajectory/ # CCA (supervised) and TSCAN (unsupervised) + GAM-based trajectory DGE
|
|
63
63
|
│ ├── sample_association/ # Per-PC variance explained vs sample-level covariates (permutation FDR)
|
|
64
|
+
│ ├── sample_prediction/ # Cross-validated phenotype prediction from the PCs; kNN label transfer
|
|
64
65
|
│ ├── visualization/ # Embedding plots, dendrograms, DGE volcanos, modality-aware multi-omics scatters
|
|
65
66
|
│ ├── utils/ # Shared helpers: seed, safe h5ad I/O, limma, TF-IDF, batch regress, Grouping
|
|
66
67
|
│ └── gene_activity/ # ATAC peak → gene activity inference + RNA-ATAC validation
|
|
@@ -134,51 +135,22 @@ For multi-omics, the pipeline takes two separate h5ads (RNA + ATAC) and integrat
|
|
|
134
135
|
|
|
135
136
|
## Installation
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
detects and uses them at runtime. There is no separate "GPU build" of SampleDisco.
|
|
140
|
-
|
|
141
|
-
### 1. Core install (CPU)
|
|
138
|
+
One conda environment runs every part of the package: the RNA / ATAC / multi-omics
|
|
139
|
+
pipelines, scGLUE training (with `bedtools`), MaxFuse and all downstream analyses.
|
|
142
140
|
|
|
143
141
|
```bash
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### 2. System prerequisite — bedtools
|
|
148
|
-
|
|
149
|
-
scGLUE (the multi-omics integrator) calls the `bedtools` binary, which pip cannot
|
|
150
|
-
provide:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
conda install -c bioconda bedtools
|
|
154
|
-
```
|
|
142
|
+
# CPU (recommended)
|
|
143
|
+
conda env create -f environment-cpu.yml && conda activate sampledisco-cpu
|
|
155
144
|
|
|
156
|
-
|
|
145
|
+
# GPU (Linux + NVIDIA): the CPU environment + RAPIDS 24.12
|
|
146
|
+
conda env create -f environment-gpu.yml && conda activate sampledisco-gpu
|
|
147
|
+
pip install --no-deps rapids-singlecell==0.13.1 sampledisco==0.6.0
|
|
157
148
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
environment. RAPIDS is CUDA-driver-specific and conda-only, so you install it
|
|
161
|
-
separately, matching your driver (the pins below target a CUDA-12.5 driver such as
|
|
162
|
-
the cluster's GPU nodes):
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
conda install -c rapidsai -c conda-forge -c nvidia \
|
|
166
|
-
cuml=24.12 cudf=24.12 cugraph=24.12 rmm=24.12 cuvs=24.12 cupy=13 cuda-version=12.5
|
|
167
|
-
pip install rapids-singlecell==0.13.1 --no-deps
|
|
149
|
+
# pip only
|
|
150
|
+
pip install "sampledisco[all]" && conda install -c bioconda -c conda-forge bedtools
|
|
168
151
|
```
|
|
169
152
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
### One-command environments (recommended)
|
|
176
|
-
|
|
177
|
-
For a fully reproducible environment (including bedtools), use the provided conda
|
|
178
|
-
files instead of the manual steps above — see `INSTALL.md` for the driver/version
|
|
179
|
-
notes:
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
conda env create -f environment-cpu.yml # CPU
|
|
183
|
-
conda env create -f environment-gpu.yml # GPU (RAPIDS 24.12)
|
|
184
|
-
```
|
|
153
|
+
`pip install sampledisco` alone gives the core pipeline; the extras `[glue]`, `[maxfuse]`
|
|
154
|
+
and `[all]` add scGLUE and MaxFuse. GPU acceleration runs only with `use_gpu: true` in the
|
|
155
|
+
config (otherwise, or when RAPIDS is missing, the CPU path runs). See `INSTALL.md` for the
|
|
156
|
+
version pins, driver notes and troubleshooting.
|
|
@@ -9,8 +9,8 @@ build-backend = "setuptools.build_meta"
|
|
|
9
9
|
|
|
10
10
|
[project]
|
|
11
11
|
name = "sampledisco"
|
|
12
|
-
version = "0.
|
|
13
|
-
description = "Cross-omics, cross-condition sample embedding for single-cell data (RNA
|
|
12
|
+
version = "0.6.0"
|
|
13
|
+
description = "Cross-omics, cross-condition sample embedding for single-cell data (RNA, ATAC, multi-omics)"
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
requires-python = ">=3.10"
|
|
16
16
|
license = "MIT"
|
|
@@ -29,10 +29,31 @@ classifiers = [
|
|
|
29
29
|
]
|
|
30
30
|
dynamic = ["dependencies"]
|
|
31
31
|
|
|
32
|
+
# Optional feature sets. `pip install "sampledisco[all]"` gives one environment
|
|
33
|
+
# that runs every CPU part of the package (RAPIDS GPU stack: environment-gpu.yml).
|
|
34
|
+
# Training GLUE additionally needs the bedtools binary: conda install -c bioconda bedtools
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
# MaxFuse 0.0.2 calls AnnData(arr, dtype=...), which anndata 0.13 removed.
|
|
37
|
+
maxfuse = ["maxfuse==0.0.2", "anndata<0.13"]
|
|
38
|
+
# scGLUE 0.3.2 imports anndata._core.sparse_dataset.SparseDataset, removed in
|
|
39
|
+
# anndata 0.11, and its training calls ReduceLROnPlateau(verbose=...), removed in
|
|
40
|
+
# torch 2.7 (its own metadata says only anndata>=0.7, torch>=1.8). harmony-pytorch is
|
|
41
|
+
# the torch Harmony backend used by the RNA+ATAC gene-activity path.
|
|
42
|
+
glue = ["scglue==0.3.2", "harmony-pytorch==0.1.8", "anndata<0.11", "torch<2.7"]
|
|
43
|
+
# Same as glue; the name used in older docs and in sampledisco.utils.harmony_compat.
|
|
44
|
+
multiomics = ["scglue==0.3.2", "harmony-pytorch==0.1.8", "anndata<0.11", "torch<2.7"]
|
|
45
|
+
all = [
|
|
46
|
+
"maxfuse==0.0.2",
|
|
47
|
+
"scglue==0.3.2",
|
|
48
|
+
"harmony-pytorch==0.1.8",
|
|
49
|
+
"anndata<0.11",
|
|
50
|
+
"torch<2.7",
|
|
51
|
+
]
|
|
52
|
+
|
|
32
53
|
[project.urls]
|
|
33
|
-
Homepage = "https://github.com/J041120h/
|
|
54
|
+
Homepage = "https://github.com/J041120h/SampleDisco"
|
|
34
55
|
Documentation = "https://j041120h.github.io/SampleDisco_tutorial/"
|
|
35
|
-
Repository = "https://github.com/J041120h/
|
|
56
|
+
Repository = "https://github.com/J041120h/SampleDisco"
|
|
36
57
|
|
|
37
58
|
[project.scripts]
|
|
38
59
|
sampledisco = "sampledisco.cli:main"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# SampleDisco core (CPU) dependencies. PyTorch is installed as a dependency of harmonypy 0.2.0.
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# the CPU path when they are absent.
|
|
2
|
+
# scGLUE/harmony-pytorch and MaxFuse are optional extras
|
|
3
|
+
# (pip install "sampledisco[all]", see pyproject.toml). A CUDA build of torch and RAPIDS
|
|
4
|
+
# GPU acceleration are NOT installed here — they're OS/driver-specific (see INSTALL.md,
|
|
5
|
+
# environment-gpu.yml). SampleDisco falls back to the CPU path when they are absent.
|
|
6
6
|
numpy>=1.23
|
|
7
7
|
pandas>=1.5
|
|
8
8
|
scipy>=1.9
|
|
@@ -19,6 +19,7 @@ harmonypy==0.2.0 # the version used for the published results; it requires tor
|
|
|
19
19
|
python-igraph>=0.10
|
|
20
20
|
leidenalg>=0.9
|
|
21
21
|
networkx>=3.0
|
|
22
|
+
pynndescent>=0.5.13,<0.7 # 0.7 (and umap-learn 0.6, which needs it) break sc.pp.neighbors on >~8k cells
|
|
22
23
|
POT>=0.9
|
|
23
24
|
pygam>=0.9
|
|
24
25
|
numba>=0.57
|
|
@@ -33,6 +34,6 @@ pyensembl>=2.3
|
|
|
33
34
|
# cluster-DGE (RAISIN) — both on the live downstream path
|
|
34
35
|
combat>=0.3
|
|
35
36
|
adjustText>=1.0
|
|
36
|
-
# NOTE: scGLUE (only for training GLUE from scratch) is
|
|
37
|
-
# install it
|
|
38
|
-
# bioconda scglue` — the bioconda recipe caps numpy<1.22 and breaks the stack.
|
|
37
|
+
# NOTE: scGLUE (only for training GLUE from scratch) is the [glue] extra, not a core
|
|
38
|
+
# dependency — install it from PyPI (`pip install "sampledisco[glue]"`), never `conda
|
|
39
|
+
# install -c bioconda scglue` — the bioconda recipe caps numpy<1.22 and breaks the stack.
|
|
@@ -6,6 +6,8 @@ pull scanpy / torch / scGLUE until you actually call into the pipeline):
|
|
|
6
6
|
import sampledisco
|
|
7
7
|
sampledisco.wrapper(...) # full pipeline (RNA / ATAC / multi-omics)
|
|
8
8
|
sampledisco.compute_sample_embedding(...) # the core method only
|
|
9
|
+
sampledisco.predict_phenotype(...) # cross-validated phenotype prediction from the PCs
|
|
10
|
+
sampledisco.transfer_labels(...) # kNN label transfer in the sample embedding
|
|
9
11
|
|
|
10
12
|
The CLI entry point is ``sampledisco --config <yaml>`` (see ``sampledisco.cli``).
|
|
11
13
|
"""
|
|
@@ -18,15 +20,22 @@ try:
|
|
|
18
20
|
except PackageNotFoundError: # running from a source tree that isn't installed
|
|
19
21
|
__version__ = "0.0.0+unknown"
|
|
20
22
|
|
|
21
|
-
__all__ = ["wrapper", "compute_sample_embedding"]
|
|
23
|
+
__all__ = ["wrapper", "compute_sample_embedding", "predict_phenotype", "transfer_labels"]
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
def __getattr__(name: str):
|
|
25
27
|
# PEP 562 lazy attribute access — defer heavy imports to first use.
|
|
26
28
|
if name == "wrapper":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
# Return the (callable) ``sampledisco.wrapper`` subpackage, not the function:
|
|
30
|
+
# importing any of its submodules rebinds this attribute to the package, so
|
|
31
|
+
# returning the function here made ``from sampledisco import wrapper`` yield
|
|
32
|
+
# a non-callable module. Calling the package runs wrapper.wrapper.wrapper.
|
|
33
|
+
import importlib
|
|
34
|
+
return importlib.import_module("sampledisco.wrapper")
|
|
29
35
|
if name == "compute_sample_embedding":
|
|
30
36
|
from sampledisco.sample_embedding import compute_sample_embedding
|
|
31
37
|
return compute_sample_embedding
|
|
38
|
+
if name in ("predict_phenotype", "transfer_labels"):
|
|
39
|
+
from sampledisco.sample_prediction import prediction
|
|
40
|
+
return getattr(prediction, name)
|
|
32
41
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# SampleDisco — DEMO CONFIG (Zenodo tutorial data)
|
|
3
3
|
# =============================================================================
|
|
4
4
|
# Ready-to-run config for the demo datasets published at
|
|
5
|
-
# https://doi.org/10.5281/zenodo.
|
|
5
|
+
# https://doi.org/10.5281/zenodo.22549610 (concept DOI — always resolves to the latest version)
|
|
6
6
|
# Quick start (run from a folder that contains ./data/test_RNA.h5ad and
|
|
7
7
|
# ./data/test_ATAC.h5ad — see the "Demo data" tutorial page):
|
|
8
8
|
# sampledisco -m complex --config <this-file>.yaml
|
|
@@ -59,7 +59,7 @@ rna_pseudo_adata_path:
|
|
|
59
59
|
# --- Common Column Names ---
|
|
60
60
|
rna_sample_col: "sample"
|
|
61
61
|
rna_sample_level_batch_col: "batch"
|
|
62
|
-
rna_celltype_col: "cell_type" #
|
|
62
|
+
rna_celltype_col: "cell_type" # existing labels to start from (existing_cell_types:true) and the label column used when cell typing is off. Cell typing always writes obs['cell_type'], which later stages then use. The demo .h5ad's precomputed labels are in 'celltype' — set this to "celltype" only if you flip existing_cell_types:true.
|
|
63
63
|
|
|
64
64
|
# --- Preprocessing Parameters ---
|
|
65
65
|
rna_min_cells: 100
|
|
@@ -108,7 +108,7 @@ rna_trajectory_visualization_label:
|
|
|
108
108
|
rna_cca_pvalue: false
|
|
109
109
|
rna_tscan_origin:
|
|
110
110
|
rna_tscan_n_clusters: 3 # int; null lets TSCAN auto-select via BIC (2-20)
|
|
111
|
-
rna_tscan_pseudotime_mode: "rank" # "rank" or "
|
|
111
|
+
rna_tscan_pseudotime_mode: "rank" # "rank" or "distance"
|
|
112
112
|
|
|
113
113
|
# --- Sample Distance Parameters ---
|
|
114
114
|
rna_sample_distance_methods:
|
|
@@ -230,7 +230,7 @@ atac_trajectory_visualization_label:
|
|
|
230
230
|
atac_cca_pvalue: false
|
|
231
231
|
atac_tscan_origin:
|
|
232
232
|
atac_tscan_n_clusters: 3 # int; null lets TSCAN auto-select via BIC (2-20)
|
|
233
|
-
atac_tscan_pseudotime_mode: "rank" # "rank" or "
|
|
233
|
+
atac_tscan_pseudotime_mode: "rank" # "rank" or "distance"
|
|
234
234
|
|
|
235
235
|
# --- Sample Distance Parameters ---
|
|
236
236
|
atac_sample_distance_methods:
|
|
@@ -399,7 +399,7 @@ multiomics_n_cca_pcs: 5
|
|
|
399
399
|
multiomics_cca_pvalue: false
|
|
400
400
|
multiomics_tscan_origin:
|
|
401
401
|
multiomics_tscan_n_clusters: # int; null lets TSCAN auto-select via BIC (2-20)
|
|
402
|
-
multiomics_tscan_pseudotime_mode: "rank" # "rank" or "
|
|
402
|
+
multiomics_tscan_pseudotime_mode: "rank" # "rank" or "distance"
|
|
403
403
|
|
|
404
404
|
# --- Sample Distance Parameters ---
|
|
405
405
|
multiomics_sample_distance_methods:
|
{sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_cell_type_cpu.py
RENAMED
|
@@ -229,6 +229,7 @@ def cell_types_multiomics(
|
|
|
229
229
|
adata=adata,
|
|
230
230
|
modality_column=modality_column,
|
|
231
231
|
cluster_column=cell_type_column,
|
|
232
|
+
modality_values=(rna_modality_value, atac_modality_value),
|
|
232
233
|
min_proportion_of_expected=0.05,
|
|
233
234
|
verbose=verbose
|
|
234
235
|
)
|
|
@@ -278,9 +279,10 @@ def cell_types_multiomics(
|
|
|
278
279
|
)
|
|
279
280
|
|
|
280
281
|
if save and output_dir and not defined_output_path:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
# output_dir already points at <output_dir>/preprocess (rebound above);
|
|
283
|
+
# joining "preprocess" again wrote preprocess/preprocess/ in <= 0.5.0.
|
|
284
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
285
|
+
save_path = os.path.join(output_dir, "adata_preprocessed.h5ad")
|
|
284
286
|
safe_h5ad_write(adata, save_path)
|
|
285
287
|
|
|
286
288
|
if defined_output_path:
|
{sampledisco-0.4.2 → sampledisco-0.6.0}/src/sampledisco/preparation/multi_omics_cell_type_gpu.py
RENAMED
|
@@ -242,6 +242,7 @@ def cell_types_multiomics_gpu(
|
|
|
242
242
|
adata=adata,
|
|
243
243
|
modality_column=modality_column,
|
|
244
244
|
cluster_column=cell_type_column,
|
|
245
|
+
modality_values=(rna_modality_value, atac_modality_value),
|
|
245
246
|
min_proportion_of_expected=0.05,
|
|
246
247
|
verbose=verbose
|
|
247
248
|
)
|
|
@@ -312,9 +313,10 @@ def cell_types_multiomics_gpu(
|
|
|
312
313
|
)
|
|
313
314
|
|
|
314
315
|
if save and output_dir and not defined_output_path:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
# output_dir already points at <output_dir>/preprocess (rebound above);
|
|
317
|
+
# joining "preprocess" again wrote preprocess/preprocess/ in <= 0.5.0.
|
|
318
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
319
|
+
save_path = os.path.join(output_dir, "adata_preprocessed.h5ad")
|
|
318
320
|
print(f"Saving integrated data to: {save_path}")
|
|
319
321
|
safe_h5ad_write(adata, save_path)
|
|
320
322
|
|
|
@@ -200,6 +200,12 @@ def apply_combat_correction(adata, batch_col, group_col=None, sample_col=None, v
|
|
|
200
200
|
return adata_corrected
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
# Worker count for n_jobs None/-1: the CPU-affinity/cgroup mask (not the node-wide
|
|
204
|
+
# core count, which over-subscribes shared nodes and multiplies ComBat's peak
|
|
205
|
+
# memory), capped at SLURM_CPUS_PER_TASK. Shared with utils.harmony_compat.
|
|
206
|
+
from sampledisco.utils.cpus import resolve_n_jobs as _resolve_n_jobs
|
|
207
|
+
|
|
208
|
+
|
|
203
209
|
def raisinfit(
|
|
204
210
|
adata,
|
|
205
211
|
sample_col,
|
|
@@ -277,14 +283,7 @@ def raisinfit(
|
|
|
277
283
|
# -----------------------------------------------------------------
|
|
278
284
|
# Setup
|
|
279
285
|
# -----------------------------------------------------------------
|
|
280
|
-
|
|
281
|
-
# Respect the CPU-affinity/cgroup mask (SLURM, containers, cgroups) rather
|
|
282
|
-
# than the node-wide core count — the latter over-subscribes on shared
|
|
283
|
-
# nodes and multiplies peak memory (ComBat), causing OOM kills.
|
|
284
|
-
try:
|
|
285
|
-
n_jobs = len(os.sched_getaffinity(0))
|
|
286
|
-
except AttributeError: # sched_getaffinity is Linux-only
|
|
287
|
-
n_jobs = cpu_count()
|
|
286
|
+
n_jobs = _resolve_n_jobs(n_jobs)
|
|
288
287
|
if verbose:
|
|
289
288
|
print(f"Using {n_jobs} CPU cores")
|
|
290
289
|
|
|
@@ -410,6 +410,24 @@ def plot_journal_dotplot(
|
|
|
410
410
|
plt.close()
|
|
411
411
|
|
|
412
412
|
|
|
413
|
+
def _failgroups_hit(fit, kZ, group):
|
|
414
|
+
"""Groups in fit['failgroup'] (variance not estimable, set to 0) whose variance
|
|
415
|
+
enters this contrast's variance, i.e. with a non-zero weight in k @ Z."""
|
|
416
|
+
fail = {str(g) for g in (fit.get('failgroup') or [])}
|
|
417
|
+
if not fail:
|
|
418
|
+
return []
|
|
419
|
+
w = np.abs(np.asarray(kZ, dtype=np.float64))
|
|
420
|
+
used = w > 1e-8 * max(w.max(), np.finfo(np.float64).tiny)
|
|
421
|
+
return sorted(str(g) for g in fail & set(np.asarray(group).astype(str)[used]))
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def _contrast_kZ(fit, contrast):
|
|
425
|
+
"""k @ Z for a contrast, computed exactly as in raisintest."""
|
|
426
|
+
X = np.asarray(fit['X'], dtype=np.float64)
|
|
427
|
+
k = np.asarray(contrast, dtype=np.float64) @ np.linalg.pinv(X.T @ X) @ X.T
|
|
428
|
+
return k @ np.asarray(fit['Z'], dtype=np.float64)
|
|
429
|
+
|
|
430
|
+
|
|
413
431
|
def raisintest(
|
|
414
432
|
fit,
|
|
415
433
|
coef: int = 2,
|
|
@@ -482,6 +500,21 @@ def raisintest(
|
|
|
482
500
|
b = means @ k
|
|
483
501
|
|
|
484
502
|
kZ = k @ Z
|
|
503
|
+
bad = _failgroups_hit(fit, kZ, group)
|
|
504
|
+
if bad:
|
|
505
|
+
# A zero (non-estimable) variance would make every gene look significant.
|
|
506
|
+
warnings.warn(
|
|
507
|
+
f"[RAISIN] contrast uses group(s) {bad} whose variance could not be "
|
|
508
|
+
f"estimated (zero residual df, e.g. a single sample); stat/pvalue/FDR "
|
|
509
|
+
f"are set to NaN.", RuntimeWarning, stacklevel=2)
|
|
510
|
+
nan = np.full(G, np.nan)
|
|
511
|
+
res = pd.DataFrame({'Foldchange': b, 'stat': nan, 'pvalue': nan, 'FDR': nan},
|
|
512
|
+
index=gene_names)
|
|
513
|
+
if output_dir:
|
|
514
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
515
|
+
res.to_csv(os.path.join(output_dir, "raisin_results.csv"))
|
|
516
|
+
return res
|
|
517
|
+
|
|
485
518
|
sigma2_by_group = np.zeros((G, len(group)))
|
|
486
519
|
for i, g in enumerate(group):
|
|
487
520
|
if g in sigma2_columns:
|
|
@@ -649,6 +682,15 @@ def run_pairwise_tests(
|
|
|
649
682
|
if verbose:
|
|
650
683
|
print(f"Starting pairwise comparisons. Found {len(pairs)} pairs.")
|
|
651
684
|
|
|
685
|
+
failgroups = sorted({str(g) for g in (fit.get('failgroup') or [])})
|
|
686
|
+
if failgroups:
|
|
687
|
+
warnings.warn(
|
|
688
|
+
f"[RAISIN] Variance could not be estimated for group(s) {failgroups} (zero "
|
|
689
|
+
f"residual degrees of freedom, e.g. a single-sample group) and was set to 0. "
|
|
690
|
+
f"Comparisons that use these groups would be badly overconfident, so they are "
|
|
691
|
+
f"skipped (marked FAILED) and report no significant genes.",
|
|
692
|
+
RuntimeWarning, stacklevel=2)
|
|
693
|
+
|
|
652
694
|
results_summary = {}
|
|
653
695
|
all_results = {}
|
|
654
696
|
failed_comparisons = {}
|
|
@@ -682,6 +724,19 @@ def run_pairwise_tests(
|
|
|
682
724
|
contrast[idx_g1] = 1
|
|
683
725
|
contrast[idx_g2] = -1
|
|
684
726
|
|
|
727
|
+
bad = (_failgroups_hit(fit, _contrast_kZ(fit, contrast), fit['group'])
|
|
728
|
+
if failgroups else [])
|
|
729
|
+
if bad:
|
|
730
|
+
reason = (f"variance not estimable for group(s) {bad} (zero residual df, "
|
|
731
|
+
f"e.g. a single sample); not tested")
|
|
732
|
+
print(f"Skipping {comp_name}: {reason}.")
|
|
733
|
+
failed_comparisons[comp_name] = f"skipped: {reason}"
|
|
734
|
+
if output_dir:
|
|
735
|
+
os.makedirs(sub_dir, exist_ok=True)
|
|
736
|
+
with open(os.path.join(sub_dir, "FAILED"), "w") as fh:
|
|
737
|
+
fh.write(f"skipped: {reason}\n")
|
|
738
|
+
continue
|
|
739
|
+
|
|
685
740
|
try:
|
|
686
741
|
res = raisintest(
|
|
687
742
|
fit,
|
|
@@ -10,7 +10,7 @@ from typing import Optional
|
|
|
10
10
|
from anndata._core.aligned_df import ImplicitModificationWarning
|
|
11
11
|
|
|
12
12
|
import sys
|
|
13
|
-
from sampledisco.visualization.visualization_helper import visualizeDistanceMatrix
|
|
13
|
+
from sampledisco.visualization.visualization_helper import visualizeDistanceMatrix, plot_cell_type_abundances
|
|
14
14
|
from sampledisco.sample_distance.distance_test import distanceCheck
|
|
15
15
|
|
|
16
16
|
warnings.filterwarnings("ignore", category=ImplicitModificationWarning)
|