1. 合并多組數(shù)據(jù)
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, #在線上標(biāo)記相互作用強(qiáng)度
edge.weight.max = weight.max[2],
sources.use = "Epithelial cells", #選擇source細(xì)胞類(lèi)型
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形式傳遞給參數(shù)
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)
更多詳情,可查看官方說(shuō)明Comparison_analysis_of_multiple_datasets