py-SpotSweeper
Spatially-aware quality control for spatial transcriptomics.
Python port of R/Bioconductor package SpotSweeper v1.5.0.
Install
pip install spotsweeper
Quick start
import anndata as ad
from spotsweeper import local_variance, local_outliers, find_artifacts, flag_visium_outliers
# Load your spatial data as AnnData with adata.obsm['spatial']
adata = ad.read_h5ad("your_data.h5ad")
# 1. Compute local variance of mitochondrial percentage
adata = local_variance(adata, metric="subsets_Mito_percent", n_neighbors=36)
# 2. Detect local outliers in library size
adata = local_outliers(adata, metric="sum", direction="lower", log=True)
# 3. Flag systematic Visium outliers
adata = flag_visium_outliers(adata)
# 4. Find artifacts (single sample only)
adata = find_artifacts(adata, mito_percent="subsets_Mito_percent", n_order=5)
Functions
| Function | Description |
|---|---|
local_variance() |
Local variance of QC metrics using kNN + robust regression |
local_outliers() |
Outlier detection using MAD-based modified z-scores |
find_artifacts() |
Artifact detection via multi-scale variance + PCA + k-means |
flag_visium_outliers() |
Flag known systematic Visium outlier spots |
plot_qc_metrics() |
Spatial scatter plot of QC metrics |
plot_qc_pdf() |
Multi-page PDF of QC plots per sample |
Speed vs R
| Function | R | Python | Speedup |
|---|---|---|---|
| localVariance | 8.9s | 0.5s | 19x |
| localOutliers | 1.3s | 0.2s | 8x |
| findArtifacts | 16s | 5.5s | 3x |
| flagVisiumOutliers | 0.05s | 0.003s | 14x |
Parity
All functions pass parity gates against R reference outputs:
| Function | Metric | Value | Gate |
|---|---|---|---|
| localVariance | max abs err | 2.67e-6 | 1e-5 |
| localOutliers | F1 | 1.0 | 0.95 |
| findArtifacts | ARI | 1.0 | 0.95 |
| flagVisiumOutliers | exact match | 1.0 | 1.0 |
Requirements
- Python >= 3.9
- numpy, scipy, pandas, anndata, scikit-learn, matplotlib
License
MIT
References
Totty et al. (2025) "SpotSweeper: spatially-aware quality control for spatial transcriptomics." Bioconductor.
Metadata
Release files for py-spotsweeper 0.1.0
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 |
|---|---|---|---|---|
| py_spotsweeper-0.1.0.tar.gz | 11.8 kB | Without provenance | Details for py_spotsweeper-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_spotsweeper-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_spotsweeper-0.1.0-py3-none-any.whl |
Total release size: 23.5 kB
Release files / py_spotsweeper-0.1.0.tar.gz
| Download URL | py_spotsweeper-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a585547097a06ca3377e5a1f8129100e3629df62af3341060fa674d098bcd931
|
|
BLAKE2b-256 checksum How to use checksums |
0b00cb824ae10995d88398b746c71fff1f9348c3e11a764a3596aef38b60d009
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / py_spotsweeper-0.1.0-py3-none-any.whl
| Download URL | py_spotsweeper-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc611943db5e37336d20cc1cd1451a1c6dddc66bc3836c1b6b54869c69513778
|
|
BLAKE2b-256 checksum How to use checksums |
8714fa9f5d1f43fc97e4e0eb968a78b7f73cb10b140fe7a340f713d64c897ad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for py-spotsweeper 0.1.0
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.