AnnData-native framework for spatial perturbation inference across sequencing-based and imaging-based platforms.
Project description
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.
Project details
Release history Release notifications | RSS feed
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 spatialperturb-0.3.0.tar.gz.
File metadata
- Download URL: spatialperturb-0.3.0.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a467aa196ede03a85f1a248b2d8f49252c6ffd7a152586d24fc14c15a95523e
|
|
| MD5 |
e734e9c9f6133aa0568a42be9d7ce6c7
|
|
| BLAKE2b-256 |
568009150596f024f469d4fd4eb6b5d1111b09491fc58278e221a1cb49d5e0e4
|
File details
Details for the file spatialperturb-0.3.0-py3-none-any.whl.
File metadata
- Download URL: spatialperturb-0.3.0-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96fbfd08478d0b1c70fb04ffb8ecf35d9f7cc13632d670670eeecd071cf06b4e
|
|
| MD5 |
d953cca801eb4fb773db48e88547a95a
|
|
| BLAKE2b-256 |
dafeeb0b58f436b62b6995ee9f99b39ae8f0c84e79f4a9c5f10bafc0ea104706
|