Methods Reference

May 20, 2026 · View on GitHub

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 65 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

CategoryTools
Dataload_data, preprocess_data, compute_embeddings, export_data, reload_data
Spatialanalyze_spatial_statistics, find_spatial_genes, identify_spatial_domains
Cellsannotate_cell_types, deconvolve_data, analyze_cell_communication
Genesfind_markers, compare_conditions, analyze_enrichment
Dynamicsanalyze_velocity_data, analyze_trajectory_data, analyze_cnv
Multi-sampleintegrate_samples, register_spatial_data
Outputvisualize_data

Data Management

load_data

Load spatial transcriptomics data.

ParameterTypeDescription
data_pathstrPath to file or folder
data_typestrvisium, xenium, slide_seq, merfish, seqfish, generic
namestrOptional dataset name

Supported formats: H5AD, 10X Visium folders, H5, MTX


preprocess_data

Normalize, filter, and prepare data.

ParameterDefaultDescription
normalizationpearson_residualslog, sct, pearson_residuals, scvi, none
n_hvgs2000Highly variable genes
n_pcs30Principal components
n_neighbors15Neighbor graph
clustering_resolution1.0Leiden clustering
filter_genes_min_cells3Min cells per gene
filter_cells_min_genes30Min genes per cell
filter_mito_pct20.0Max mitochondrial %
scaleFalseScale to unit variance before PCA

Advanced options:

ParameterDefaultDescription
use_scrubletFalseEnable doublet detection (for single-cell resolution data)
normalize_target_sumNoneTarget counts per cell (None=median, 1e4=Visium, 1e6=MERFISH)
remove_mito_genesTrueExclude mito genes from HVG
batch_keybatchBatch column for batch-aware normalization

compute_embeddings

Compute dimensionality reduction and clustering.

ParameterDefaultDescription
compute_pcaTrueCompute PCA
compute_umapTrueCompute UMAP
compute_clusteringTrueLeiden clustering
compute_spatial_neighborsTrueSpatial graph
n_pcs30Principal components
clustering_resolution1.0Clustering resolution
forceFalseRecompute if exists

export_data / reload_data

Export dataset for external scripts, reload after modifications.

ParameterDefaultDescription
data_idrequiredDataset ID
pathautoCustom path (default: ~/.chatspatial/active/{data_id}.h5ad)

Spatial Analysis

analyze_spatial_statistics

Analyze spatial patterns and autocorrelation.

ParameterDefaultDescription
analysis_typeneighborhoodSee types below
cluster_keyNoneRequired for group-based analyses
genesNoneSpecific genes to analyze
n_top_genes20Top HVGs to analyze (if genes not specified)
n_neighbors8Spatial neighbors

Analysis types:

TypeCategoryRequires cluster_key
moranGeneNo
local_moranGeneNo
gearyGeneNo
getis_ordGeneNo
bivariate_moranGeneNo
neighborhoodGroupYes
co_occurrenceGroupYes
ripleyGroupYes
join_countGroupYes
local_join_countGroupYes
centralityNetworkYes
network_propertiesNetworkYes
spatial_centralityNetworkYes

find_spatial_genes

Identify spatially variable genes.

ParameterDefaultDescription
methodflashssparkx, flashs, spatialde
n_top_genesNoneTop genes to return (None = all significant)

identify_spatial_domains

Find tissue domains and spatial niches.

ParameterDefaultDescription
methodspagcnspagcn, stagate, graphst, banksy, leiden, louvain
n_domains7Expected number of domains
resolution0.5Clustering resolution

Cell Analysis

annotate_cell_types

Assign cell types.

ParameterDefaultDescription
methodtangramSee methods below
reference_data_idNoneReference dataset (for transfer methods)
cell_type_keyNoneCell type column in reference
marker_genesNoneMarker dict (for CellAssign)
sctype_tissueNonescType tissue name, required unless custom markers are provided
sctype_db_NoneLocal scType database path, or remote URL when explicitly allowed
sctype_custom_markersNoneCustom scType marker sets
sctype_scaledTrueWhether scType should treat the expression matrix as scaled
sctype_allow_remoteFalseOne-off opt-in to load scType remote R scripts and default marker database
sctype_allow_runtime_r_installFalseOne-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:

MethodRequires ReferenceNotes
tangramYesSpatial mapping
scanviYesDeep learning transfer
cellassignNoMarker-based
sctypeNoAutomatic (R)
singlerNoReference-based (R)
mllmcelltypeNoLLM-based

