何时使用
当你需要从单细胞 RNA-seq 推断并可视化细胞类型间的信号通讯时使用本条,典型场景:
- 判定组织/疾病样本里哪些细胞类型是旁分泌/自分泌信号的主要发送者与受体者
- 找出介导特定细胞群通讯的配体-受体对(如 肿瘤→T 细胞、成纤维→上皮)
- 比较两条件(健康 vs 疾病、用药 vs 对照)的信号网络,发现重连/丢失的通讯
- 发现某细胞互作中富集的通路级信号程序(如 MHC-II、COLLAGEN、VEGF)
- 按通讯强度或网络中心性排序,为扰动实验优先选靶
不该用本条的边界:
- 想要纯 Python 流程,或跨多个配体-受体数据库(CellChat/CellPhoneDB/Connectome/NicheNet)的共识排名 → 用 liana(py)
- 需要配体到靶基因的调控推断(预测发送细胞配体调控受体细胞哪些靶基因)→ 用 NicheNet
- 物种非人/鼠:CellChatDB 仅覆盖人鼠,其它物种需自建数据库
步骤
- 建对象:从 Seurat 对象(取归一化
data+ Idents 标签)或计数矩阵 + 标签向量createCellChat - 设库子集:
cellchat@DB <- CellChatDB.human(或 .mouse),可subsetDB限定信号类别,再subsetData - 过表达:
identifyOverExpressedGenes→identifyOverExpressedInteractions - 算概率:
computeCommunProb(质量作用定律)→filterCommunication(min.cells=10) - 通路聚合:
computeCommunProbPathway→aggregateNet(产出 net$count / net$weight) - 网络中心性:
netAnalysis_computeCentrality算发送/受体/中介/影响者;identifyCommunicationPatterns(NMF,k 由selectK肘部定) - 可视化:弦图
netVisual_circle/aggregate、热图netVisual_heatmap、气泡图netVisual_bubble - 跨条件:
mergeCellChat→compareInteractions/netVisual_diffInteraction/rankNet
指令
安装(CRAN 常滞后,从 GitHub 装):
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")
BiocManager::install(c("BiocNeighbors", "ComplexHeatmap"))
devtools::install_github("jinworks/CellChat") # CellChat >= 2.0
install.packages(c("NMF","ggplot2","ggalluvial","igraph","dplyr","patchwork","circlize"))
数据要求:归一化表达矩阵(基因×细胞)+ 细胞分组标签向量。物种符号须匹配——人为全大写 HGNC(TGFB1),鼠为首字母大写 MGI(Tgfb1)。
示例
完整流程(Seurat 输入 → 弦图 + 气泡图):
library(CellChat); library(Seurat)
data.input <- GetAssayData(seurat_obj, assay="RNA", slot="data") # 对数归一化
meta <- data.frame(labels = Idents(seurat_obj), row.names = colnames(seurat_obj))
cellchat <- createCellChat(object=data.input, meta=meta, group.by="labels")
cellchat@DB <- CellChatDB.human # 或 CellChatDB.mouse
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
cellchat <- computeCommunProb(cellchat, type="triMean", # 最稳健的聚合
nboot=100, seed.use=42, population.size=TRUE)
cellchat <- filterCommunication(cellchat, min.cells=10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
print(cellchat@netP$pathways) # 显著通路名
# 导出 LR 级显著交互(p<0.05)
df.lr <- subsetCommunication(cellchat, slot.name="net")
write.csv(df.lr[df.lr$pval < 0.05, ], "cellchat_lr.csv", row.names=FALSE)
# 聚合弦图(计数 + 强度)
groupSize <- as.numeric(table(cellchat@idents))
par(mfrow=c(1,2))
netVisual_circle(cellchat@net$count, vertex.weight=groupSize, weight.scale=TRUE, title.name="Number of interactions")
netVisual_circle(cellchat@net$weight, vertex.weight=groupSize, weight.scale=TRUE, title.name="Interaction strength")
# 指定通路弦图 + 气泡图
netVisual_aggregate(cellchat, signaling="COLLAGEN", layout="chord")
netVisual_bubble(cellchat, signaling=c("COLLAGEN","MIF","VEGF"))
ggsave("bubble.pdf", width=10, height=8)
中心性与跨条件比较:
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name="netP")
netAnalysis_signalingRole_heatmap(cellchat, pattern="all") # 行=通路 列=细胞群
# 双条件:合并后比较
object.list <- list(Control=cellchat_ctrl, Disease=cellchat_disease)
cc <- mergeCellChat(object.list, add.names=names(object.list))
compareInteractions(cc, group=c(1,2), measure="weight")
netVisual_diffInteraction(cc, weight.scale=TRUE) # 增/减连接弦图
rankNet(cc, mode="comparison", stacked=TRUE, do.stat=TRUE) # 各条件特异通路
注意事项
- 输入必须是对数归一化值,不是原始计数(否则
computeCommunProb概率全 0);用subsetData()后确认nrow(cellchat@data.signaling) > 0。 - 基因命名匹配物种:人全大写 / 鼠首字母大写;混用会导致概率全 0。鼠数据用
CellChatDB.mouse。 - 关键参数:
type="triMean"(最严格,推荐)/truncatedMean(配trim);nboot默认 100,内存紧张可降到 50;population.size=TRUE对异质数据推荐;min.cells默认 10,小簇被丢可降到 5 或先合并稀有簇。 - net$count vs net$weight:count 是显著 LR 对数量,weight 是通讯概率之和(信息流)。高 count 低 weight = 多弱交互;高 weight 低 count = 少数主导通路。
- NMF 模式:
identifyCommunicationPatterns的k用selectK()肘部选,先试 k=2/3;不收敛多因 k 过高或数据过稀疏。 - 大数据/内存:≤30000 细胞/条件,或降
nboot;细胞群过多时弦图不可读,改用netVisual_heatmap或先把簇并成大类。 - 跨条件合并:
mergeCellChat前须setIdent()统一两对象的细胞群名levels(...@idents),否则报标签不匹配。 - 检查点:
saveRDS(cellchat, "cellchat.rds")保存完成对象,可视化/比较前先存盘。
互见
- related:
single-cell-rnaseq-analysis—— 先用 Scanpy/Seurat 完成质控、聚类与细胞类型注释,产出 CellChat 所需的分组标签 - related:
gene-set-enrichment-analysis—— 对富集通路做进一步功能解读 - related:
nextflow-pipeline-builder—— 把通讯分析纳入可复现的批量流程 - combines_with:
single-cell-rnaseq-analysis—— 上游注释 + 下游通讯推断构成完整 scRNA-seq 解读链
本条采编自 jaechang-hits/SciAgent-Skills(CC-BY-4.0),适配重写而非逐字翻译。