方法参考

全部 20 个 ChatSpatial 工具及其参数与选项。


快速索引

分类

工具

数据

load_data, preprocess_data, compute_embeddings, export_data, reload_data

空间

analyze_spatial_statistics, find_spatial_genes, identify_spatial_domains

细胞

annotate_cell_types, deconvolve_data, analyze_cell_communication

基因

find_markers, compare_conditions, analyze_enrichment

动态

analyze_velocity_data, analyze_trajectory_data, analyze_cnv

多样本

integrate_samples, register_spatial_data

输出

visualize_data


数据管理

load_data

加载空间转录组数据。

参数

类型

说明

data_path

str

文件或文件夹路径

data_type

str

visium, xenium, slide_seq, merfish, seqfish, generic

name

str

可选的数据集名称

支持的格式:H5AD、10X Visium 文件夹、H5、MTX


preprocess_data

归一化、过滤并准备数据。

参数

默认值

说明

normalization

log

log, sct, pearson_residuals, scvi, none

n_hvgs

2000

高变基因数

n_pcs

30

主成分数

n_neighbors

15

邻居图

clustering_resolution

1.0

Leiden 聚类

filter_genes_min_cells

3

每个基因的最小细胞数

filter_cells_min_genes

30

每个细胞的最小基因数

filter_mito_pct

20.0

线粒体比例上限(%)

scale

False

PCA 前缩放到单位方差

高级选项:

参数

默认值

说明

scrublet_enable

False

启用 doublet 检测(适用于单细胞分辨率数据)

normalize_target_sum

None

每个细胞的目标计数(None=中位数,1e4=Visium,1e6=MERFISH)

remove_mito_genes

True

从高变基因中排除线粒体基因

batch_key

batch

用于批次感知归一化的 batch 列


compute_embeddings

计算降维结果与聚类。

参数

默认值

说明

compute_pca

True

计算 PCA

compute_umap

True

计算 UMAP

compute_clustering

True

Leiden 聚类

compute_spatial_neighbors

True

空间图

n_pcs

30

主成分数

clustering_resolution

1.0

聚类分辨率

force

False

若已存在则重新计算


export_data / reload_data

导出数据集以供外部脚本使用,并在修改后重新加载。

参数

默认值

说明

data_id

必填

数据集 ID

path

auto

