This release is a pre-release and may not be stable for production use.
rctd-py
Spatial transcriptomics deconvolution, 10–57x faster than R spacexr on a GPU (doublet mode)
New in v0.4.0: rctd-py now gives the same results as R spacexr wherever both use the same sigma. Getting there aligned a few details of the fit with R (bulk platform-effect fit, sigma sampling, singlet labels, cell-type order, QP solver), so results can differ from 0.3.9, mostly on sequencing-based data such as Visium. On imaging data (Xenium, CosMx, Atera) spot classes are almost unchanged. Numbers are in the changelog;
rctd-py==0.3.9stays available to reproduce earlier results.
A Python reimplementation of the spacexr RCTD algorithm (Cable et al., Nature Biotechnology 2022) with GPU acceleration via PyTorch.
Deconvolve spatial transcriptomics spots (Visium, Xenium, MERFISH, Slide-seq, …) into cell type proportions using a scRNA-seq reference — in minutes instead of hours.
Documentation: rctd-py.readthedocs.io (installation, tutorials, CLI, API reference, coming from R spacexr)
✨ Highlights
| ⚡ 10–57x faster than R spacexr | Doublet mode on 19 datasets, one GPU vs 8 R cores. Xenium Prime 5K, 503k cells fitted: 34 min vs 31 hours in R |
| 🎯 Matches R spacexr | Same calls as R wherever both pick the same sigma (11 of 19 datasets); 99.0–99.9% of spot classes on the rest, where sigma differs by 0.01–0.02, as it does between two R runs (details) |
| 🔧 Familiar to spacexr users | Same algorithm and, with a few exceptions, the same parameter names (mapping) |
📦 pip install rctd-py |
Pure Python, works on CPU out of the box (3.7–14x faster than R in doublet mode), uses a GPU when there is one |
| 🧬 Whole-transcriptome ready | 10x Atera WTA (18,028-gene panel): 714k cells deconvolved in 9 min on GPU (doublet mode, 7 cell types) |
Installation
uv pip install rctd-py # or: pip install rctd-py
GPU builds of PyTorch, older NVIDIA drivers and offline / HPC installs (the 404 MB Q-matrices file) are covered in the installation guide.
Quick Start
from rctd import Reference, run_rctd
import anndata
reference = Reference(anndata.read_h5ad("reference.h5ad"), cell_type_col="cell_type")
spatial = anndata.read_h5ad("spatial.h5ad")
# normalisation, sigma estimation and deconvolution in one call
result = run_rctd(spatial, reference, mode="doublet")
| Mode | What it does | Best for |
|---|---|---|
full |
Weights for all K cell types per pixel | Visium spots, continuous mixtures |
doublet |
Singlet or doublet call per pixel, top 1–2 types | Slide-seq, Visium HD bins, segmented cells (Xenium, MERFISH, CosMx) |
multi |
Greedy selection of up to 4 types per pixel | Spots expected to hold more than 2 types (an alternative to full) |
📓 Tutorial (marimo notebook) · 🤖 Claude Code skill (copy the .claude/skills/rctd-py/ folder into ~/.claude/skills/ for assisted coding with rctd-py)
Command Line
rctd info # versions, GPU availability
rctd validate spatial.h5ad reference.h5ad # fast input checks
rctd run spatial.h5ad reference.h5ad --mode doublet -o results.h5ad
rctd run experiment.zarr reference.h5ad --table cell_table # SpatialData stores work too
All options and the output layout: command line reference.
Benchmarks
rctd-py on one NVIDIA L40S or 8 CPU threads, R spacexr 2.2.1 on 8 cores; rctd-py points are the median of 3 runs. Full and multi mode, per-dataset tables and memory: benchmarks.
Citation
If you use rctd-py, please cite the original RCTD paper:
@article{cable2022robust,
title={Robust decomposition of cell type mixtures in spatial transcriptomics},
author={Cable, Dylan M and Murray, Evan and Zou, Luli S and Goeva, Aleksandrina and Macosko, Evan Z and Chen, Fei and Irizarry, Rafael A},
journal={Nature Biotechnology},
volume={40},
number={4},
pages={517--526},
year={2022},
doi={10.1038/s41587-021-00830-w}
}
Contributing
Contributions welcome! See CONTRIBUTING.md for setup instructions, or open an issue.
License
Metadata
Release files for rctd-py 0.4.0rc1
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 | |
|---|---|---|---|---|
| rctd_py-0.4.0rc1.tar.gz | 595.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rctd_py-0.4.0rc1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 663.2 kB
Release files / rctd_py-0.4.0rc1.tar.gz
| Download URL | rctd_py-0.4.0rc1.tar.gz |
|---|---|
| Size | 595.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d01a3e1bcb70dbdf6d2d076d8f75edd262bc58aaa078221d1d60a41f6a467b8
|
|
BLAKE2b-256 checksum How to use checksums |
320be99544e55ecb106ad0bc8fc5760d04953aac3258232f6d8a986952de8763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / rctd_py-0.4.0rc1-py3-none-any.whl
| Download URL | rctd_py-0.4.0rc1-py3-none-any.whl |
|---|---|
| Size | 67.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d41136144a106d8984420b22dceaef550691b5de405f617a430fed9ef53be066
|
|
BLAKE2b-256 checksum How to use checksums |
4270fe6f6e183155dfe55f71f7319475ddc542a1837643a3764beac70a33a530
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for rctd-py 0.4.0rc1
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.