deconvolve_data

Estimate cell type proportions per spot.

ParameterDefaultDescription
methodflashdeconvSee methods below
reference_data_idrequiredReference dataset
cell_type_keyrequiredCell type column in reference

Methods:

MethodSpeedGPUNotes
flashdeconvFastNoDefault, recommended
cell2locationSlowYesHigh accuracy
rctdFastNoR-based
destviMediumYesscvi-tools
stereoscopeSlowYesAlternative DL
tangramMediumYesSpatial mapping
spotlightFastNoR-based
cardFastNoR-based, imputation

analyze_cell_communication

Analyze ligand-receptor interactions.

ParameterDefaultDescription
methodfastcccfastccc, liana, cellphonedb, cellchat_r
speciesrequiredhuman, mouse, zebrafish
cell_type_keyrequiredCell type column
liana_resourceconsensusLR database (mouseconsensus for mouse)

Gene Analysis

find_markers

Find differentially expressed genes.

ParameterDefaultDescription
group_keyrequiredGrouping column
group1NoneFirst group (None = each vs rest)
group2NoneSecond group
methodwilcoxonwilcoxon, t-test, t-test_overestim_var, logreg, pydeseq2
n_top_genes50Top genes per group

compare_conditions

Compare experimental conditions (pseudobulk DESeq2).

ParameterDefaultDescription
condition_keyrequiredCondition column
condition1requiredTreatment group
condition2requiredControl group
sample_keyrequiredSample/patient column
cell_type_keyNoneStratify by cell type
n_top_genes50Top DEGs

analyze_enrichment

Gene set enrichment analysis.

ParameterDefaultDescription
speciesrequiredhuman, mouse, zebrafish
methodspatial_enrichmapspatial_enrichmap, pathway_gsea, pathway_ora, pathway_enrichr, pathway_ssgsea
gene_set_databaseGO_Biological_ProcessSee 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.

ParameterDefaultDescription
methodscveloscvelo, velovi
scvelo_modestochasticdeterministic, stochastic, dynamical

Requires: spliced and unspliced layers


analyze_trajectory_data

Trajectory and pseudotime inference.

ParameterDefaultDescription
methodcellrankcellrank, palantir, dpt
root_cellsNoneStarting cells

Note: CellRank requires velocity data


analyze_cnv

Copy number variation detection.

ParameterDefaultDescription
methodinfercnvpyinfercnvpy, numbat
reference_keyrequiredCell type column
reference_categoriesrequiredNormal cell types

Multi-Sample

integrate_samples

Batch integration.

ParameterDefaultDescription
data_idsrequiredList of dataset IDs
methodharmonyharmony, bbknn, scanorama, scvi
batch_keybatchBatch column

register_spatial_data

Align spatial sections.

ParameterDefaultDescription
source_idrequiredSource dataset
target_idrequiredTarget dataset
methodpastepaste, stalign

Visualization

visualize_data

Create all plot types.

ParameterDefaultDescription
plot_typefeatureSee types below
subtypeNoneVisualization variant
featureNoneGene(s) or column to show
basisspatialspatial, umap
cluster_keyNoneGrouping column
colormapcoolwarmColor scheme
dpi300Resolution
output_formatpngpng, pdf, svg, eps, tiff, jpg

Plot types and subtypes:

TypeSubtypesUse
featureGene/metadata on spatial or UMAP
expressionheatmap, violin, dotplot, correlationAggregated expression
deconvolutionspatial_multi, pie, dominant, diversity, umap, imputationCell proportions
communicationdotplot, tileplot, circle_plotLR interactions
interactionSpatial LR pairs
trajectorypseudotime, circular, fate_map, gene_trends, fate_heatmap, palantirPseudotime
velocitystream, phase, proportions, heatmap, pagaRNA velocity
statisticsneighborhood, co_occurrence, ripley, moran, centrality, getis_ordSpatial stats
enrichmentbarplot, dotplotPathway results
cnvheatmap, spatialCNV results
integrationbatch, cluster, highlightIntegration QC

GPU Acceleration

Set use_gpu=True for these methods:

CategoryMethods
PreprocessingscVI normalization
AnnotationTangram, scANVI
DeconvolutionCell2location, DestVI, Stereoscope, Tangram
DomainsSTAGATE, GraphST
VelocityVeloVI
IntegrationscVI
CNVinferCNVpy