singlecell-cellchat-cn

Perform cell–cell communication analysis on single-cell or spatial transcriptomics data using CellChat, covering single-dataset workflows, pathway-level inference, visualization, two-condition comparisons, NMF communication pattern discovery, and spatial CCC analysis.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "singlecell-cellchat-cn" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5df14d02e044f119ead50f797bc54c2fda3c98e0903b6371881b172411501a8a. Verify the upstream source and version against https://skillhub.cn/skills/org-ekt13cme/singlecell-cellchat before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Perform cell–cell communication analysis on single-cell or spatial transcriptomics data using CellChat, covering single-dataset workflows, pathway-level inference, visualization, two-condition comparisons, NMF communication pattern discovery, and spatial CCC analysis.

0 Downloads

Introduction source: third_party · org-ekt13cme · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: "singlecell-cellchat-cn"
description: "使用 CellChat 对单细胞或空间转录组数据进行细胞间通讯分析。涵盖单数据集流程、通路水平推断、可视化、双条件比较、NMF 通讯模式识别和空间 CCC 分析。"
alwaysAllow: ["Bash"]

singlecell-cellchat-cn Skill

指导用户使用 CellChat(R / Seurat)进行细胞间通讯分析(cell-cell communication, CCC)。CellChat 能够将配体-受体(ligand-receptor, LR)相互作用聚合到 信号通路层面,提供丰富的内置可视化,并且非常适合 双条件差异通讯比较 和 通讯模式识别。

什么时候适合使用 CellChat

当用户有以下需求时,优先考虑 CellChat:

  • 希望分析 信号通路层级 的细胞通讯,而不仅仅是单个配体-受体对
  • 需要丰富的内置可视化,例如 circle plot、chord diagram、heatmap、river plot
  • 想比较两个条件下的细胞通讯差异,例如 Control vs Disease
  • 需要进行通讯模式识别,例如基于 NMF 的 outgoing / incoming pattern 分析
  • 需要分析空间转录组中的细胞通讯
    • CellChat v2:适合 Visium 等 spot-level 空间数据
    • CellChat v3 / SpatialCellChat:适合单细胞分辨率空间数据
  • 分析流程主要基于 R / Seurat

在写代码前,应先向用户确认以下信息:

  1. 物种:human 还是 mouse,对应 CellChatDB.human 或 CellChatDB.mouse
  2. Seurat 版本:Seurat v5 和 v4 的表达矩阵读取方式不同
  3. 分析类型:单个数据集分析,还是两个条件 / 多数据集比较
  4. 数据类型:普通单细胞数据,还是空间转录组数据

这些信息会决定后续使用哪条工作流,以及关键参数如何设置。

安装

devtools::install_github("jinworks/CellChat")

# 如果是单细胞分辨率空间通讯分析,可安装:
# devtools::install_github("jinworks/SpatialCellChat")

单数据集 CellChat 分析流程

Step 1 — 创建 CellChat 对象

Seurat v5 推荐写法:

library(CellChat)
library(patchwork)

data.input = seurat_obj[["RNA"]]$data
labels = Idents(seurat_obj)
meta = data.frame(labels = labels, row.names = names(labels))

cellchat = createCellChat(
  object = data.input,
  meta = meta,
  group.by = "labels"
)

也可以直接从 Seurat 对象创建:

cellchat = createCellChat(
  object = seurat_obj,
  group.by = "ident",
  assay = "RNA"
)

注意:

  • Seurat v5 使用 seurat_obj[["RNA"]]$data
  • Seurat v4 常见写法是 seurat_obj[["RNA"]]@data
  • 不要使用 integrated assay,因为 integrated assay 中可能包含负值,不适合 CellChat

Step 2 — 设置数据库

CellChatDB = CellChatDB.human
# 或者:
# CellChatDB = CellChatDB.mouse

CellChatDB.use = subsetDB(CellChatDB)
cellchat@DB = CellChatDB.use

如果只想分析某一类信号,例如分泌型信号:

CellChatDB.use = subsetDB(
  CellChatDB,
  search = "Secreted Signaling",
  key = "annotation"
)

cellchat@DB = CellChatDB.use

说明:

  • subsetDB(CellChatDB) 默认使用 protein signaling
  • CellChatDB v2 中的 Non-protein Signaling 部分依赖估计表达,标准分析中通常建议先排除

Step 3 — 数据预处理

cellchat = subsetData(cellchat)

future::plan("multisession", workers = 4)

cellchat = identifyOverExpressedGenes(cellchat)
cellchat = identifyOverExpressedInteractions(cellchat)

注意:

  • subsetData() 是必须步骤,即使使用完整数据库也要运行
  • identifyOverExpressedGenes() 用于识别每个细胞群中过表达的基因
  • identifyOverExpressedInteractions() 用于识别潜在过表达的配体-受体相互作用

Step 4 — 细胞通讯概率推断

cellchat = computeCommunProb(
  cellchat,
  type = "triMean"
)

cellchat = filterCommunication(
  cellchat,
  min.cells = 10
)

cellchat = computeCommunProbPathway(cellchat)
cellchat = aggregateNet(cellchat)

参数说明:

  • type = "triMean":较保守,约等价于 25% trimmed mean
  • type = "truncatedMean", trim = 0.1:更宽松,适合找回低表达但可能有生物学意义的通路
  • filterCommunication(min.cells = 10):过滤细胞数过少的细胞群之间的通讯
  • computeCommunProbPathway():将 LR 对聚合到 pathway 层面
  • aggregateNet():生成细胞群之间的通讯数量和通讯强度矩阵

Step 5 — 系统层面分析

cellchat = netAnalysis_computeCentrality(
  cellchat,
  slot.name = "netP"
)

该步骤用于计算各细胞群在不同信号通路中的发送者、接收者、中介者、影响者等角色。

结果提取

提取 LR 层面的通讯结果

df.net = subsetCommunication(cellchat)

提取 pathway 层面的通讯结果

df.netP = subsetCommunication(
  cellchat,
  slot.name = "netP"
)

按来源细胞和目标细胞筛选

subsetCommunication(
  cellchat,
  sources.use = c(1, 2),
  targets.use = c(4, 5)
)

按信号通路筛选

subsetCommunication(
  cellchat,
  signaling = c("WNT", "TGFb")
)

常用 CellChat 对象槽位

cellchat@net$prob
cellchat@net$pval
cellchat@net$count
cellchat@net$weight
cellchat@netP$prob

说明:

  • cellchat@net$prob:source × target × LR-pair 的三维通讯概率数组
  • cellchat@net$pval:对应的显著性 p 值
  • cellchat@net$count:细胞群之间显著通讯数量矩阵
  • cellchat@net$weight:细胞群之间通讯强度矩阵
  • cellchat@netP$prob:source × target × pathway 的三维通路通讯概率数组

可视化

总体通讯网络

groupSize = as.numeric(table(cellchat@idents))

netVisual_circle(
  cellchat@net$count,
  vertex.weight = groupSize,
  weight.scale = TRUE
)

netVisual_circle(
  cellchat@net$weight,
  vertex.weight = groupSize,
  weight.scale = TRUE
)

netVisual_heatmap(
  cellchat,
  measure = "weight"
)

说明:

  • cellchat@net$count 展示细胞群之间的通讯数量
  • cellchat@net$weight 展示细胞群之间的通讯强度
  • netVisual_heatmap() 可快速查看细胞群间通讯强弱

特定信号通路可视化

pathways.show = c("CXCL")

netVisual_aggregate(
  cellchat,
  signaling = pathways.show,
  vertex.receiver = seq(1, 4)
)

netVisual_aggregate(
  cellchat,
  signaling = pathways.show,
  layout = "circle"
)

netVisual_aggregate(
  cellchat,
  signaling = pathways.show,
  layout = "chord"
)

netAnalysis_contribution(
  cellchat,
  signaling = pathways.show
)

说明:

  • layout = "circle":环形图
  • layout = "chord":弦图
  • netAnalysis_contribution():展示某个 pathway 中不同 LR 对的贡献

Bubble plot

netVisual_bubble(
  cellchat,
  sources.use = 4,
  targets.use = c(5:11),
  remove.isolate = FALSE
)

netVisual_bubble(
  cellchat,
  sources.use = 4,
  targets.use = c(5:11),
  signaling = c("CCL", "CXCL")
)

Bubble plot 适合展示指定 source cell type 到 target cell type 的配体-受体通讯。

信号角色分析

netAnalysis_signalingRole_scatter(cellchat)

netAnalysis_signalingRole_heatmap(
  cellchat,
  pattern = "outgoing"
)

netAnalysis_signalingRole_heatmap(
  cellchat,
  pattern = "incoming"
)

说明:

  • outgoing:哪些细胞群主要作为信号发送者
  • incoming:哪些细胞群主要作为信号接收者
  • scatter plot 可展示不同细胞群的发送和接收强度

通讯模式识别:NMF

library(NMF)
library(ggalluvial)

selectK(
  cellchat,
  pattern = "outgoing"
)

cellchat = identifyCommunicationPatterns(
  cellchat,
  pattern = "outgoing",
  k = 4
)

netAnalysis_river(
  cellchat,
  pattern = "outgoing"
)

netAnalysis_dot(
  cellchat,
  pattern = "outgoing"
)

说明:

  • selectK() 用于选择合适的模式数量 k
  • identifyCommunicationPatterns() 使用 NMF 识别通讯模式
  • netAnalysis_river() 展示细胞群、信号通路和通讯模式之间的关系
  • netAnalysis_dot() 用 dot plot 展示模式特征

多数据集 / 双条件比较分析

例如比较 Control 和 Disease:

object.list = list(
  Ctrl = cellchat.ctrl,
  Disease = cellchat.disease
)

cellchat = mergeCellChat(
  object.list,
  add.names = names(object.list)
)

比较整体通讯数量或强度

compareInteractions(
  cellchat,
  show.legend = FALSE,
  group = c(1, 2)
)

差异通讯网络

netVisual_diffInteraction(
  cellchat,
  weight.scale = TRUE
)

说明:

  • 红色通常表示 dataset 2 中增强的通讯
  • 蓝色通常表示 dataset 2 中减弱的通讯

比较不同信号通路的整体强度

gg1 = rankNet(
  cellchat,
  mode = "comparison",
  stacked = TRUE,
  do.stat = TRUE
)

gg2 = rankNet(
  cellchat,
  mode = "comparison",
  stacked = FALSE,
  do.stat = TRUE
)

gg1 + gg2

条件比较下的 bubble plot

netVisual_bubble(
  cellchat,
  sources.use = 4,
  targets.use = c(5:11),
  comparison = c(1, 2),
  max.dataset = 2,
  remove.isolate = TRUE
)

基于 DEG 的上调 / 下调配体-受体分析

pos.dataset = "Disease"
features.name = paste0(pos.dataset, ".merged")

cellchat = identifyOverExpressedGenes(
  cellchat,
  group.dataset = "datasets",
  pos.dataset = pos.dataset,
  features.name = features.name,
  only.pos = FALSE,
  thresh.pc = 0.1,
  thresh.fc = 0.05,
  thresh.p = 0.05
)

net = netMappingDEG(
  cellchat,
  features.name = features.name,
  variable.all = TRUE
)

net.up = subsetCommunication(
  cellchat,
  net = net,
  datasets = "Disease",
  ligand.logFC = 0.05
)

net.down = subsetCommunication(
  cellchat,
  net = net,
  datasets = "Ctrl",
  ligand.logFC = -0.05
)

说明:

  • net.up:Disease 中上调的配体相关通讯
  • net.down:Ctrl 中相对更高、Disease 中下降的通讯
  • 阈值如 thresh.fc、thresh.p 可根据数据情况调整

空间转录组分析流程:CellChat v2 / Visium

准备空间坐标

spatial.locs = Seurat::GetTissueCoordinates(
  visium.obj,
  scale = NULL,
  cols = c("imagerow", "imagecol")
)

读取 scale factor

scalefactors = jsonlite::fromJSON("scalefactors_json.json")

spot.size = 65
conversion.factor = spot.size / scalefactors$spot_diameter_fullres

spatial.factors = data.frame(
  ratio = conversion.factor,
  tol = spot.size / 2
)

构建 metadata

meta = data.frame(
  labels = Idents(visium.obj),
  samples = "sample1",
  row.names = names(Idents(visium.obj))
)

注意:

  • 空间数据的 meta 中必须包含 samples 列
  • 即使只有一个样本,也需要写 samples = "sample1"

创建空间 CellChat 对象

cellchat = createCellChat(
  object = data.input,
  meta = meta,
  group.by = "labels",
  datatype = "spatial",
  coordinates = spatial.locs,
  spatial.factors = spatial.factors
)

计算空间通讯概率

cellchat = computeCommunProb(
  cellchat,
  type = "truncatedMean",
  trim = 0.1,
  distance.use = TRUE,
  interaction.range = 250,
  scale.distance = 0.01,
  contact.dependent = TRUE,
  contact.range = 100
)

参数说明:

  • distance.use = TRUE:考虑空间距离衰减
  • interaction.range = 250:分泌型信号的最大扩散范围,单位通常为微米
  • contact.dependent = TRUE:考虑接触依赖型通讯
  • contact.range = 100:Visium 数据常用值
  • 单细胞分辨率空间数据中,contact.range 可考虑使用约 10 微米

关键参数

参数 常用值 说明
type "triMean" / "truncatedMean" triMean 更保守;truncatedMean 更宽松
trim 0-0.25 仅用于 truncatedMean
population.size TRUE / FALSE 非分选细胞常用 TRUE;FACS 分选数据可用 FALSE
nboot 约 100 置换次数,用于估计 p 值;快速测试可设为 20
distance.use TRUE / FALSE 空间分析中是否考虑距离
interaction.range 约 250 微米 分泌型信号最大作用范围
contact.range Visium 约 100;单细胞空间约 10 接触依赖型通讯范围

常见问题与排查重点

  1. 不要使用 Seurat 的 integrated assay

    • integrated assay 可能有负值
    • 推荐使用 RNA 或 SCT
  2. 注意 Seurat v5 API 变化

    • Seurat v5:seurat_obj[["RNA"]]$data
    • Seurat v4:seurat_obj[["RNA"]]@data
  3. 必须运行 subsetData()

    • 即使使用完整数据库,也需要执行
  4. triMean 可能过滤掉低表达信号

    • 如果某些预期通路缺失,可尝试:
      computeCommunProb(
      cellchat,
      type = "truncatedMean",
      trim = 0.1
      )
  5. CellChatDB v2 的 Non-protein Signaling 需要谨慎

    • 标准分析建议先用 subsetDB(CellChatDB) 排除非蛋白信号
  6. 旧版本 CellChat 对象需要更新

    cellchat = updateCellChat(cellchat)
  7. 空间数据 meta 必须包含 samples 列

    • 即使只有一个样本也必须包含
  8. 空间分析中推荐设置 variable.both = FALSE

    • 即只要求 ligand 或 receptor 之一过表达
  9. 功能相似性分析要求不同数据集有相同细胞类型组成

    • 如果细胞类型组成不同,考虑 structural similarity 或 liftCellChat()
  10. CellChat v3 / SpatialCellChat 是独立包

    • 单细胞分辨率空间通讯建议使用 jinworks/SpatialCellChat

推荐工作流总结

  1. 先确认物种、Seurat 版本、单数据集还是双条件比较、是否为空间数据
  2. 从 RNA 或 SCT assay 构建 CellChat 对象,避免使用 integrated
  3. 设置 CellChatDB.human 或 CellChatDB.mouse
  4. 运行:
    subsetData()
    identifyOverExpressedGenes()
    identifyOverExpressedInteractions()
  5. 推断通讯:
    computeCommunProb()
    filterCommunication()
    computeCommunProbPathway()
    aggregateNet()
  6. 进行系统分析:
    netAnalysis_computeCentrality()
  7. 可视化:
    • circle plot
    • heatmap
    • pathway-specific network
    • bubble plot
    • signaling role scatter / heatmap
    • NMF river plot / dot plot
  8. 如果是双条件比较:
    • 分别构建两个 CellChat 对象
    • 使用 mergeCellChat()
    • 运行 compareInteractions()、netVisual_diffInteraction()、rankNet() 和差异 LR 分析

Current listing version

1.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的 CellChat 分析工作流,涵盖单数据集、双条件比较、空间转录组等核心场景
  • 针对生物信息学研究者的明确需求,实用价值高
Trigger Precision92/100

Highlights

  • 触发描述完整覆盖通路层级分析、可视化、NMF 模式识别等关键能力
  • 前置确认项(物种、Seurat 版本、分析类型)清晰,边界明确
Structure and Standards88/100

Areas to improve

  • 文档长度略超建议 Reported severity: Minor

    SKILL.md 约 600 行,略超 500 行建议值

    Recommendation: 可考虑将部分代码示例或参数表拆分为独立参考文件,但当前信息密度高,影响较小

Highlights

  • 步骤划分清晰,从对象创建到可视化形成完整闭环
  • frontmatter 完整,alwaysAllow 合理设置为 Bash
Execution Reliability90/100

Highlights

  • 关键异常场景覆盖全面(Seurat 版本差异、integrated assay 警告、空间数据 samples 列)
  • 参数说明详细,包含 triMean/truncatedMean 选择建议及空间分析距离参数
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.