SpatialPerturb
SpatialPerturb is an AnnData-native framework for spatial perturbation inference across sequencing-based and imaging-based platforms.
It now ships a benchmark-oriented workflow built around:
- a stable
AnnDataschema, fetch -> prepare -> loadpublic dataset lifecycle helpers,- intrinsic and neighborhood differential effects with
simpleandpseudobulkmodes, - ligand-receptor differential scoring with fixed fallback or custom LR resources,
- perturbation-program and cross-platform concordance metrics,
- paper-style figure rendering and report manifests.
Install
pip install SpatialPerturb
For heavier ecosystem interop:
pip install "SpatialPerturb[interop]"
Quick start
import spatialperturb as sp
adata = sp.load_demo_dataset()
intrinsic = sp.intrinsic_de(
adata,
perturbation="Lrrk2",
control="control",
method="pseudobulk",
sample_col="sample",
cell_type="neuron",
roi="hippocampus",
)
neighbor = sp.neighbor_de(
adata,
perturbation="Lrrk2",
control="control",
method="pseudobulk",
sample_col="sample",
aggregate="pseudobulk",
cell_type="neuron",
roi="hippocampus",
)
lr = sp.differential_lr(adata, perturbation="Lrrk2", control="control", lr_network="fallback")
power = sp.power_curve(adata, perturbation="Lrrk2", control="control", method="pseudobulk", sample_col="sample")
programs = sp.derive_perturbation_programs(intrinsic, top_n=10, direction="both")
Public dataset lifecycle
import spatialperturb as sp
sp.available_datasets()
sp.fetch_dataset("shen_2026_scrnaseq", cache_dir=".spatialperturb-cache")
sp.prepare_dataset("shen_2026_scrnaseq", cache_dir=".spatialperturb-cache")
adata = sp.load_public_dataset("shen_2026_scrnaseq", cache_dir=".spatialperturb-cache")
Registered public tracks:
shen_2026_stereoseq->GSE274447shen_2026_scrnaseq->GSE274058demo_spatialperturb-> deterministic paired demo data
Notes:
shen_2026_scrnaseqsupports automatic fetch and preparation from the GEO raw archive.shen_2026_stereoseqsupports automatic fetch and extraction, but final preparation still requires a preconverted.h5ador tabular export from the raw GEF files.
Paper-grade benchmark workflow
import spatialperturb as sp
results = sp.run_core_benchmark(
"demo_spatialperturb",
config={
"cache_dir": ".spatialperturb-cache",
"reference_dataset": "demo_spatialperturb",
"method": "pseudobulk",
"sample_col": "sample",
"concordance_level": "both",
},
output_dir="reports/demo_spatialperturb",
)
This writes:
- tidy tables under
reports/.../tables/ - fixed paper figures under
reports/.../figures/ - a machine-readable
manifest.json - the exact
input.h5adused for the run
CLI
spatialperturb datasets
spatialperturb fetch-dataset shen_2026_scrnaseq
spatialperturb prepare-dataset shen_2026_scrnaseq
spatialperturb run-benchmark demo_spatialperturb --output-dir reports/demo
spatialperturb render-paper-figures demo_spatialperturb --output-dir reports/demo-figs
spatialperturb validate path/to/data.h5ad
Package layout
spatialperturb.io: AnnData ingestion helpers.spatialperturb.pp: perturbation assignment and QC.spatialperturb.gr: spatial graph construction and neighbor collection.spatialperturb.tl: intrinsic DE, neighbor DE, ligand-receptor scoring, concordance, and power.spatialperturb.pl: plotting helpers for benchmark figures.spatialperturb.signatures: perturbation program derivation and scoring.spatialperturb.datasets: dataset registry plus publicfetch/prepare/load.spatialperturb.benchmarks: benchmark orchestration and report manifests.spatialperturb.reports: fixed paper figure rendering.
Development
python -m pip install --upgrade build pytest twine
python -m build
pytest -q
Citation
Please cite the package if you find it useful. See CITATION.cff.
Metadata
Release files for SpatialPerturb 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spatialperturb-0.3.1.tar.gz | 48.6 kB | Without provenance | Details for spatialperturb-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spatialperturb-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for spatialperturb-0.3.1-py3-none-any.whl |
Total release size: 97.3 kB
Release files / spatialperturb-0.3.1.tar.gz
| Download URL | spatialperturb-0.3.1.tar.gz |
|---|---|
| Size | 48.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8bc53cac3188ff0af1ff833139da4cc7f192259d4a43d9f92b9f5fd14025aca
|
|
BLAKE2b-256 checksum How to use checksums |
b06e14023aebffd5051b159ceabee970d11d9333bf131def00370b1fca0ccea3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / spatialperturb-0.3.1-py3-none-any.whl
| Download URL | spatialperturb-0.3.1-py3-none-any.whl |
|---|---|
| Size | 48.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eaf9a847b1450300b4492d1b04dad20c7c1340dde1ee74f95ca9f4be6b5a089
|
|
BLAKE2b-256 checksum How to use checksums |
c7aae20ec2f50f00ff7047582ef3fdac50190d38a0e388111320ca83ed2353e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for SpatialPerturb 0.3.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.