Skip to main content

Documentation Status PyPI PyPI-Downloads

causarray

Advances in single-cell sequencing and CRISPR technologies have enabled detailed case-control comparisons and experimental perturbations at single-cell resolution. However, uncovering causal relationships in observational genomic data remains challenging due to selection bias and inadequate adjustment for unmeasured confounders, particularly in heterogeneous datasets. To address these challenges, we introduce causarray [Du26], a doubly robust causal inference framework for analyzing array-based genomic data at both bulk-cell and single-cell levels. causarray integrates a generalized confounder adjustment method to account for unmeasured confounders and employs semiparametric inference with flexible machine learning techniques to ensure robust statistical estimation of treatment effects.

Usage

We recommend using causarray in a conda environment:

# create a new conda environment and install the necessary packages
conda create -n causarray python=3.12 -y

# activate the environment
conda activate causarray

The module can be installed via PyPI:

pip install causarray

For optimal parallel performance, we recommend installing llvm-openmp if using conda:

conda install -c conda-forge llvm-openmp

For R users, reticulate can be used to call causarray from R while keeping NumPy >2 in the Python environment. Create the separate R environment with a current NumPy-2-compatible reticulate build:

conda env create -f environment-r.yaml

The R tutorial runs from causarray-r and connects to the Python package in the causarray environment. The documentation and tutorials using both Python and R are available at causarray.readthedocs.io.

Tutorials

Tutorial Language Description Link
Perturb-seq [Jin20] Python CRISPR screen analysis on excitatory neurons Notebook
Perturb-seq [Jin20] R Same analysis using reticulate Notebook
Genome-wide CRISPRi screen [Replogle22] Python Batch fitting on 200 perturbations from a K562 genome-wide CRISPRi screen Notebook
Case-control: SEA-AD [Gabitto24] Python Causal inference on observational single-cell data (Alzheimer's disease) Notebook

Batch fitting API

For screens with hundreds to thousands of perturbations, use gcate_lfc_batch so that peak memory is bounded by one batch at a time:

from causarray import gcate_lfc_batch

df_res = gcate_lfc_batch(
    Y, X, A, r,
    batch_size=10,    # perturbations per batch (or use n_batches= for a fixed count)
    max_cells=2000,   # max pert cells per batch (ctrl added on top)
    n_ctrl=2000,      # fixed ctrl subsample shared across batches
    cache_path='results.h5',   # resume if interrupted
    verbose=True,
)

See the Replogle-E-K562 tutorial for a demonstration on 200 perturbations from a genome-wide CRISPRi screen.

Diagnostic masks without refitting effects

Treatment-by-gene support or quality-control rules can be aligned to an existing causarray result table by label, even when its rows are reordered:

from causarray import align_test_mask

keep = align_test_mask(
    df_res,
    support_mask,                 # treatments × genes, Boolean
    treatment_names=perturbations,
    gene_names=genes,
)
df_res_flagged = df_res.assign(support_keep=keep)

This operation only annotates or subsets existing results. It does not refit the causarray LFC or change standard errors and p-values. If a diagnostic rule was selected after inspecting the outcomes, retain the original adjusted p-values rather than redefining the multiple-testing family post hoc. The Replogle tutorial compares several expression-support rules with marginal Wilcoxon results.

Changelog

See CHANGELOG for a full version history.

References

[Du26] Jin-Hong Du, Maya Shen, Hansruedi Mathys, and Kathryn Roeder. "Uncovering causal relationships in single cell omic studies with causarray". In: Briefings in Bioinformatics (2026).

[Gabitto24] Mariano I. Gabitto et al. "Integrated multimodal cell atlas of Alzheimer's disease". In: Nature Neuroscience (2024).

[Jin20] Xin Jin et al. "In vivo Perturb-seq reveals neuronal and glial abnormalities associated with autism risk genes". In: Nature Neuroscience (2020).

[Replogle22] Joseph M. Replogle et al. "Mapping information-rich genotype-phenotype landscapes with genome-scale Perturb-seq". In: Cell (2022).

Metadata

Release files for causarray 0.1.0

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

Source distribution (sdist)

Source distribution for causarray 0.1.0
File Size Uploaded
causarray-0.1.0.tar.gz 70.5 kB Details

Built distribution (wheel)

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

Total release size: 146.4 kB

Release files / causarray-0.1.0.tar.gz

Download URL causarray-0.1.0.tar.gz
Size 70.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0e1456ed59b7f79db5e7a73f57eb69440de1d705eed4e5632d995346db9968db
BLAKE2b-256 checksum
How to use checksums
b0fdb9a9fcd09773e401a7939fc4e9b653cc73b81ed69d8507f60e45e49b0765
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 23, 2026.

Transparency log

Release files / causarray-0.1.0-py3-none-any.whl

Download URL causarray-0.1.0-py3-none-any.whl
Size 75.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca8569ca42d77a8a812fa9ea1c2821f41a649efd545ffb65013ab4cfd04739b8
BLAKE2b-256 checksum
How to use checksums
9db790d994d09fcb5545189a515f511ff9fac8511231e6edf1fce8c026d0949b
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 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

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