学习CellChat细胞间通讯分析2

2022-05-22  本文已影响0人  吹不散的烽烟

学习 CellChat 细胞间通讯分析

第一部分:CellChat对象的数据输入&处理及初始化

[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.导入教程数据
2.1 加载官方的教程数据
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"]
加载数据是list
2.2 准备用于 CelChat 分析的输入数据
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 创建 CellChat 对象
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
创建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 设置互作的配体-受体数据库
CellChatDB <- CellChatDB.human  # 如果使用小鼠数据用CellChatDB.mouse
showDatabaseCategory(CellChatDB) # 展示数据库的结构
展示数据库的结构
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 使用互作的配体-受体数据库子集进行细胞间通讯分析
CellChatDB.use <- subsetDB(CellChatDB, search = "Secreted Signaling") # 使用Secreted Signaling 用于分析
CellChatDB.use <- CellChatDB # 使用默认的数据库
cellchat@DB <- CellChatDB.use # 在CellChat对象中设置使用的数据库
CellChat对象中设置使用的数据库
2.6 用于细胞间通讯分析表达数据的预处理
# 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投射基因达标矩阵数据到PPI网络中(可选操作步骤)
cellchat <- projectData(cellchat, PPI.human)
上一篇 下一篇

猜你喜欢

热点阅读