rctd-py

Runs GPU-accelerated RCTD cell type deconvolution on spatial transcriptomics data via Python.

Updated May 28, 2026
One-click install
npx skills add https://github.com/cpanse/skills --skill rctd-py-cpanse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rctd-py
Source: https://github.com/cpanse/skills/tree/main/single-cell-ml/skills/rctd-py
Command: npx skills add https://github.com/cpanse/skills --skill rctd-py-cpanse

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, rctd-py, anndata, gget, and includes references (resource) components.

What problem does it solve? R spacexr deconvolution is too slow for large spatial transcriptomics datasets, and FGCZ GPU nodes lack the R module environment, making cell type annotation of Visium, Xenium, and VisiumHD data a bottleneck. ## Core Features & Use Cases - GPU-Accelerated Deconvolution: Runs RCTD via PyTorch on CUDA devices, 4-41x faster than R spacexr, with doublet, multi, and full modes for different spatial platforms. - Reference Preparation: Converts Seurat, spacexr, scanpy, or CELLxGENE references into h5ad format with raw counts for Python workflows. - FGCZ SLURM Integration: Provides SBATCH templates for L40S and Blackwell GPU nodes, including workarounds for missing Dev/* modules. - Use Case: A researcher with a 400k-cell Xenium dataset submits a GPU SLURM job using rctd run --mode doublet --umi-min 20, then integrates the resulting cell type weights back into a Seurat object for spatial visualization. ## Quick Start Ask the agent to run rctd-py deconvolution on your spatial.h5ad and reference.h5ad files in doublet mode on the GPU and integrate the results back into your Seurat object.

Frequently Asked Questions about rctd-py

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run RCTD deconvolution on GPU with Python?

Install PyTorch with CUDA support, then install rctd-py and run `rctd run spatial.h5ad reference.h5ad --mode doublet --device cuda`. Validate inputs first with `rctd validate`, which requires no GPU.

What is the difference between rctd-py and R spacexr?

rctd-py is a Python/PyTorch reimplementation of RCTD that runs 4-41x faster than R spacexr with 99.7% concordance. It supports GPU acceleration and h5ad workflows, while spacexr runs in R on CPU.

Which RCTD mode should I use for Xenium or Visium data?

Use doublet mode for Xenium, MERFISH, and Slide-seq data, assigning 1-2 cell types per spot. Use full mode for Visium and VisiumHD where spots contain multiple cells, and multi mode for dense data with high contamination.

How do I fix CUDA out of memory errors in rctd-py?

Reduce the batch size with `--batch-size 5000` or lower, and switch to `--dtype float32` to halve VRAM usage. Default settings use roughly 4 GB VRAM for 45 cell types, so most GPUs handle standard workloads.

Can I run rctd-py on FGCZ GPU nodes without R modules?

Yes, GPU nodes lack Dev/* modules, so run rctd-py via `uv run rctd` from the local repo at ~/git/rctd-py. Perform any R-based reference conversion as a separate job on the employee partition first.

How do I convert a Seurat reference to h5ad for rctd-py?

In R, use anndataR's as_anndata with x_layer set to counts, optionally downsampling to about 500 cells per type, then write_h5ad. Ensure .X contains raw integer counts and .obs has a cell_type column.