單細胞轉錄組-CellChat細胞相互作用分析

所有信息可以查看github
教程有很多虽界,最基本的是Inference and analysis of cell-cell communication using CellChat
如果有分組,想做比較分析可以看這個Comparison analysis of multiple datasets using CellChat

輸入

首先需要你已經(jīng)做好了細胞分群臭家,得到了seurat object妹萨。這時谚攒,需要創(chuàng)建一個CellChat對象。

# Part I: Data input & processing and initialization of CellChat object
data.input = seuratObject[["RNA"]]@data  # normalized data matrix
meta = dat.sub@meta.data # a dataframe with rownames containing cell mata data
meta$labels <- meta$celltype # celltype interaction analysis
cellchat <- CellChat::createCellChat(object = data.input, meta = meta, group.by = "labels")
cellchat <- setIdent(cellchat, ident.use = "labels") # set "labels" as default cell identity

分析

groupSize <- as.numeric(table(cellchat@idents)) # number of cells in each cell group
# use CellChatDB.mouse if running on mouse data
# simply use the default CellChatDB
# set the used database in the object
cellchat@DB <- CellChatDB.mouse
# subset the expression data of signaling genes for saving computation cost
cellchat <- subsetData(cellchat) # This step is necessary even if using the whole database
future::plan("multiprocess", workers = 4) # do parallel
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
# project gene expression data onto PPI network (optional)
cellchat <- projectData(cellchat, PPI.human)
  
# Part2: Inference of cell-cell conmmunication network
cellchat <- computeCommunProb(cellchat)
# Filter out the cell-cell communication if there are only few number of cells in certain cell groups
cellchat <- filterCommunication(cellchat, min.cells = 10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)

可視化

aggregated cell-cell communication network

groupSize <- as.numeric(table(cellchat@idents))
par(mfrow = c(1,2), xpd=TRUE)
netVisual_circle(cellchat@net$count, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Number of interactions")
netVisual_circle(cellchat@net$weight, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")
image.png
mat <- cellchat@net$weight
par(mfrow = c(3,4), xpd=TRUE)
for (i in 1:nrow(mat)) {
  mat2 <- matrix(0, nrow = nrow(mat), ncol = ncol(mat), dimnames = dimnames(mat))
  mat2[i, ] <- mat[i, ]
  netVisual_circle(mat2, vertex.weight = groupSize, weight.scale = T, edge.weight.max = max(mat), title.name = rownames(mat)[I])
}
image.png

heatmap

可以選擇展示某個pathway,可也有不選signaling參數(shù)晒旅,展示所有的pathway。

pathways.show <- c("CXCL") 
par(mfrow=c(1,1))
netVisual_heatmap(cellchat, signaling = pathways.show, color.heatmap = "Reds")
image.png

數(shù)據(jù)之間做比較

這時候需要分別跑兩個組的CellChat分析汪诉,然后進行對比分析废恋。

dir.create("Comparison")
cellchat.Control <- readRDS("Control.cellchat.result.ImmuneCell.rds")
cellchat.Treatment <- readRDS("Treatment.cellchat.result.ImmuneCell.rds")
object.list <- list(Control= cellchat.Control, MC = cellchat.Treatment)
cellchat <- mergeCellChat(object.list, add.names = names(object.list),cell.prefix = TRUE)


# define a positive dataset, i.e., the dataset with positive fold change against the other dataset
pos.dataset = "Treatment"
# define a char name used for storing the results of differential expression analysis
features.name = pos.dataset
# perform differential expression analysis
cellchat <- identifyOverExpressedGenes(cellchat, group.dataset = "datasets", pos.dataset = pos.dataset, features.name = features.name, only.pos = TRUE)
#> Use the joint cell labels from the merged CellChat object
# map the results of differential expression analysis onto the inferred cell-cell communications to easily manage/subset the ligand-receptor pairs of interest
net <- netMappingDEG(cellchat, features.name = features.name)

然后就可以繪制各種圖啦
相互作用數(shù)量和強度統(tǒng)計柱狀圖

gg1 <- compareInteractions(cellchat, show.legend = F, group = c(1,2))
gg2 <- compareInteractions(cellchat, show.legend = F, group = c(1,2), measure = "weight")
gg1 + gg2

相互作用數(shù)量和強度的差異網(wǎng)絡圖

par(mfrow = c(1,2), xpd=TRUE)
netVisual_diffInteraction(cellchat, weight.scale = T)
netVisual_diffInteraction(cellchat, weight.scale = T, measure = "weight")
image.png

相互作用數(shù)量、強度的差異熱圖扒寄,這個圖文章中用的比較多鱼鼓,也比較直觀

gg1 <- netVisual_heatmap(cellchat)
#> Do heatmap based on a merged object
gg2 <- netVisual_heatmap(cellchat, measure = "weight")
#> Do heatmap based on a merged object
gg1 + gg2
image.png

分別畫兩個數(shù)據(jù)集的相互作用強度

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, label.edge= F, edge.weight.max = weight.max[2], edge.width.max = 12, title.name = paste0("Number of interactions - ", names(object.list)[I]))
}
image.png

