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; 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
  • 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
  • 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
  • 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
  • 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
  • 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:

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

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.

Metadata

Release files for crispyx 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crispyx 0.1.3
File Size Uploaded
crispyx-0.1.3.tar.gz 373.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crispyx 0.1.3
File Interpreter ABI Platform
crispyx-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 655.3 kB

Release files / crispyx-0.1.3.tar.gz

Download URL crispyx-0.1.3.tar.gz
Size 373.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e83380d0bf0dc0c59f5b97d4c51b5f3536891afc3ad7b1df4d0ca93aaf603ef
BLAKE2b-256 checksum
How to use checksums
18c3452e87264b8df35f19644e3128e95471e601f50491aed52d9ea159f2b800
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / crispyx-0.1.3-py3-none-any.whl

Download URL crispyx-0.1.3-py3-none-any.whl
Size 282.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed7446164e96ffe3220f2c718020764b51a85a38b226fc688347892a1fc6274f
BLAKE2b-256 checksum
How to use checksums
df74e68413efdc47075eba937f85c2c2d2f7dda69c9e772efe0642222bab6203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release 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