1. 合并多组数据
library(CellChat)
cellchat.1 <- readRDS("group1.cellchat.rds")
cellchat.2 <- readRDS("group2.cellchat.rds")
object.list <- list(Group1 = cellchat.1, Group2 = cellchat.2)
cellchat <- mergeCellChat(object.list, add.names = names(object.list))
saveRDS(cellchat,"cellchat.merged.rds")
2.绘制两组circle图
weight.max <- getMaxWeight(object.list, attribute = c("idents","count"))
par(mfrow = c(1,2), xpd=TRUE)
for (i in 1:length(object.list)) {
netVisual_circle(object.list[[i]]@net$count, weight.scale = T, remove.isolate = T,
label.edge= T, #在线上标记相互作用强度
edge.weight.max = weight.max[2],
sources.use = "Epithelial cells", #选择source细胞类型
targets.use = c("CD8 Teff","CD8 Tem","CD8 Tex","CD8 Tn"),
edge.width.max = 30, vertex.weight.max = 10,title.name = paste0(names(object.list)[i]))
}
3.绘制两组bubble图
# 将选择的lrpair以dataframe形式传递给参数
lr <- data.frame(interaction_name=c("SPP1_CD44","CDH1_KLRG1","CLEC2B_KLRB1"))
# pairLR.use <- extractEnrichedLR(cellchat, signaling = c("CCL","CXCL","FGF"))
bubble1 <- netVisual_bubble(cellchat,
pairLR.use = lr,
sources.use = "Epithelial cells",
targets.use = c("CD8 Teff","CD8 Tem","CD8 Tex","CD8 Tn"),
return.data = TRUE,
comparison = c(1, 2),
angle.x = 90)
print(bubble1$gg.obj)
更多详情,可查看官方说明Comparison_analysis_of_multiple_datasets