自定义路径(默认:~/.chatspatial/active/


空间分析

analyze_spatial_statistics

分析空间模式与自相关。

参数

默认值

说明

analysis_type

neighborhood

见下方类型

cluster_key

None

分组分析需要该参数

genes

None

指定要分析的基因

n_top_genes

20

要分析的高变基因数量(未指定 genes 时)

n_neighbors

8

空间邻居数

分析类型:

类型

分类

需要 cluster_key

moran

基因

local_moran

基因

geary

基因

getis_ord

基因

bivariate_moran

基因

neighborhood

分组

co_occurrence

分组

ripley

分组

join_count

分组

centrality

网络

可选


find_spatial_genes

识别空间变异基因。

参数

默认值

说明

method

sparkx

sparkx, flashs, spatialde

n_top_genes

None

返回的基因数量(None=返回所有显著基因)


identify_spatial_domains

识别组织区域与空间微环境。

参数

默认值

说明

method

spagcn

spagcn, stagate, graphst, leiden, louvain

n_domains

7

期望的区域数量

resolution

0.5

聚类分辨率


细胞分析

annotate_cell_types

分配细胞类型。

参数

默认值

说明

method

tangram

见下方方法

reference_data_id

None

参考数据集(用于 label transfer 方法)

cell_type_key

None

参考数据中的细胞类型列

marker_genes

None

marker 字典(用于 CellAssign)

方法:

Method

需要参考数据

备注

tangram

空间映射

scanvi

深度学习迁移

cellassign

基于 marker

sctype

自动(R)

singler

基于参考(R)

mllmcelltype

基于 LLM


deconvolve_data

估计每个 spot 的细胞类型比例。

参数

默认值

说明

method

flashdeconv

见下方方法

reference_data_id

必填

参考数据集

cell_type_key

必填

参考数据中的细胞类型列

方法:

Method

Speed

GPU

备注

flashdeconv

默认,推荐

cell2location

高准确性

rctd

基于 R

destvi

中等

scvi-tools

stereoscope

替代的深度学习方法

tangram

中等

空间映射

spotlight

基于 R

card

基于 R,含插补


analyze_cell_communication

分析配体-受体相互作用。

参数

默认值

说明

method

fastccc

fastccc, liana, cellphonedb, cellchat_r

species

必填

human, mouse, zebrafish

cell_type_key

必填

细胞类型列

liana_resource

consensus

配体-受体(LR)数据库(小鼠用 mouseconsensus


基因分析

find_markers

寻找差异表达基因。

参数

默认值

说明

group_key

必填

分组列

group1

None

第一组(None=每组 vs 其余)

group2

None

第二组

method

wilcoxon

wilcoxon, t-test, t-test_overestim_var, logreg, pydeseq2

n_top_genes

50

每组 top 基因数


compare_conditions

比较实验条件(pseudobulk DESeq2)。

参数

默认值

说明

condition_key

必填

条件列

condition1

必填

处理组

condition2

必填

对照组

sample_key

必填

样本/患者列

cell_type_key

None

按细胞类型分层

n_top_genes

50

Top 差异基因数


analyze_enrichment

基因集富集分析。

参数

默认值

说明

species

必填

human, mouse, zebrafish

method

pathway_ora

pathway_ora, pathway_gsea, pathway_ssgsea, spatial_enrichmap

gene_set_database

GO_Biological_Process

见下方数据库

数据库GO_Biological_ProcessGO_Molecular_FunctionKEGG_PathwaysReactome_PathwaysMSigDB_Hallmark


动态

analyze_velocity_data

RNA velocity 分析。

参数

默认值

说明

method

scvelo

scvelo, velovi

mode

stochastic

deterministic, stochastic, dynamical

需要splicedunspliced layers


analyze_trajectory_data

轨迹与伪时间推断。

参数

默认值

说明

method

cellrank

cellrank, palantir, dpt

root_cells

None

起始细胞

注意:CellRank 需要 velocity 数据


analyze_cnv

拷贝数变异(CNV)检测。

参数

默认值

说明

method

infercnvpy

infercnvpy, numbat

reference_key

必填

细胞类型列

reference_categories

必填

正常细胞类型


多样本

integrate_samples

批次整合。

参数

默认值

说明

data_ids

必填

数据集 ID 列表

method

harmony

harmony, bbknn, scanorama, scvi

batch_key

batch

批次列


register_spatial_data

对齐空间切片。

参数

默认值

说明

source_id

必填

源数据集

target_id

必填

目标数据集

method

paste

paste, stalign


可视化

visualize_data

生成所有类型的图。

参数

默认值

说明

plot_type

feature

见下方类型

subtype

None

可视化子类型

feature

None

要展示的基因或列

basis

spatial

spatial, umap

cluster_key

None

分组列

colormap

coolwarm

配色方案

dpi

300

分辨率

output_format

png

png, pdf, svg

图形类型与子类型:

类型

子类型

用途

feature

在 spatial 或 UMAP 上展示基因/元数据

expression

heatmap, violin, dotplot, correlation

汇总表达

deconvolution

spatial_multi, pie, dominant, diversity, umap

细胞比例

communication

dotplot, tileplot, circle_plot

LR 相互作用

interaction

空间 LR 配对

trajectory

pseudotime, fate_map, gene_trends

伪时间

velocity

stream, phase, paga

RNA velocity

statistics

neighborhood, co_occurrence, ripley, moran

空间统计

enrichment

barplot, dotplot

通路结果

cnv

heatmap, spatial

CNV 结果

integration

batch, cluster

整合质控


GPU 加速

对以下方法设置 use_gpu=True

分类

方法

预处理

scVI 归一化

注释

Tangram, scANVI

去卷积

Cell2location, DestVI, Stereoscope, Tangram

区域

STAGATE, GraphST

速度

VeloVI

整合

scVI

CNV

inferCNVpy


下一步

  • 示例 — 查看方法如何实际使用

  • 概念 — 何时该用哪种方法

  • 故障排查 — 常见问题与解决方案