Skip to main content

crispyx

License: Modified MIT Python 3.10+ PyPI PyPI Downloads Tests

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; CSC-aware streaming with format_mismatch_policy; all without loading the full matrix into memory
  • 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, and cx.pl namespaces; 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; Docker and Singularity support
  • 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

Benchmarked across 12 CRISPR screen datasets (21k–1.97M cells), crispyx (v0.0.1) consistently outperforms Scanpy, Pertpy/PyDESeq2, and edgeR in both speed and memory:

Metric crispyx vs Scanpy crispyx vs Pertpy/PyDESeq2
t-test 1.6–3.9× faster (median 2.5×)
Wilcoxon 5–43× faster (median 8.5×)
NB-GLM 1.6–3.6× faster (median 2.0×)
Peak memory 2–59× lower for t-test (median 6×); comparable for Wilcoxon 1.4–10× lower (median 2.5×)
Accuracy (effect sizes) Pearson r > 0.999 Pearson r > 0.97

Speed and memory ratios are computed only over runs where both tools completed, so they exclude the largest screens — precisely the cases where crispyx's advantage is greatest.

crispyx completed all 89 runs across all 12 datasets. Pertpy/PyDESeq2 completed on 4 of 12 datasets and edgeR on none, both failing by timeout or memory limit. Scanpy completed at least one task on every dataset, but timed out or exceeded the memory cap on 12 of its 36 runs.

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

See benchmarking/ for full results and reproduction scripts.

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).

Benchmarking

cd benchmarking
./run_benchmark.sh config/Adamson.yaml       # single dataset
./run_benchmark.sh config/*.yaml             # all datasets

See benchmarking/README.md for configuration options and output structure.

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 0.0.9 and later is released under a Modified MIT License — every MIT freedom, with no fee or royalty, plus two attribution conditions that apply to commercial use. See the LICENSE for the terms. crispyx 0.0.8 and earlier remains under the unmodified 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

crispyx-0.0.10.tar.gz (320.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crispyx-0.0.10-py3-none-any.whl (247.6 kB view details)

Uploaded Python 3

File details

Details for the file crispyx-0.0.10.tar.gz.

File metadata

  • Download URL: crispyx-0.0.10.tar.gz
  • Upload date:
  • Size: 320.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for crispyx-0.0.10.tar.gz
Algorithm Hash digest
SHA256 0e3cf674e364d8020d9a6038e9b1f7f2d2c416422a566b57a5ca451d3a84aa51
MD5 f18921295e72d068bd627df0ec350810
BLAKE2b-256 3fec5d4f4eb619f9dd0188643bebc61cda1fab8be5c9d20ffef678d56ed22cd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for crispyx-0.0.10.tar.gz:

Publisher: publish.yml on JinHongDu-Lab/crispyx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crispyx-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: crispyx-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 247.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for crispyx-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c7b1603e0d95f6c2b74f12d6d55c24b2bf8f9b37ac2bff0fb01be82133d9386a
MD5 7af16a5e68fd8033607d4d445aeb9a3f
BLAKE2b-256 9d02d716c15cad94e6bf468fa2c4a4d656eb8b5cec3141093bb1fbfcd309447e

See more details on using hashes here.

Provenance

The following attestation bundles were made for crispyx-0.0.10-py3-none-any.whl:

Publisher: publish.yml on JinHongDu-Lab/crispyx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

This release

0.0.10 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page