BioF3 FigCode · SCI 绘图代码集

细胞通讯气泡图(CellChat Bubble)

导出日期:2026年6月27日

分类:网络与互作 | 依赖包:CellChat、ggplot2

解决的生物学问题

哪些细胞类型在用哪些信号通路对话?通讯方向是什么?

应用场景

输入数据格式

CellChat 对象(CellChat::createCellChat 输出后跑完 computeCommunProb)

关键参数

快速开始

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 --- 标注的段落是示例数据生成代码。替换为自己的数据时,保持列名一致即可:

延伸阅读