spoQC
spoQC is a modular framework for multimodal quality control (QC) of imaging-based spatially resolved transcriptomics (SRT). It independently evaluates cell segmentation, imaging, and transcript data to identify high-quality regions (HQRs) across entire tissue sections. In addition, spoQC uses Markov random fields (MRFs) to incorporate spatial dependencies and generate spatially refined QC masks.
[!NOTE] SpoQC is currently under active development and is still in the alpha phase. You may encounter bugs, incomplete features, or unexpected behavior. If you are testing spoQC and run into any issues, please contact the development team or open an issue in the repository. Feedback, bug reports, and pull requests are highly appreciated and help us improve the project.
[!NOTE] Processing a full-resolution spatial transcriptomics (SRT) dataset with spoQC typically requires access to an HPC (High Performance Computing) environment. For smaller datasets, reduced-resolution data, or data subsets, it may be possible to run spoQC locally.
To reduce runtime and improve scalability, we recommend running spoQC with Nextflow. We are continuously working on improving performance and making local execution easier.
Supported Spatial Transcriptomics Technologies
Currently supported:
- 10x Xenium
[!NOTE] Atera support is currently under development and is not yet available.
Cite
If you use spoQC in your work, please cite:
Citation information will be provided soon.
Collaborators
This tool was developed in collaboration with the following institutions:
- German Cancer Research Center (DKFZ, Heidelberg, Germany)
- Centro Nacional de Análisis Genómico (CNAG, Barcelona, Spain)
- Center for Quantitative Analysis of Molecular and Cellular Biosystems (BioQuant, Heidelberg, Germany)
- Berlin Institute of Health at Charité (Berlin, Germany)
- Altos Labs San Diego Institute of Technology (San Diego, USA)
- Allen Institute for Brain Science (Seattle, USA)
- European Molecular Biology Laboratory (EMBL, Heidelberg, Germany)
Contributors
The following people contributed directly or indirectly through supervision, code review, and the development of concepts and ideas:
- Florian Heyl
- Ezgi Sen
- Niklas Müller-Bötticher
- Sameesh Kher
- Dongze He
- Brian Long
- Naveed Ishaque
- Oliver Stegle
Documentation
For further details please read the documentation.
Installation
Docker
docker run -ti quay.io/heylf/spoqc:0.1.0
Pip
pip install spoqc
Run
spoQC is designed to process large spatial transcriptomics (SRT) datasets at full resolution. Running the complete pipeline typically requires access to an HPC (High Performance Computing) environment.
If you do not have access to an HPC system, you may still be able to run spoQC locally by:
- Using a lower-resolution dataset.
- Running spoQC on a subset of your data.
- Testing individual pipeline steps before processing the full dataset.
Step 1: Generate a Cell Type Annotation (Optional)
If your dataset does not already contain a cell type annotation, spoQC can create one automatically using unsupervised Leiden clustering.
Run:
python3 -m spoqc -s "annotation" -i [input_spatial_data_bundle] -o [output_folder] -t [spoqc_tmp_folder] -n [n_cores]
After the analysis finishes, spoQC will create an annotation file:
[spoqc_tmp_folder]/report/annotation/unsupervised_cell_annotation.tsv
You can use this file as the value for the [annotation_file] parameter in later steps.
Step 2: Run the Complete spoQC Pipeline
To execute all spoQC analyses in the correct order, run:
python3 -m spoqc -s all -i [input_spatial_data_bundle] -o [output_folder] -t [spoqc_tmp_folder] -n [n_cores] -a [annotation_file]
This is the recommended option for most users.
Step 3: Run Individual Pipeline Steps
Advanced users can execute individual spoQC steps separately.
Run:
python3 -m spoqc -s [step] -i [input_spatial_data_bundle] -o [output_folder] -t [spoqc_tmp_folder] -n [n_cores] -a [annotation_file]
Replace [step] with one of the following pipeline stages.
Important: These steps must be executed in the exact order shown below. Running steps out of order will cause downstream analyses to fail.
- generalqc
- bubbleqc
- doubletqc
- voidqc
- cellqc
- ambientqc
- hqcr_ident
- hqcr_celltype
- hqpr_metrices (has to be run for each staining)
- hqpr_clustering (has to be run for each staining)
- hqpr_refinement (has to be run for each staining)
- hqpr_bounding_box (has to be run for each staining)
- hqpr_celltype (has to be run for each staining)
- hqtr_metrices
- hqtr_ac
- hqtr_qv
- hqtr_clustering
- hqtr_refinement
- hqtr_bounding_box
- hqtr_celltype
- combine_masks (has to be run for each staining)
- transcriptqc
- modelqc
- cellcycleqc
- analysis_overview
- analysis_cluster
- analysis_category
Example
To run the first pipeline step (generalqc), execute:
python3 -m spoqc -s generalqc -i [input_spatial_data_bundle] -o [output_folder] -t [spoqc_tmp_folder] -n [n_cores] -a [annotation_file]
Wait until the step has completed successfully before continuing with the next step in the list.
Nextflow subworkflow
spoQC can be executed sequentially, but processing a full-resolution spatial transcriptomics dataset typically takes 4–5 days to complete.
To significantly reduce runtime, we provide a dedicated Nextflow subworkflow that parallelizes many of the processing steps. Using the Nextflow workflow can reduce the total runtime to approximately 1–2 days, depending on the available computational resources.
The workflow is available on the spoQC branch of nf-core/spatialaxe.
[!NOTE] Processing a full-resolution spatial transcriptomics (SRT) dataset with spoQC typically requires access to an HPC (High Performance Computing) environment.
If an HPC system is not available, you may still be able to run spoQC locally by:
- Using a lower-resolution dataset.
- Processing a subset of your data.
- Running selected workflow components instead of the complete pipeline.
Contribute
There are several ways to contribute to spoQC. The project is built around four main pillars:
- metrics
- priors
- subworkflows
- standard pre- and postprocessing scripts
[!NOTE] We are currently working on standardizing these components and providing templates to make contributions easier and more consistent.
spoqc/metrics/
Metrics are used to quantify different aspects of spatial transcriptomics data quality. Currently, metrics are organized into three categories:
- image metrics
- segmentation metrics
- transcript density metrics
Some metrics may be relevant to multiple categories. The organization of these layers is still being refined as spoQC evolves.
Examples
Segmentation metric
spoqc/metrics/segmentation/overlap_area.py
Segmentation metrics must be linked back to individual cells and stored in the SpatialData object (within the associated AnnData table).
Image metric
spoqc/metrics/image/edge_strength.py
Image metrics should be saved as a one-dimensional (1D) array.
Transcript density metric
spoqc/metrics/image/transcript_density_image.py
Transcript density metrics should also be saved as a one-dimensional (1D) array.
spoqc/priors/
Priors are used to estimate the initial probability that a spatial observation (for example, a cell or pixel) is of high or low quality based on a specific metric.
All priors are combined in:
spoqc/priors/combine_priors.py
Each prior contributes evidence about the quality of a spatial observation and is integrated into the overall quality assessment.
spoqc/subworkflows/
SpoQC contains several predefined subworkflows that automate common analysis tasks.
Some subworkflows, such as qc_doublets.py, serve as entry points for metric calculation, quality assessment, visualization, and reporting.
Subworkflows are a good place to contribute additional analysis pipelines or improve existing workflows.
Standard Pre- and Postprocessing Scripts
SpoQC also includes scripts for common preprocessing and postprocessing operations.
Examples include:
- normalization methods
- data transformations
- filtering procedures
- result aggregation and reporting
Contributions that improve interoperability with new data formats or analysis workflows are particularly welcome.
How to Add a New Metric
To contribute a new metric, follow these steps:
-
Identify which metric category the new metric belongs to (image, segmentation, transcript density, or another relevant layer).
-
Implement the metric calculation and place the script in the appropriate folder under:
spoqc/metrics/ -
Create a corresponding prior estimation method and place it in:
spoqc/priors/ -
Register the new prior in:
spoqc/priors/combine_priors.py -
Ensure that the prior returns the probability that a spatial observation (for example, a cell or pixel) is of high quality.
Checklist for New Metrics
- Metric implementation added to
spoqc/metrics/ - Metric output stored in the expected format
- Prior implementation added to
spoqc/priors/ - Prior registered in
spoqc/priors/combine_priors.py - Prior represents the probability of high-quality observations
- Documentation and examples added where appropriate
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 spoqc-0.0.1.tar.gz.
File metadata
- Download URL: spoqc-0.0.1.tar.gz
- Upload date:
- Size: 132.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e25ee0b0b5a0eb0cd94067b568a4b38336e2acb7e8f60b747d43c95ccbef49f
|
|
| MD5 |
14beafbe0452907d62b7436b36c1de73
|
|
| BLAKE2b-256 |
e9e5cb0476e6857e7e98001fb7b753d7e0ba264de63b720bf22f9b8b8b18b0a9
|
Provenance
The following attestation bundles were made for spoqc-0.0.1.tar.gz:
Publisher:
publish.yml on heylf/spoQC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spoqc-0.0.1.tar.gz -
Subject digest:
1e25ee0b0b5a0eb0cd94067b568a4b38336e2acb7e8f60b747d43c95ccbef49f - Sigstore transparency entry: 2498553128
- Sigstore integration time:
-
Permalink:
heylf/spoQC@5afed5ecd93ab82253561b3e1ddda73f86ba34ff -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/heylf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5afed5ecd93ab82253561b3e1ddda73f86ba34ff -
Trigger Event:
release
-
Statement type:
File details
Details for the file spoqc-0.0.1-py3-none-any.whl.
File metadata
- Download URL: spoqc-0.0.1-py3-none-any.whl
- Upload date:
- Size: 162.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abfcae848d70fe7c9ffff61731c84318a6887352e1180e38985231b779f4116
|
|
| MD5 |
2715610eb77031c1b845895f8baced25
|
|
| BLAKE2b-256 |
9bf703159962943d1c71a7491bc78b641413b65ed84ec54423222357248f8d9c
|
Provenance
The following attestation bundles were made for spoqc-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on heylf/spoQC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spoqc-0.0.1-py3-none-any.whl -
Subject digest:
5abfcae848d70fe7c9ffff61731c84318a6887352e1180e38985231b779f4116 - Sigstore transparency entry: 2498553132
- Sigstore integration time:
-
Permalink:
heylf/spoQC@5afed5ecd93ab82253561b3e1ddda73f86ba34ff -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/heylf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5afed5ecd93ab82253561b3e1ddda73f86ba34ff -
Trigger Event:
release
-
Statement type: