Skip to main content

py-spacetrooper

PyPI version Python versions License: MIT PyPI downloads

Python port of SpaceTrooper — Quality Control for image-based spatial transcriptomics data.

Parity: Pearson r = 0.989 vs R | Speed: 102× faster

Install

pip install py-spacetrooper

Quickstart

import anndata as ad
from spacetrooper import SpaceTrooper

# Load your spatial data
adata = ad.read_h5ad("your_data.h5ad")

# Run QC pipeline
st = SpaceTrooper(adata)
st.spatial_per_cell_qc()
st.compute_qc_score()

# Access results
print(st.adata.obs["QC_score"])  # QC scores (0-1)

Functional API

from spacetrooper import (
    spatial_per_cell_qc,
    compute_outliers_qc_score,
    check_outliers,
    compute_qc_score,
)

spatial_per_cell_qc(adata)
compute_outliers_qc_score(adata)
check_outliers(adata)
compute_qc_score(adata)

Supported platforms

Platform Function Description
Nanostring CosMx read_cosmx_spe Transcriptomics + Proteomics
Vizgen MERFISH read_merfish_spe MERFISH / Merscope
10x Xenium read_xenium_spe Xenium output bundle

What's included

Python function R equivalent Description
spatial_per_cell_qc spatialPerCellQC Per-cell QC metrics
compute_spatial_outlier computeSpatialOutlier Outlier detection (medcouple/MAD)
compute_outliers_qc_score computeOutliersQCScore Outlier labels for QC formula
check_outliers checkOutliers Validate outlier counts
compute_qc_score computeQCScore Ridge logistic regression QC score
compute_threshold_flags computeThresholdFlags Fixed threshold flags
read_cosmx_spe readCosmxSPE Read CosMx data
read_merfish_spe readMerfishSPE Read MERFISH data
read_xenium_spe readXeniumSPE Read Xenium data
read_polygons readPolygons Read polygon boundaries
plot_metric_hist plotMetricHist Metric histogram
plot_centroids plotCentroids Spatial scatter plot

Parity with R

Metric Value Threshold
QC_score Pearson r 0.989 ≥ 0.90
Intermediate metrics < 1e-13 < 1e-8
Wall-clock speed 102× faster —

Citation

@article{righelli2024spacetrooper,
  title={SpaceTrooper: Quality Control for image-based spatial transcriptomics},
  author={Righelli, Dario and Banzi, Benedetta and Marchionni, Matteo and others},
  year={2024},
  journal={Bioinformatics}
}

License

MIT (matches upstream SpaceTrooper)

Metadata

Release files for py-spacetrooper 0.1.1

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

Source distribution (sdist)

Source distribution for py-spacetrooper 0.1.1
File Size Uploaded Provenance Actions
py_spacetrooper-0.1.1.tar.gz 24.3 kB Without provenance Details for py_spacetrooper-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-spacetrooper 0.1.1
File Interpreter ABI Platform Actions
py_spacetrooper-0.1.1-py3-none-any.whl Python 3 none any Details for py_spacetrooper-0.1.1-py3-none-any.whl

Total release size: 49.9 kB

Release files / py_spacetrooper-0.1.1.tar.gz

Download URL py_spacetrooper-0.1.1.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7491593a7cca6cf7399bd9d6ed0512944fc95cddbf73b642091de94369726c58
BLAKE2b-256 checksum
How to use checksums
9c401e35eb1a96b606deabd1b827a98575c95d012400a98ba2e7a3f3c685853b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / py_spacetrooper-0.1.1-py3-none-any.whl

Download URL py_spacetrooper-0.1.1-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57b41df059b1801ececcb8199cc97108fa2187fae98c7f0662fd2d530c7d500b
BLAKE2b-256 checksum
How to use checksums
88915e54548dfe9e33e5265f2acc8d657bf8c1da2a611b1a2876e24a20522396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Security for py-spacetrooper 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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