crispyx
Motivation
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.
crispyx solves this by streaming data directly from on-disk AnnData (.h5ad) files. Quality control, normalisation, pseudo-bulk aggregation, and differential expression all operate without materialising the full matrix.
Features
- 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 withformat_mismatch_policy; all without loading the full matrix into memory - 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 ofscanpy.pp.downsample_counts) for aligning dataset scale and sequencing depth before comparing screens - 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
- Differential expression – t-test, Wilcoxon rank-sum (including batch-stratified / van Elteren test via
batch_column), and negative binomial GLM with apeGLM LFC shrinkage; multi-core support and adaptive memory management; per-condition low-expression filtering to exclude genes that are near-zero in both groups - Dimension reduction – Memory-efficient PCA and KNN graph construction on backed data
- Scanpy-compatible API & plotting – Familiar
cx.pp,cx.pb,cx.tl, andcx.plnamespaces; Scanpy-style rank genes plots, volcano, MA, PCA, UMAP, QC summaries, and overlap heatmaps - Data preparation utilities – Edit backed metadata without loading X; standardise gene names; normalise perturbation labels; auto-detect metadata columns
- HPC-ready – Resume/checkpoint for long-running jobs; configurable
memory_limit_gb - 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
Quick Start
import crispyx as cx
# Open dataset without loading into memory
adata = cx.read_h5ad_ondisk("data/demo_benchmark.h5ad")
# Quality control with adaptive thresholds
adata = cx.pp.qc_summary(
adata,
perturbation_column="perturbation",
min_genes=5,
min_cells_per_perturbation=5,
)
# Differential expression
adata = cx.tl.rank_genes_groups(
adata,
perturbation_column="perturbation",
method="wilcoxon", # or "t-test", "nb_glm"
)
# Access results
print(adata.uns["rank_genes_groups"])
de_results = adata.uns["rank_genes_groups"].load()
For the full workflow (normalisation, PCA, pseudo-bulk, NB-GLM, LFC shrinkage, plotting, data preparation utilities), see the Usage Guide and the tutorial notebook.
Performance
crispyx consistently outperforms Scanpy, Pertpy/PyDESeq2, and edgeR in both speed and memory across a range of CRISPR screen dataset sizes, with results matching Scanpy to Pearson r > 0.999:
Installation
pip install crispyx
For development (editable install with all extras):
git clone https://github.com/jinhongdu-lab/crispyx.git
cd crispyx
pip install -e ".[test,benchmark,docs]"
crispyx supports Python 3.10–3.12 and is compatible with recent releases of the
scientific stack, including anndata >= 0.13 and pandas >= 3.0 (where string
metadata is stored on disk using the nullable-string encoding).
Testing
pytest
Documentation
sphinx-build docs docs/_build
Acknowledgements
crispyx builds on the foundational work of Scanpy (Wolf et al., 2018), Pertpy, PyDESeq2 (Muzellec et al., 2023), and AnnData (Virshup et al., 2024). We gratefully acknowledge these projects for establishing the single-cell analysis ecosystem in Python; crispyx extends their APIs and algorithmic designs to enable memory-efficient, streaming computation for large-scale CRISPR screen datasets.
Contributing
Suggestions, bug reports, and contributions are welcome! Please open an issue or submit a pull request.
License
crispyx is released under a Modified MIT License. If you use crispyx in research, please cite it — see CITATION.cff.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crispyx-0.1.2.tar.gz.
File metadata
- Download URL: crispyx-0.1.2.tar.gz
- Upload date:
- Size: 349.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ca0e37637ad11045284cf19db586f8eb122b372eb12b4d653689d7fe9253ad
|
|
| MD5 |
9ccbe9750d727c0feb8952dd0d7749ec
|
|
| BLAKE2b-256 |
9c33ba312611aa23a79403d2a947ed2136e523e18a411fb015f974d73a165d38
|
Provenance
The following attestation bundles were made for crispyx-0.1.2.tar.gz:
Publisher:
publish.yml on JinHongDu-Lab/crispyx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crispyx-0.1.2.tar.gz -
Subject digest:
15ca0e37637ad11045284cf19db586f8eb122b372eb12b4d653689d7fe9253ad - Sigstore transparency entry: 2582739799
- Sigstore integration time:
-
Permalink:
JinHongDu-Lab/crispyx@60107884185afa361949a4705ed405d8d9575fdb -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/JinHongDu-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@60107884185afa361949a4705ed405d8d9575fdb -
Trigger Event:
release
-
Statement type:
File details
Details for the file crispyx-0.1.2-py3-none-any.whl.
File metadata
- Download URL: crispyx-0.1.2-py3-none-any.whl
- Upload date:
- Size: 268.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da4a2d65ecc680da5c6ff0d29ae11a8762dd044f56adc801a914e586bbc9824d
|
|
| MD5 |
d884cc5132d43cffa471d86fd283c667
|
|
| BLAKE2b-256 |
7d6fa15b4e9ba7e2fbeca712049455cabdf4f24027dae8b59c404b0453d3d577
|
Provenance
The following attestation bundles were made for crispyx-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on JinHongDu-Lab/crispyx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crispyx-0.1.2-py3-none-any.whl -
Subject digest:
da4a2d65ecc680da5c6ff0d29ae11a8762dd044f56adc801a914e586bbc9824d - Sigstore transparency entry: 2582739804
- Sigstore integration time:
-
Permalink:
JinHongDu-Lab/crispyx@60107884185afa361949a4705ed405d8d9575fdb -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/JinHongDu-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@60107884185afa361949a4705ed405d8d9575fdb -
Trigger Event:
release
-
Statement type: