BioF3 FigCode · SCI 绘图代码集
细胞通讯气泡图(CellChat Bubble)
分类:网络与互作 | 依赖包:CellChat、ggplot2
解决的生物学问题
哪些细胞类型在用哪些信号通路对话?通讯方向是什么?
应用场景
- 肿瘤微环境免疫细胞通讯
- 组织发育中信号传递
- CAR-T 治疗后的免疫重塑
- 空间转录组配套通讯分析
输入数据格式
CellChat 对象(CellChat::createCellChat 输出后跑完 computeCommunProb)
关键参数
- sources.use(发送方细胞类型索引)
- targets.use(接收方)
- signaling(指定信号通路名,如 "TGFb")
- sort.by.source = TRUE(按发送方分组)
- remove.isolate = TRUE(去掉无通讯的对)
快速开始
1. 直接在线运行
打开 FigCode 在线绘图,点击本工具卡片的"在线绘图"按钮即可用内置示例数据出图,零环境配置。
2. 本地复现
下载脚本和示例数据,本地 RStudio 运行:
# 下载
curl -O https://<your-site>/figcode/scripts/cellchat-bubble.R
curl -O https://<your-site>/figcode/data/cellchat-bubble.csv
3. 安装依赖
# CRAN 包
install.packages(c("ggplot2"))
# Bioconductor 包(如需)
# BiocManager::install(c())
完整代码
library(CellChat)
library(ggplot2)
# --- Demo: load packaged toy CellChat object ---
# 真实使用时把它替换成自己跑出来的 cellchat 对象
data(cellchat, package = "CellChat")
# --- Bubble plot for selected source/target pairs ---
# 选 2 个发送方 vs 4 个接收方
netVisual_bubble(
cellchat,
sources.use = c(1, 2),
targets.use = c(3, 4, 5, 6),
remove.isolate = TRUE,
angle.x = 45,
font.size = 9,
title.name = "Cell-cell Communication"
)
替换为自己的数据
脚本中以 # --- Demo data --- 标注的段落是示例数据生成代码。替换为自己的数据时,保持列名一致即可:
- 输入格式:CellChat 对象(CellChat::createCellChat 输出后跑完 computeCommunProb)
- 使用
read.csv()/readRDS()读取本地文件
延伸阅读
- 相关教程:细胞通讯气泡图 完整流程
- 出现 bug?欢迎在 FigCode 页面 点击对应卡片,在评论区留言。