crispyx 0.2.4__tar.gz → 0.2.5__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.
- {crispyx-0.2.4/src/crispyx.egg-info → crispyx-0.2.5}/PKG-INFO +5 -5
- {crispyx-0.2.4 → crispyx-0.2.5}/README.md +4 -4
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/__init__.py +18 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_namespaces.py +90 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_version.py +1 -1
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/data.py +759 -220
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/de.py +983 -95
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/glm.py +63 -104
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/plotting.py +2 -1
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/pseudobulk.py +85 -9
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/qc.py +393 -1
- {crispyx-0.2.4 → crispyx-0.2.5/src/crispyx.egg-info}/PKG-INFO +5 -5
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx.egg-info/SOURCES.txt +8 -0
- crispyx-0.2.5/tests/test_assign_guides.py +88 -0
- crispyx-0.2.5/tests/test_atomic_outputs.py +168 -0
- crispyx-0.2.5/tests/test_check_data.py +201 -0
- crispyx-0.2.5/tests/test_collapse_genes.py +122 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_concat_h5ad.py +1 -1
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_convert_format.py +4 -1
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_data_helpers.py +9 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_nb_glm.py +27 -0
- crispyx-0.2.5/tests/test_nb_offset.py +386 -0
- crispyx-0.2.5/tests/test_pseudobulk_sparse_output.py +95 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_rank_genes_groups_outputs.py +17 -0
- crispyx-0.2.5/tests/test_recover_counts.py +106 -0
- crispyx-0.2.5/tests/test_shrink_lfc_arrays.py +79 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_stream_on_fast_axis.py +6 -5
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_two_group_deseq2.py +16 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/LICENSE +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/pyproject.toml +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/setup.cfg +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_checkpoint.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_disk.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_grouping.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_h5codec.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_irls.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_kernels.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_memory.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_messages.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_preflight.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_provenance.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_size_factors.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/_statistics.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/batch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/dimred.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/hvg.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/profiling.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/residual.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx/sample.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx.egg-info/dependency_links.txt +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx.egg-info/requires.txt +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/src/crispyx.egg-info/top_level.txt +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_batch_process.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_cgroup_memory_budget.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_compare_controls.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_compress_h5ad.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_de_edge_cases.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_de_lowexpr_filter.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_de_resume.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_dimred.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_disk_dispatch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_downsample_counts.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_glm_structured.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_groupby_alias.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_hvg.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_in_memory_input.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_irls.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_memory_dispatch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_messages.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_normalisation.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_normalized_effects.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_normalized_effects_se.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_obs_writes.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_pickle.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_plotting.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_preflight_dispatch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_profiling.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_pseudobulk_batch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_pseudobulk_memory.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_pseudobulk_profiles.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_qc_parity.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_read_backed.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_residual_effects.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_result_provenance.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_scanpy_parity.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_standardize.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_subsample.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_temp_file_cleanup.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_wilcoxon_dispatch.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_wilcoxon_labels.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_wilcoxon_stratified.py +0 -0
- {crispyx-0.2.4 → crispyx-0.2.5}/tests/test_workflow.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crispyx
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Memory-efficient streaming analysis of large-scale CRISPR and Perturb-seq screens on disk-backed AnnData files
|
|
5
5
|
Author: Jin-Hong Du
|
|
6
6
|
License: Modified MIT License
|
|
@@ -145,7 +145,7 @@ Dynamic: license-file
|
|
|
145
145
|
|
|
146
146
|
Genome-wide CRISPR screens routinely produce datasets with hundreds of thousands of cells and tens of thousands of genes. Standard single-cell analysis toolkits (Scanpy, Pertpy) load the entire count matrix into memory, requiring large RAM allocations and often making routine workflows impractical on laptops or shared compute nodes.
|
|
147
147
|
|
|
148
|
-
**crispyx**
|
|
148
|
+
**crispyx** runs quality control, normalisation, pseudo-bulk aggregation, differential expression (t-test, Wilcoxon, NB-GLM with covariates, covariate-adjusted residual effects), control checks and PCA/KNN on screens stored as `.h5ad` files, streaming from disk under a memory budget, so that million-cell screens run on a laptop or a cluster node. The API mirrors Scanpy. It starts from an `.h5ad` file; it does not read raw sequencing outputs, and it is not a general single-cell toolkit.
|
|
149
149
|
|
|
150
150
|
**Documentation:** [crispyx.readthedocs.io](https://crispyx.readthedocs.io/en/latest/) — [installation](https://crispyx.readthedocs.io/en/latest/installation.html), [quick start](https://crispyx.readthedocs.io/en/latest/quickstart.html), [tutorials](https://crispyx.readthedocs.io/en/latest/notebooks/crispyx_tutorial.html) and [API reference](https://crispyx.readthedocs.io/en/latest/api.html).
|
|
151
151
|
|
|
@@ -202,18 +202,18 @@ For the full workflow (normalisation, PCA, pseudo-bulk, NB-GLM, LFC shrinkage, p
|
|
|
202
202
|
- **Streaming QC & preprocessing** – Filter cells, perturbations, and genes; normalise and log-transform; select highly variable genes (`seurat_v3`/`mean_dispersion`, control-cells-only by default); CSC-aware streaming with `format_mismatch_policy`; all without loading the full matrix into memory
|
|
203
203
|
- **Subsampling & downsampling** – Stratified or cluster-sampled cell subsampling (`cx.pp.subsample`, exact count or proportion per stratum, drop or keep small groups) and dependency-free per-cell count thinning (`cx.pp.downsample_counts`, the streaming equivalent of `scanpy.pp.downsample_counts`) for aligning dataset scale and sequencing depth before comparing screens
|
|
204
204
|
- **Pseudo-bulk aggregation** – Absolute profiles over multiple grouping columns (for example, perturbation × batch), strict count sums or mean log1p expression, optional deterministic bootstrap sampling, and explicit within-batch effect calculation
|
|
205
|
-
- **Differential expression** – t-test, Wilcoxon rank-sum (including batch-stratified / van Elteren test via `batch_column`),
|
|
205
|
+
- **Differential expression** – t-test, Wilcoxon rank-sum (including batch-stratified / van Elteren test via `batch_column`), negative binomial GLM with covariates and apeGLM LFC shrinkage, and a fixed-offset NB test for many small perturbations against a large, stratified control set (`cx.tl.nb_offset_test`); multi-core support and adaptive memory management; per-condition low-expression filtering to exclude genes that are near-zero in both groups
|
|
206
206
|
- **Covariate-adjusted effects** – `cx.tl.residual_effects` (Feng et al., 2026) fits each gene to covariates such as donor, lane or batch on the control cells only, and takes a perturbation's effect as the mean residual of its cells. Unlike the NB GLM, which fits the covariates on counts jointly with each perturbation, the control fit is shared by every perturbation, so a perturbation's own cells cannot shift its covariate adjustment, and all perturbations come from one streaming pass. On a 1.16-million-cell screen it reproduces the published effects and significance calls in under a minute.
|
|
207
207
|
- **Storage-format aware** – Gene-streaming functions (`wilcoxon_test`, `batch_process`) can convert a CSR source once to a temporary, memory-bounded CSC copy beside the output instead of re-reading the whole matrix once per gene chunk; `format_mismatch_policy="auto"` (the default) measures the source's read throughput and does so only when the re-reads would really cost more than the conversion, so a small local file is streamed as-is and a large one on a network filesystem is converted; `convert_to_csc`/`convert_to_csr` honour `memory_limit_gb` and preserve the value dtype
|
|
208
208
|
- **Dimension reduction** – Memory-efficient PCA and KNN graph construction on backed data
|
|
209
209
|
- **Scanpy-compatible API & plotting** – Familiar `cx.pp`, `cx.pb`, `cx.tl`, and `cx.pl` namespaces; Scanpy-style rank genes plots, volcano, MA, PCA, UMAP, QC summaries, and overlap heatmaps
|
|
210
|
-
- **Data preparation utilities** – Edit backed metadata without loading X;
|
|
210
|
+
- **Data preparation utilities** – Edit backed metadata without loading X; normalise perturbation labels and take target genes out of guide names (`target_pattern`); assign guides from guide-capture counts (`cx.pp.assign_guides`); recover integer counts from data published as log1p-normalised values (`cx.pp.recover_counts`); sum the rows of a gene split over several (`cx.pp.collapse_genes`); concatenate multi-file screens; check a file for the mistakes that mislead an analysis (`cx.pp.check_data`); auto-detect metadata columns
|
|
211
211
|
- **HPC-ready** – Resume/checkpoint for long-running jobs; configurable `memory_limit_gb`
|
|
212
212
|
- **Disk-aware** – Estimates and warns about scratch-disk usage before large writes or CSC/CSR conversions, and `cx.estimate_disk_usage(...)` answers "how much disk will this need?" up front; the memory savings above assume the machine has enough free disk for streaming intermediates and output files
|
|
213
213
|
|
|
214
214
|
## Performance
|
|
215
215
|
|
|
216
|
-
crispyx
|
|
216
|
+
Across 12 public CRISPR screens, crispyx completes every dataset where Scanpy, Pertpy/PyDESeq2 and edgeR run out of memory or time, with t-test and Wilcoxon results matching Scanpy to Pearson *r* > 0.999 and NB-GLM statistics agreeing with PyDESeq2 given the same size factors (z correlation 0.997–0.9999):
|
|
217
217
|
|
|
218
218
|
<p align="center">
|
|
219
219
|
<img src="docs/_static/fig2.png" width="800" alt="Benchmark results across 12 CRISPR screens: (a) dataset sizes, (b) completion status by method, (c) concordance with Scanpy, (d) runtime scaling, (e) peak memory scaling">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
Genome-wide CRISPR screens routinely produce datasets with hundreds of thousands of cells and tens of thousands of genes. Standard single-cell analysis toolkits (Scanpy, Pertpy) load the entire count matrix into memory, requiring large RAM allocations and often making routine workflows impractical on laptops or shared compute nodes.
|
|
13
13
|
|
|
14
|
-
**crispyx**
|
|
14
|
+
**crispyx** runs quality control, normalisation, pseudo-bulk aggregation, differential expression (t-test, Wilcoxon, NB-GLM with covariates, covariate-adjusted residual effects), control checks and PCA/KNN on screens stored as `.h5ad` files, streaming from disk under a memory budget, so that million-cell screens run on a laptop or a cluster node. The API mirrors Scanpy. It starts from an `.h5ad` file; it does not read raw sequencing outputs, and it is not a general single-cell toolkit.
|
|
15
15
|
|
|
16
16
|
**Documentation:** [crispyx.readthedocs.io](https://crispyx.readthedocs.io/en/latest/) — [installation](https://crispyx.readthedocs.io/en/latest/installation.html), [quick start](https://crispyx.readthedocs.io/en/latest/quickstart.html), [tutorials](https://crispyx.readthedocs.io/en/latest/notebooks/crispyx_tutorial.html) and [API reference](https://crispyx.readthedocs.io/en/latest/api.html).
|
|
17
17
|
|
|
@@ -68,18 +68,18 @@ For the full workflow (normalisation, PCA, pseudo-bulk, NB-GLM, LFC shrinkage, p
|
|
|
68
68
|
- **Streaming QC & preprocessing** – Filter cells, perturbations, and genes; normalise and log-transform; select highly variable genes (`seurat_v3`/`mean_dispersion`, control-cells-only by default); CSC-aware streaming with `format_mismatch_policy`; all without loading the full matrix into memory
|
|
69
69
|
- **Subsampling & downsampling** – Stratified or cluster-sampled cell subsampling (`cx.pp.subsample`, exact count or proportion per stratum, drop or keep small groups) and dependency-free per-cell count thinning (`cx.pp.downsample_counts`, the streaming equivalent of `scanpy.pp.downsample_counts`) for aligning dataset scale and sequencing depth before comparing screens
|
|
70
70
|
- **Pseudo-bulk aggregation** – Absolute profiles over multiple grouping columns (for example, perturbation × batch), strict count sums or mean log1p expression, optional deterministic bootstrap sampling, and explicit within-batch effect calculation
|
|
71
|
-
- **Differential expression** – t-test, Wilcoxon rank-sum (including batch-stratified / van Elteren test via `batch_column`),
|
|
71
|
+
- **Differential expression** – t-test, Wilcoxon rank-sum (including batch-stratified / van Elteren test via `batch_column`), negative binomial GLM with covariates and apeGLM LFC shrinkage, and a fixed-offset NB test for many small perturbations against a large, stratified control set (`cx.tl.nb_offset_test`); multi-core support and adaptive memory management; per-condition low-expression filtering to exclude genes that are near-zero in both groups
|
|
72
72
|
- **Covariate-adjusted effects** – `cx.tl.residual_effects` (Feng et al., 2026) fits each gene to covariates such as donor, lane or batch on the control cells only, and takes a perturbation's effect as the mean residual of its cells. Unlike the NB GLM, which fits the covariates on counts jointly with each perturbation, the control fit is shared by every perturbation, so a perturbation's own cells cannot shift its covariate adjustment, and all perturbations come from one streaming pass. On a 1.16-million-cell screen it reproduces the published effects and significance calls in under a minute.
|
|
73
73
|
- **Storage-format aware** – Gene-streaming functions (`wilcoxon_test`, `batch_process`) can convert a CSR source once to a temporary, memory-bounded CSC copy beside the output instead of re-reading the whole matrix once per gene chunk; `format_mismatch_policy="auto"` (the default) measures the source's read throughput and does so only when the re-reads would really cost more than the conversion, so a small local file is streamed as-is and a large one on a network filesystem is converted; `convert_to_csc`/`convert_to_csr` honour `memory_limit_gb` and preserve the value dtype
|
|
74
74
|
- **Dimension reduction** – Memory-efficient PCA and KNN graph construction on backed data
|
|
75
75
|
- **Scanpy-compatible API & plotting** – Familiar `cx.pp`, `cx.pb`, `cx.tl`, and `cx.pl` namespaces; Scanpy-style rank genes plots, volcano, MA, PCA, UMAP, QC summaries, and overlap heatmaps
|
|
76
|
-
- **Data preparation utilities** – Edit backed metadata without loading X;
|
|
76
|
+
- **Data preparation utilities** – Edit backed metadata without loading X; normalise perturbation labels and take target genes out of guide names (`target_pattern`); assign guides from guide-capture counts (`cx.pp.assign_guides`); recover integer counts from data published as log1p-normalised values (`cx.pp.recover_counts`); sum the rows of a gene split over several (`cx.pp.collapse_genes`); concatenate multi-file screens; check a file for the mistakes that mislead an analysis (`cx.pp.check_data`); auto-detect metadata columns
|
|
77
77
|
- **HPC-ready** – Resume/checkpoint for long-running jobs; configurable `memory_limit_gb`
|
|
78
78
|
- **Disk-aware** – Estimates and warns about scratch-disk usage before large writes or CSC/CSR conversions, and `cx.estimate_disk_usage(...)` answers "how much disk will this need?" up front; the memory savings above assume the machine has enough free disk for streaming intermediates and output files
|
|
79
79
|
|
|
80
80
|
## Performance
|
|
81
81
|
|
|
82
|
-
crispyx
|
|
82
|
+
Across 12 public CRISPR screens, crispyx completes every dataset where Scanpy, Pertpy/PyDESeq2 and edgeR run out of memory or time, with t-test and Wilcoxon results matching Scanpy to Pearson *r* > 0.999 and NB-GLM statistics agreeing with PyDESeq2 given the same size factors (z correlation 0.997–0.9999):
|
|
83
83
|
|
|
84
84
|
<p align="center">
|
|
85
85
|
<img src="docs/_static/fig2.png" width="800" alt="Benchmark results across 12 CRISPR screens: (a) dataset sizes, (b) completion status by method, (c) concordance with Scanpy, (d) runtime scaling, (e) peak memory scaling">
|
|
@@ -41,6 +41,8 @@ from .data import (
|
|
|
41
41
|
normalise_perturbation_labels,
|
|
42
42
|
read_h5ad_ondisk,
|
|
43
43
|
read_backed,
|
|
44
|
+
recover_counts,
|
|
45
|
+
collapse_genes,
|
|
44
46
|
resolve_data_path,
|
|
45
47
|
standardise_gene_names,
|
|
46
48
|
write_filtered_subset,
|
|
@@ -50,7 +52,10 @@ from .data import (
|
|
|
50
52
|
from .de import (
|
|
51
53
|
RankGenesGroupsResult,
|
|
52
54
|
nb_glm_test,
|
|
55
|
+
nb_offset_test,
|
|
53
56
|
shrink_lfc,
|
|
57
|
+
shrink_lfc_arrays,
|
|
58
|
+
ShrunkLFC,
|
|
54
59
|
t_test,
|
|
55
60
|
wilcoxon_test,
|
|
56
61
|
)
|
|
@@ -84,12 +89,16 @@ from .pseudobulk import (
|
|
|
84
89
|
compute_pseudobulk_effects,
|
|
85
90
|
)
|
|
86
91
|
from .qc import (
|
|
92
|
+
Issue,
|
|
93
|
+
assign_guides,
|
|
94
|
+
check_perturbation_data,
|
|
87
95
|
compare_controls,
|
|
88
96
|
control_guide_correlation,
|
|
89
97
|
filter_cells_by_gene_count,
|
|
90
98
|
filter_genes_by_cell_count,
|
|
91
99
|
filter_perturbations_by_cell_count,
|
|
92
100
|
quality_control_summary,
|
|
101
|
+
raise_on_errors,
|
|
93
102
|
)
|
|
94
103
|
from .residual import residual_effects
|
|
95
104
|
from .sample import subsample
|
|
@@ -128,6 +137,10 @@ __all__ = [
|
|
|
128
137
|
"quality_control_summary",
|
|
129
138
|
"compare_controls",
|
|
130
139
|
"control_guide_correlation",
|
|
140
|
+
"assign_guides",
|
|
141
|
+
"check_perturbation_data",
|
|
142
|
+
"Issue",
|
|
143
|
+
"raise_on_errors",
|
|
131
144
|
"plot_control_guide_correlation",
|
|
132
145
|
"highly_variable_genes",
|
|
133
146
|
# Subsampling
|
|
@@ -147,7 +160,10 @@ __all__ = [
|
|
|
147
160
|
"t_test",
|
|
148
161
|
"wilcoxon_test",
|
|
149
162
|
"nb_glm_test",
|
|
163
|
+
"nb_offset_test",
|
|
150
164
|
"shrink_lfc",
|
|
165
|
+
"shrink_lfc_arrays",
|
|
166
|
+
"ShrunkLFC",
|
|
151
167
|
# Data utilities
|
|
152
168
|
"AnnData",
|
|
153
169
|
"ensure_gene_symbol_column",
|
|
@@ -156,6 +172,8 @@ __all__ = [
|
|
|
156
172
|
"resolve_data_path",
|
|
157
173
|
"normalize_total_log1p",
|
|
158
174
|
"downsample_counts",
|
|
175
|
+
"recover_counts",
|
|
176
|
+
"collapse_genes",
|
|
159
177
|
"convert_to_csc",
|
|
160
178
|
"convert_to_csr",
|
|
161
179
|
"compress_h5ad",
|
|
@@ -19,6 +19,8 @@ from .data import (
|
|
|
19
19
|
convert_to_csr,
|
|
20
20
|
concat_h5ad,
|
|
21
21
|
downsample_counts,
|
|
22
|
+
recover_counts,
|
|
23
|
+
collapse_genes,
|
|
22
24
|
normalize_total_log1p,
|
|
23
25
|
read_backed,
|
|
24
26
|
resolve_data_path,
|
|
@@ -26,7 +28,9 @@ from .data import (
|
|
|
26
28
|
from .de import (
|
|
27
29
|
RankGenesGroupsResult,
|
|
28
30
|
nb_glm_test,
|
|
31
|
+
nb_offset_test,
|
|
29
32
|
shrink_lfc,
|
|
33
|
+
shrink_lfc_arrays,
|
|
30
34
|
t_test,
|
|
31
35
|
wilcoxon_test,
|
|
32
36
|
)
|
|
@@ -56,6 +60,8 @@ from .pseudobulk import (
|
|
|
56
60
|
)
|
|
57
61
|
from .residual import ResidualNull, residual_effects
|
|
58
62
|
from .qc import (
|
|
63
|
+
assign_guides,
|
|
64
|
+
check_perturbation_data,
|
|
59
65
|
compare_controls,
|
|
60
66
|
control_guide_correlation,
|
|
61
67
|
filter_cells_by_gene_count,
|
|
@@ -210,6 +216,21 @@ class _PreprocessingNamespace:
|
|
|
210
216
|
"""
|
|
211
217
|
return control_guide_correlation(data, **kwargs)
|
|
212
218
|
|
|
219
|
+
def assign_guides(self, guide_counts, guide_names=None, **kwargs):
|
|
220
|
+
"""The guide that dominates each cell's guide-capture counts, or NA.
|
|
221
|
+
|
|
222
|
+
See :func:`crispyx.qc.assign_guides`.
|
|
223
|
+
"""
|
|
224
|
+
return assign_guides(guide_counts, guide_names, **kwargs)
|
|
225
|
+
|
|
226
|
+
def check_data(self, data, **kwargs):
|
|
227
|
+
"""Check a screen's file for labels, genes and counts that would
|
|
228
|
+
mislead an analysis.
|
|
229
|
+
|
|
230
|
+
See :func:`crispyx.qc.check_perturbation_data`.
|
|
231
|
+
"""
|
|
232
|
+
return check_perturbation_data(data, **kwargs)
|
|
233
|
+
|
|
213
234
|
def convert_to_csc(
|
|
214
235
|
self,
|
|
215
236
|
data: str | Path | ad.AnnData,
|
|
@@ -392,6 +413,60 @@ class _PreprocessingNamespace:
|
|
|
392
413
|
verbose=verbose,
|
|
393
414
|
)
|
|
394
415
|
|
|
416
|
+
def recover_counts(
|
|
417
|
+
self,
|
|
418
|
+
data: str | Path | ad.AnnData,
|
|
419
|
+
output_path: str | Path | None = None,
|
|
420
|
+
*,
|
|
421
|
+
n_counts_column: str | None = None,
|
|
422
|
+
chunk_size: int = 4096,
|
|
423
|
+
data_name: str | None = None,
|
|
424
|
+
format_mismatch_policy: Literal["auto", "warn", "convert", "off"] = "auto",
|
|
425
|
+
verbose: int | bool = True,
|
|
426
|
+
) -> AnnData:
|
|
427
|
+
"""Recover the integer counts behind a ``log1p(normalize_total(counts))``
|
|
428
|
+
matrix, streamed.
|
|
429
|
+
|
|
430
|
+
See :func:`crispyx.data.recover_counts` for the full parameter
|
|
431
|
+
documentation.
|
|
432
|
+
"""
|
|
433
|
+
return recover_counts(
|
|
434
|
+
data,
|
|
435
|
+
output_path,
|
|
436
|
+
n_counts_column=n_counts_column,
|
|
437
|
+
chunk_size=chunk_size,
|
|
438
|
+
data_name=data_name,
|
|
439
|
+
format_mismatch_policy=format_mismatch_policy,
|
|
440
|
+
verbose=verbose,
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
def collapse_genes(
|
|
444
|
+
self,
|
|
445
|
+
data: str | Path | ad.AnnData,
|
|
446
|
+
output_path: str | Path | None = None,
|
|
447
|
+
*,
|
|
448
|
+
by: "str | pd.Series | Sequence",
|
|
449
|
+
chunk_size: int = 4096,
|
|
450
|
+
data_name: str | None = None,
|
|
451
|
+
format_mismatch_policy: Literal["auto", "warn", "convert", "off"] = "auto",
|
|
452
|
+
verbose: int | bool = True,
|
|
453
|
+
) -> AnnData:
|
|
454
|
+
"""Sum the rows of ``var`` that are one gene, under a caller-supplied
|
|
455
|
+
key, streamed.
|
|
456
|
+
|
|
457
|
+
See :func:`crispyx.data.collapse_genes` for the full parameter
|
|
458
|
+
documentation.
|
|
459
|
+
"""
|
|
460
|
+
return collapse_genes(
|
|
461
|
+
data,
|
|
462
|
+
output_path,
|
|
463
|
+
by=by,
|
|
464
|
+
chunk_size=chunk_size,
|
|
465
|
+
data_name=data_name,
|
|
466
|
+
format_mismatch_policy=format_mismatch_policy,
|
|
467
|
+
verbose=verbose,
|
|
468
|
+
)
|
|
469
|
+
|
|
395
470
|
def concat_h5ad(
|
|
396
471
|
self,
|
|
397
472
|
paths: Sequence[str | Path],
|
|
@@ -990,6 +1065,21 @@ class _ToolsNamespace:
|
|
|
990
1065
|
"Choose from 'wilcoxon', 't-test', or 'nb_glm'."
|
|
991
1066
|
)
|
|
992
1067
|
|
|
1068
|
+
def nb_offset_test(self, data: str | Path | ad.AnnData, **kwargs):
|
|
1069
|
+
"""Negative binomial test of each perturbation on its own cells, with
|
|
1070
|
+
the controls as a fixed per-stratum baseline.
|
|
1071
|
+
|
|
1072
|
+
See :func:`crispyx.de.nb_offset_test`.
|
|
1073
|
+
"""
|
|
1074
|
+
return nb_offset_test(data, **kwargs)
|
|
1075
|
+
|
|
1076
|
+
def shrink_lfc_arrays(self, lfc, se, *, prior_scale=None, exclude=None, floor=None):
|
|
1077
|
+
"""apeGLM shrinkage of fold changes given as arrays, exactly.
|
|
1078
|
+
|
|
1079
|
+
See :func:`crispyx.de.shrink_lfc_arrays`.
|
|
1080
|
+
"""
|
|
1081
|
+
return shrink_lfc_arrays(lfc, se, prior_scale=prior_scale, exclude=exclude, floor=floor)
|
|
1082
|
+
|
|
993
1083
|
def shrink_lfc(
|
|
994
1084
|
self,
|
|
995
1085
|
data: str | Path | ad.AnnData,
|