數(shù)據(jù)結構

待補充

總結

cellchat對象中可以獲得ligand-receptor對兒的很多信息,要好好掌握數(shù)據(jù)結構该编,靈活應用迄本。

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市课竣,隨后出現(xiàn)的幾起案子嘉赎,更是在濱河造成了極大的恐慌,老刑警劉巖于樟,帶你破解...
    沈念sama閱讀 217,185評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件曹阔,死亡現(xiàn)場離奇詭異,居然都是意外死亡隔披,警方通過查閱死者的電腦和手機赃份,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,652評論 3 393
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人抓韩,你說我怎么就攤上這事纠永。” “怎么了谒拴?”我有些...
    開封第一講書人閱讀 163,524評論 0 353
  • 文/不壞的土叔 我叫張陵尝江,是天一觀的道長。 經(jīng)常有香客問我英上,道長炭序,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,339評論 1 293
  • 正文 為了忘掉前任苍日,我火速辦了婚禮惭聂,結果婚禮上,老公的妹妹穿的比我還像新娘相恃。我一直安慰自己辜纲,他們只是感情好,可當我...
    茶點故事閱讀 67,387評論 6 391
  • 文/花漫 我一把揭開白布拦耐。 她就那樣靜靜地躺著耕腾,像睡著了一般。 火紅的嫁衣襯著肌膚如雪杀糯。 梳的紋絲不亂的頭發(fā)上扫俺,一...
    開封第一講書人閱讀 51,287評論 1 301
  • 那天,我揣著相機與錄音固翰,去河邊找鬼牵舵。 笑死,一個胖子當著我的面吹牛倦挂,可吹牛的內(nèi)容都是我干的畸颅。 我是一名探鬼主播,決...
    沈念sama閱讀 40,130評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼方援,長吁一口氣:“原來是場噩夢啊……” “哼没炒!你這毒婦竟也來了?” 一聲冷哼從身側響起犯戏,我...
    開封第一講書人閱讀 38,985評論 0 275
  • 序言:老撾萬榮一對情侶失蹤送火,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后先匪,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體种吸,經(jīng)...
    沈念sama閱讀 45,420評論 1 313
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,617評論 3 334
  • 正文 我和宋清朗相戀三年呀非,在試婚紗的時候發(fā)現(xiàn)自己被綠了坚俗。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片镜盯。...
    茶點故事閱讀 39,779評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖猖败,靈堂內(nèi)的尸體忽然破棺而出速缆,到底是詐尸還是另有隱情,我是刑警寧澤恩闻,帶...
    沈念sama閱讀 35,477評論 5 345
  • 正文 年R本政府宣布艺糜,位于F島的核電站,受9級特大地震影響幢尚,放射性物質發(fā)生泄漏破停。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,088評論 3 328
  • 文/蒙蒙 一尉剩、第九天 我趴在偏房一處隱蔽的房頂上張望真慢。 院中可真熱鬧,春花似錦边涕、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,716評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至宠蚂,卻和暖如春式撼,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背求厕。 一陣腳步聲響...
    開封第一講書人閱讀 32,857評論 1 269
  • 我被黑心中介騙來泰國打工著隆, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人呀癣。 一個月前我還...
    沈念sama閱讀 47,876評論 2 370
  • 正文 我出身青樓美浦,卻偏偏與公主長得像,于是被迫代替她去往敵國和親项栏。 傳聞我的和親對象是個殘疾皇子浦辨,可洞房花燭夜當晚...
    茶點故事閱讀 44,700評論 2 354

推薦閱讀更多精彩內(nèi)容