Methods Reference¶
This page is the canonical human-readable reference for ChatSpatial tool names, method names, common defaults, accepted values, and user-facing parameter behavior. MCP clients expose the full schema for method-specific advanced options.
ChatSpatial’s public interface is a set of 20 schema-validated MCP tools. Those
tools orchestrate 66 spatial transcriptomics methods across 15 analytical
categories. In this page, tool means the MCP entry point you or an AI client
can call; method means an algorithm or analysis backend selected through a
parameter such as method, analysis_type, plot_type, or subtype.
Quick Reference¶
Category |
Tools |
|---|---|
Data |
|
Spatial |
|
Cells |
|
Genes |
|
Dynamics |
|
Multi-sample |
|
Output |
|
Data Management¶
load_data¶
Load spatial transcriptomics data.
Parameter |
Type |
Description |
|---|---|---|
|
str |
Path to file or folder |
|
str |
|
|
str |
Optional dataset name |
Supported formats: H5AD, 10X Visium folders, H5, MTX
preprocess_data¶
Normalize, filter, and prepare data.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
2000 |
Highly variable genes |
|
3 |
Min cells per gene |
|
30 |
Min genes per cell |
|
20.0 |
Max mitochondrial % |
|
False |
Scale to unit variance before PCA |
Advanced options:
Parameter |
Default |
Description |
|---|---|---|
|
False |
Enable doublet detection (for single-cell resolution data) |
|
None |
Target counts per cell (None=median, 1e4=Visium, 1e6=MERFISH) |
|
True |
Exclude mito genes from HVG |
|
|
Batch column for batch-aware normalization |
PCA, neighbor, UMAP, and clustering parameters belong to
compute_embeddings; preprocess_data does not accept or retain them.
preprocess_data does not compute PCA, UMAP, clustering, or neighbor graphs.
Call compute_embeddings explicitly before cluster- or embedding-dependent tools.
compute_embeddings¶
Compute dimensionality reduction and clustering.
Parameter |
Default |
Description |
|---|---|---|
|
True |
Compute PCA |
|
True |
Compute UMAP |
|
True |
Leiden clustering |
|
True |
Spatial graph |
|
30 |
Principal components |
|
1.0 |
Clustering resolution |
|
False |
Recompute if exists |
export_data / reload_data¶
Export dataset for external scripts, reload after modifications.
Parameter |
Default |
Description |
|---|---|---|
|
required |
Dataset ID |
|
auto |
Custom path (default: |
Spatial Analysis¶
analyze_spatial_statistics¶
Analyze spatial patterns and autocorrelation.
Parameter |
Default |
Description |
|---|---|---|
|
|
See types below |
|
None |
Required for group-based analyses |
|
None |
Specific genes to analyze |
|
20 |
Top HVGs to analyze (if genes not specified) |
|
8 |
Spatial neighbors |
Analysis types:
Type |
Category |
Requires cluster_key |
|---|---|---|
|
Gene |
No |
|
Gene |
No |
|
Gene |
No |
|
Gene |
No |
|
Gene |
No |
|
Group |
Yes |
|
Group |
Yes |
|
Group |
Yes |
|
Group |
Yes |
|
Group |
Yes |
|
Network |
Yes |
|
Network |
Yes |
|
Network |
Yes |
find_spatial_genes¶
Identify spatially variable genes.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
None |
Top genes to return (None = all significant) |
|
None |
Optional runtime cap applied after filters; keeps the highest-expressed genes for testing |
|
True |
Restrict testing to highly variable genes |
|
True |
Exclude mitochondrial genes before testing |
|
False |
Exclude ribosomal genes before testing |
n_top_genes limits the ranked result returned to the caller;
max_genes_tested limits the genes supplied to the statistical backend. Use
the latter to bound SpatialDE runtime without changing the meaning of the
output limit. FlashS is the default Python-native backend and is part of the
standard installation; SpatialDE is installed with chatspatial[spatial-genes].
identify_spatial_domains¶
Find tissue domains and spatial niches.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
7 |
Expected number of domains |
|
0.5 |
Clustering resolution |
SpaGCN, STAGATE, and AESTETIK kmeans/bgm use n_domains. BANKSY and the
Leiden/Louvain paths are resolution-driven; adjust banksy_cluster_resolution
or resolution instead of expecting an exact domain count. GraphST may use
graphst_n_clusters when an explicit count is required. GraphST and STAGATE
publish their reusable embeddings as X_graphst and X_stagate in
adata.obsm. The legacy Louvain choice is retained for compatibility and falls
back to Leiden when the obsolete Louvain extension is unavailable.
AESTETIK fuses a precomputed expression embedding, a precomputed per-spot morphology embedding, and the spatial neighborhood grid. It reads both representations from adata.obsm and does not extract morphology features from tissue images. It also needs discrete lattice coordinates in adata.obs, either x_array/y_array or the Visium array_row/array_col columns.
Parameter |
Default |
Description |
|---|---|---|
|
|
obsm key with the expression embedding |
|
|
obsm key with the morphology embedding |
|
1.5 |
Morphology weight in the joint loss |
|
3 |
Odd side length of the neighborhood grid |
|
|
|
|
16 |
Latent embedding dimension |
|
100 |
Training epochs |
|
2023 |
Random seed |
Install with pip install 'chatspatial[aestetik]' (Python < 3.14). Method reference: Representation learning for multi-modal spatially resolved transcriptomics data, Bioinformatics (2026).
Cell Analysis¶
annotate_cell_types¶
Assign cell types.
Parameter |
Default |
Description |
|---|---|---|
|
|
See methods below |
|
None |
Reference dataset (for transfer methods) |
|
None |
Cell type column in reference |
|
None |
Marker dict (for CellAssign) |
|
None |
scType tissue name, required unless custom markers are provided |
|
None |
Local scType database path, or remote URL when explicitly allowed |
|
None |
Custom scType marker sets |
|
True |
Whether scType should treat the expression matrix as scaled |
|
False |
One-off opt-in to load scType remote R scripts and default marker database |
|
False |
One-off opt-in to install missing R packages at runtime |
scType remote resources: by default, scType does not load remote R scripts or the remote default marker database. For one-off exploratory runs, pass sctype_allow_remote=true. For production or offline workflows, prefer local R scripts via CHATSPATIAL_SCTYPE_R_DIR and a local sctype_db_ path.
{
"method": "sctype",
"sctype_tissue": "Immune system",
"sctype_allow_remote": true
}
Methods:
Method |
Requires Reference |
Notes |
|---|---|---|
|
Yes |
Spatial mapping |
|
Yes |
Deep learning transfer |
|
No |
Marker-based |
|
No |
Automatic (R) |
|
No |
Reference-based (R) |
|
No |
LLM-based |
deconvolve_data¶
Estimate cell type proportions per spot.
Parameter |
Default |
Description |
|---|---|---|
|
|
See methods below |
|
required |
Reference dataset |
|
required |
Cell type column in reference |
Methods:
Method |
Speed |
GPU |
Notes |
|---|---|---|---|
|
Fast |
No |
Default, recommended |
|
Slow |
Yes |
High accuracy |
|
Variable |
Optional |
R/spacexr by default; CUDA-oriented rctd-py backend |
|
Medium |
Yes |
scvi-tools |
|
Slow |
Yes |
Alternative DL |
|
Medium |
Yes |
Spatial mapping |
|
Fast |
No |
R-based |
|
Fast |
No |
R-based, imputation |
RCTD backend options:
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
Automatic or positive spot batch size; Python backend only |
|
|
|
|
None |
Fix sigma instead of estimating it; Python backend only |
|
4 |
Worker limit; R backend only |
Install the Python backend with
uv pip install 'chatspatial[rctd-python]'. It preserves the main
deconvolution_rctd result contract and also stores mode-specific annotations
such as rctd_status, rctd_converged, and doublet/multi outputs. The first
run downloads an approximately 400 MB likelihood table to ~/.cache/rctd.
Use rctd-py primarily on CUDA systems. CPU cold starts can be slower than
spacexr because PyTorch compilation fallback and sigma calibration dominate
small runs; rctd_sigma_override skips calibration but not compilation startup.
analyze_cell_communication¶
Analyze ligand-receptor interactions.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
required |
|
|
required |
Cell type column |
|
|
LR database ( |
LIANA is the portable default and supports human, mouse, and zebrafish.
FastCCC and CellPhoneDB currently require human data. Install LIANA and
CellPhoneDB with chatspatial[cell-communication], FastCCC with
chatspatial[fastccc], or all three through chatspatial[full]. The maintained
FastCCC runtime is composable with trajectory; it does not include the unused
HTML report layer or depend on Jinja2.
Gene Analysis¶
find_markers¶
Find differentially expressed genes.
Parameter |
Default |
Description |
|---|---|---|
|
required |
Grouping column |
|
None |
First group (None = each vs rest) |
|
None |
Second group |
|
|
|
|
50 |
Top genes per group |
Results are grouped per comparison rather than flattened across groups. Each row reports both groups’ mean expression alongside the fold change, so effect size can be interpreted in expression context.
compare_conditions¶
Compare experimental conditions (pseudobulk DESeq2).
Parameter |
Default |
Description |
|---|---|---|
|
required |
Condition column |
|
required |
Treatment group |
|
required |
Control group |
|
required |
Sample/patient column |
|
None |
Stratify by cell type |
|
50 |
Top DEGs |
analyze_enrichment¶
Gene set enrichment analysis.
Parameter |
Default |
Description |
|---|---|---|
|
required |
|
|
|
|
|
|
See databases below |
Databases: GO_Biological_Process, GO_Molecular_Function, GO_Cellular_Component, KEGG_Pathways, Reactome_Pathways, MSigDB_Hallmark, Cell_Type_Markers
Dynamics¶
analyze_velocity_data¶
RNA velocity analysis.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
|
|
Requires: spliced and unspliced layers
analyze_trajectory_data¶
Trajectory and pseudotime inference.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
None |
Starting cells |
|
5 |
Number of CellRank macrostates |
|
0.96 |
Minimum stability for a macrostate to count as terminal |
Note: CellRank requires velocity data and Python 3.12 or newer. When no
state reaches cellrank_stability_threshold, ChatSpatial falls back to
macrostate-based pseudotime and returns a warning. Palantir and DPT do not need
velocity; if root_cells is omitted, the automatically selected root and any
unreachable cells are reported in the tool warnings.
analyze_cnv¶
Copy number variation detection.
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
required |
Cell type column |
|
required |
Normal cell types |
Multi-Sample¶
integrate_samples¶
Batch integration.
Parameter |
Default |
Description |
|---|---|---|
|
required |
Two or more distinct dataset IDs |
|
|
|
|
|
Batch column |
register_spatial_data¶
Align spatial sections.
Parameter |
Default |
Description |
|---|---|---|
|
required |
Source dataset; must differ from |
|
required |
Target dataset; must differ from |
|
|
|
Visualization¶
visualize_data¶
Create all plot types.
Parameter |
Default |
Description |
|---|---|---|
|
|
See types below |
|
None |
Visualization variant |
|
None |
Gene(s) or column to show |
|
|
|
|
None |
Grouping column |
|
|
Color scheme for continuous values. Categorical features automatically use a qualitative palette such as |
|
300 |
Resolution |
|
|
|
Plot types and subtypes:
Type |
Subtypes |
Use |
|---|---|---|
|
— |
Gene/metadata on spatial or UMAP |
|
|
Aggregated expression; heatmaps scale per gene by default |
|
|
Cell proportions |
|
|
LR interactions |
|
— |
Spatial LR pairs |
|
|
Pseudotime |
|
|
RNA velocity |
|
|
Spatial stats |
|
|
Pathway results |
|
|
CNV results |
|
|
Integration QC |
GPU Acceleration¶
GPU acceleration is available for these methods. Most use use_gpu=True;
the rctd-py backend instead uses rctd_device="cuda":
Category |
Methods |
|---|---|
Preprocessing |
scVI normalization |
Annotation |
Tangram, scANVI |
Deconvolution |
Cell2location, DestVI, Stereoscope, Tangram, RCTD (rctd-py backend) |
Domains |
STAGATE, GraphST |
Velocity |
VeloVI |
Integration |
scVI |
CNV |
inferCNVpy |