學習 CellChat 細胞間通訊分析
第一部分:CellChat對象的數(shù)據(jù)輸入&處理及初始化
[Reference] (https://github.com/sqjin/CellChat/blob/master/tutorial/CellChat-vignette.html)
1.加載R包
devtools::install_github("sqjin/CellChat")
library(CellChat)
library(patchwork)
library(ComplexHeatmap)
library(circlize)
library(NMF)
library(dplyr)
library(tidyverse)
options(stringsAsFactors = FALSE)

R包加載成功
2.導入教程數(shù)據(jù)
2.1 加載官方的教程數(shù)據(jù)
load(file = '../CellChat-master/data_humanSkin_CellChat.rda')
data.input = data_humanSkin$data # normalized data matrix
meta = data_humanSkin$meta
cell.use = rownames(meta)[meta$condition == "LS"]

加載數(shù)據(jù)是list
2.2 準備用于 CelChat 分析的輸入數(shù)據(jù)
data.input = data.input[, cell.use] #篩選使用的細胞后的表達矩陣
meta = meta[cell.use, ] #篩選使用的細胞后的Metadata
unique(meta$labels) # 查看細胞的標記類群
[1] Inflam. FIB FBN1+ FIB APOE+ FIB COL11A1+ FIB cDC2 LC
[7] Inflam. DC cDC1 CD40LG+ TC Inflam. TC TC NKT
12 Levels: APOE+ FIB FBN1+ FIB COL11A1+ FIB Inflam. FIB cDC1 cDC2 LC ... NKT
2.3 創(chuàng)建 CellChat 對象
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")

創(chuàng)建CellChat對象
> levels(cellchat@idents) # show factor levels of the cell labels
[1] "APOE+ FIB" "FBN1+ FIB" "COL11A1+ FIB" "Inflam. FIB"
[5] "cDC1" "cDC2" "LC" "Inflam. DC"
[9] "TC" "Inflam. TC" "CD40LG+ TC" "NKT"
2.4 設置互作的配體-受體數(shù)據(jù)庫
CellChatDB <- CellChatDB.human # 如果使用小鼠數(shù)據(jù)用CellChatDB.mouse
showDatabaseCategory(CellChatDB) # 展示數(shù)據(jù)庫的結構

展示數(shù)據(jù)庫的結構
dplyr::glimpse(CellChatDB$interaction)
Rows: 1,939
Columns: 11
$ interaction_name <chr> "TGFB1_TGFBR1_TGFBR2", "TGFB2_TGFBR1_TGFBR2", "T…
$ pathway_name <chr> "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", …
$ ligand <chr> "TGFB1", "TGFB2", "TGFB3", "TGFB1", "TGFB1", "TG…
$ receptor <chr> "TGFbR1_R2", "TGFbR1_R2", "TGFbR1_R2", "ACVR1B_T…
$ agonist <chr> "TGFb agonist", "TGFb agonist", "TGFb agonist", …
$ antagonist <chr> "TGFb antagonist", "TGFb antagonist", "TGFb anta…
$ co_A_receptor <chr> "", "", "", "", "", "", "", "", "", "", "", "", …
$ co_I_receptor <chr> "TGFb inhibition receptor", "TGFb inhibition rec…
$ evidence <chr> "KEGG: hsa04350", "KEGG: hsa04350", "KEGG: hsa04…
$ annotation <chr> "Secreted Signaling", "Secreted Signaling", "Sec…
$ interaction_name_2 <chr> "TGFB1 - (TGFBR1+TGFBR2)", "TGFB2 - (TGFBR1+TGFB…
2.5 使用互作的配體-受體數(shù)據(jù)庫子集進行細胞間通訊分析
CellChatDB.use <- subsetDB(CellChatDB, search = "Secreted Signaling") # 使用Secreted Signaling 用于分析
CellChatDB.use <- CellChatDB # 使用默認的數(shù)據(jù)庫
cellchat@DB <- CellChatDB.use # 在CellChat對象中設置使用的數(shù)據(jù)庫

CellChat對象中設置使用的數(shù)據(jù)庫
2.6 用于細胞間通訊分析表達數(shù)據(jù)的預處理
# 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 = 1) # do parallel
> cellchat <- identifyOverExpressedGenes(cellchat)
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=01s
> cellchat <- identifyOverExpressedInteractions(cellchat)
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
2.7投射基因達標矩陣數(shù)據(jù)到PPI網絡中(可選操作步驟)
cellchat <- projectData(cellchat, PPI.human)