require(CellChat))devtools::install_local("CellChat-master/")if(! subsetData(cellchat) dim(cellchat@data.signaling) 开始计算cellchat <- identifyOverExpressedGenes(cellchat ) # 识别过表达基因cellchat <- identifyOverExpressedInteractions(cellchat) # 识别配体-受体对cellchat <- projectData( cellchat, PPI.human)#慢 将配体、受体投射到PPI网络cellchat <- smoothData(cellchat, adj = PPI.human) #v2版本的cellchat <- computeCommunProb(cellchat) #慢 推测细胞通讯网络cellchat <- computeCommunProbPathway(cellchat)cellchat <-
<- subsetData(cellchat) dim(cellchat@data.signaling) ## [1] 356 13926 3.细胞通讯网络分析 # 识别过表达基因 cellchat <- identifyOverExpressedGenes(cellchat) # 识别配体-受体对 cellchat <- identifyOverExpressedInteractions(cellchat <- projectData(cellchat, PPI.human)#慢 ## 推测细胞通讯网络 cellchat <- computeCommunProb(cellchat) #慢 ## triMean <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet(cellchat) 4.画图展示 分析出来的重要信号通路如下 cellchat (cellchat, pattern = "outgoing", k = nPatterns) #传入 cellchat <- identifyCommunicationPatterns(cellchat
当然,我们可以用str来看,就是有点冗长: > str(cellchat) Formal class 'CellChat' [package "CellChat"] with 14 slots .. cellchat <- addMeta(cellchat, meta = identity, meta.name = "labels") cellchat <- setIdent(cellchat, ident.use cellchat <- identifyOverExpressedGenes(cellchat) cellchat <- identifyOverExpressedInteractions(cellchat cellchat <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet(cellchat) 让我们看看这结果。 @netP$similarity) head(cellchat@net$count) head(cellchat@net$prob) head(cellchat@net$sum) head(cellchat
因为github连接不稳定,所以想了其他办法把CellChat包从github镜像到jihulab.com,再从jihulab.com克隆下来,然后用pak::local_install安装,如果网络可以 ,可以直接用pak::pkg_install("sqjin/CellChat")安装install.packages("pak")using(pak)pkgs <- c("BiocNeighbors", ")git clone https://jihulab.com/BioQuest/cellchat.gitpak::local_install("cellchat")# pak::local_install ("CellChat-master", dependencies = TRUE)Python环境mamba create -n SC && mamba activate SCmamba install _1.R -hUsage: CellChat_1.R [options] Description: CellChat pre!
上一篇学习了用cellchat进行单数据集的细胞通讯分析,接下来学习不同可视化方式。 注: 上一篇忘写保存cellchat对象的代码,在cellchat <- aggregateNet(cellchat)这步之后即可保存供后续可视化操作: #保存数据 readr::write_rds(cellchat , 'data/cellchat_pbmc3k.rds') 可视化方式: 对于单数据集的细胞通讯分析,我们一般会先看测序样本中所有类型的细胞间相互作用的数量和强度,和感兴趣的细胞类型与哪些细胞相互作用较多 ) cellchat <- read_rds("data/cellchat_pbmc3k.rds") # 查看各种细胞类型的索引,用于后面做图的vertex.receiver参数 levels(cellchat 参考资料: cellchat官方教程(https://github.com/sqjin/CellChat)
回顾——细胞通讯网络构建 前面的帖子(CellChat学习笔记【一】——通讯网络构建)中我们已经成功地进行了细胞间通讯网络的构建,总的来看借助下面简易的分析流程即可完成: library(CellChat , workers = 4) cellchat <- subsetData(cellchat) ##save time and memory cellchat <- identifyOverExpressedGenes (cellchat) cellchat <- identifyOverExpressedInteractions(cellchat) cellchat <- computeCommunProb(cellchat ) cellchat <- filterCommunication(cellchat, min.cells = 10) ##pathway level cellchat <- computeCommunProbPathway (cellchat) cellchat <- aggregateNet(cellchat) 今天继续介绍: (1)我们如何来理解这些分析结果; (2)我们如何将这些结果有效地展示出来,也就是可视化。
最初接触这个R包是去年年中,想做细胞间相互作用,又不会python,正好看到周老师的推文,就跟着学了学,CellChat:细胞间相互作用分析利器,当时CellChat包还是0.0.1版本,里面有不少小bug , group.by = "labels") cellchat <- addMeta(cellchat, meta = meta)##增加其他meta信息 cellchat <- setIdent( 对表达数据做进一步预处理,节省算力 cellchat <- subsetData(cellchat) cellchat <- identifyOverExpressedGenes(cellchat ) Part 2:胞间通讯网络的预测及构建 计算胞间通讯概率,预测通讯网络 cellchat <- computeCommunProb(cellchat)###这应该是核心的一行代码 cellchat 在信号通路的水平进一步推测胞间通讯,计算聚合网络 cellchat <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet(cellchat
第四部分:使用层次结构图、圆图或和弦图可视比较细胞-细胞通信 第五部分:比较不同数据集之间的信号基因表达分布 保存合并的CellChat对象 CellChat 采用自上而下的方法,即从大局出发,然后对信号机制进行更详细的改进 /comparison' dir.create(data.dir) setwd(data.dir) 加载每个数据集的cellchat对象,然后合并在一起 用户需要在每个数据集上单独运行 CellChat ,然后将不同的 CellChat 对象合并在一起。 <- list(NL = cellchat.NL, LS = cellchat.LS) cellchat <- mergeCellChat(object.list, add.names = names 保存合并的cellchat对象 saveRDS(cellchat, file = "cellchat_comparisonAnalysis_humanSkin_NL_vs_LS.rds")
预处理见上一篇推文https://mp.weixin.qq.com/s/ZsUQogkqcPXkaNDIV8GhWg,本篇内容是合并两个处理好的CellChat对象,然后进行对比分析和可视化,因为有许多细节需要手动调整所以就不写成脚本了 A.加载R包、定义函数、建立文件夹using(data.table, tidyverse, CellChat, patchwork, reticulate, ComplexHeatmap)reticulate ::use_python("/opt/homebrew/Caskroom/mambaforge/base/envs/SC/bin/python")output_dir <- "CellChat"setwd 10, plot = p1 + p2)图片5.流行学习识别差异信号通路cc <- computeNetSimilarityPairwise(cc, type = "functional")cc <- CellChat attribute = x) par(mfrow = c(1, 2), xpd = TRUE) for (y in seq(length(cc_list))) { p <- CellChat
CellChat CellChat是一款2021年发表于Nature Communications的单细胞细胞通讯分析工具。 CellChat上游分析 安装 CellChat devtools::install_github("sqjin/CellChat") 细胞通讯分析 这里我们使用 pbmc3k 的公共数据集为例来一起学习如何利用 简单介绍一下CellChat数据的结构: str(cellchat) ## Formal class 'CellChat' [package "CellChat"] with 14 slots ## cellchat <- identifyOverExpressedGenes(cellchat) cellchat <- identifyOverExpressedInteractions(cellchat cellchat <- computeCommunProb(cellchat) cellchat <- filterCommunication(cellchat, min.cells = 10) 注意到为了获得更可信的细胞间通讯
上面是之前我们分享的数据集处理过程,今天我们来看看如何进行cellchat分析:1.批量运行多组cellchat 2.比较两组cellchat结果 今天是完整代码分享,如果想要使用其他示例数据,可以参考这个数据 cellchat <- subsetData(cellchat) cellchat <- identifyOverExpressedGenes(cellchat) cellchat <- identifyOverExpressedInteractions(cellchat) cellchat <- projectData(cellchat, PPI.mouse) cellchat <- computeCommunProb(cellchat) cellchat <- filterCommunication(cellchat, min.cells = 0) cellchat /cellchat/Control/cellchat_Control_.RData") ns=cellchat load("~/biye/ipf/gse104154/cellchat/cellchat
对象 cellchat <- createCellChat(data = data.input) cellchat <- addMeta(cellchat, meta = identity, meta.name 对象 cellchat@DB <- CellChatDB.use ##配体-受体分析 # 提取数据库支持的数据子集 cellchat <- subsetData(cellchat) # 识别过表达基因 (cellchat) # 将配体、受体投射到PPI网络 cellchat <- projectData(cellchat, PPI.mouse) 推断细胞通讯网络 ##推测细胞通讯网络 cellchat <- computeCommunProb(cellchat) cellchat <- computeCommunProbPathway(cellchat) cellchat <- aggregateNet ") cellchat <- netEmbedding(cellchat, type = "structural") cellchat <- netClustering(cellchat, type =
细胞通讯学习-cellchat1 安装依赖按照官方文档说明,先安装4个依赖NMF (>= 0.23.0)circlize (>= 0.4.12)ComplexHeatmapUMAP(python包)已经安装过的可以直接跳过 以上依赖都安装完后,使用以下代码安装cellchat:devtools::install_github("sqjin/CellChat")报错,CMake was not found on the PATH Please install CMake.因为我是用conda配置环境,这里用conda来安装:conda install cmake在R终端继续安装cellchat:继续报错,缺少一堆依赖包:ERROR : dependencies ‘RSpectra’, ‘RcppEigen’, ‘ggpubr’, ‘BiocNeighbors’ are not available for package ‘CellChat 参考资料cellchat官方教程(https://github.com/sqjin/CellChat)
自从周运来写了一篇cellchat的中文介绍教程《CellChat:细胞间相互作用分析利器》,然后R包作者也在B站做了直播介绍,cellchat作为一个细胞通讯分析的新兴R包,受到了广泛关注。 保存cellchat对象 此教程概述了使用CellChat对单个数据集细胞通信网络进行推断、分析和可视化的步骤。 cellchat <- addMeta(cellchat, meta = meta) cellchat <- setIdent(cellchat, ident.use = "labels") # set (cellchat) cellchat <- projectData(cellchat, PPI.human) 第二部分:细胞通信网络的推断 CellChat 通过分配具有概率值的每个相互作用并进行排列检验 cellchat <- computeNetSimilarity(cellchat, type = "structural") cellchat <- netEmbedding(cellchat, type
我在 CellChat细胞通讯分析(一)一文中简单介绍了CellChat,以及其进行细胞间通讯的推断与分析的代码实现。 ,利用模式识别方法; CellChat可以通过定义相似性度量和从功能和拓扑两方面执行多种学习来对信号通路进行分组; CellChat可以通过多网络的联合流形学习来勾画出保守的和上下文相关的信号通路。 (cellchat, pattern = "incoming", k = nPatterns) # river plot netAnalysis_river(cellchat, pattern = " cellchat <- computeNetSimilarity(cellchat, type = "structural") cellchat <- netEmbedding(cellchat, type CellChat包的可视化展示及解读的全部内容。
# 查看指定细胞间的相互作用netVisual_bubble( cellchat, sources.use = 8, targets.use = c(1, 3, 5), remove.isolate = "MHC-I", remove.isolate = FALSE)# 查看指定受体配体对在所有细胞间的作用netVisual_bubble( cellchat, # sources.use = = 0.5, legend.pos.y = 30)# 某种细胞作为target的相互作用netVisual_chord_gene( cellchat, sources.use = c(1, 3, plotGeneExpression(cellchat, signaling = "MHC-I") #仅展示具有显著意义的信号通路中的基因plotGeneExpression(cellchat, signaling = "MHC-I", enriched.only = FALSE) #展示该信号通路中的所有基因参考资料:cellchat官方教程(https://github.com/sqjin/CellChat)
上一篇讲了cellchat安装和数据准备,接下来进行单数据集的细胞通讯分析。1 创建cellchat对象这里直接通过上次保存的Seurat数据生成。 $label_cc <- Idents(pbmc3k)# 创建cellchat对象,注意需要用Normalized data, 这里用cellchat提供的`normalizeData`函数cellchat , min.cells = 10)# 在信号通路水平推断相互作用cellchat <- computeCommunProbPathway(cellchat)cellchat <- aggregateNet (cellchat)到这里细胞通讯的推断已经完成,所有数据都存储在了cellchat对象中,接下来就是可视化了。 参考资料:cellchat官方教程(https://github.com/sqjin/CellChat)
比如cellchat这个算法做细胞通讯, 就有 prob 与 pval 这两个值! Protocols 2024 [CellChat v2] (Please kindly cite this paper when using CellChat version >= 1.5) Suoqin 2021 [CellChat v1] 我们单细胞月更群里有一个学员提问:您好,哪位大佬能帮解释一下cellchat的通讯概率是什么意思吗? 确实cellchat细胞通讯里面的两个指标很容易让人误解,这就让我们来一起看看cellchat的原理吧。 右图的边代表:communication probability的加和,该数据来源于cellchat@net$prob Ref: https://github.com/sqjin/CellChat/issues
Cellchat细胞通讯分析的主要内容如下:为了预测显著的通讯,CellChat识别出每个细胞组中差异过表达的配体和受体。 (cellchat)cellchat <- smoothData(cellchat, adj = PPI.human)cellchat <- computeCommunProb(cellchat, type (cellchat)df.net_left <- subsetCommunication(cellchat)cellchat <- aggregateNet(cellchat)cellchat_left (cellchat)cellchat <- smoothData(cellchat, adj = PPI.human)cellchat <- computeCommunProb(cellchat, type (cellchat)df.net_right <- subsetCommunication(cellchat)cellchat <- aggregateNet(cellchat)cellchat_right
1.CellChat对象的创建、处理及初始化1.1 使用Seurat对象创建CellChat对象1.2 使用表达矩阵创建CellChat对象1.3 设置配体受体交互数据库1.4 表达数据的预处理2.细胞通信网络推断 <-createCellChat(sce)str(cellchat) [1] "Formal class 'CellChat' [package \"CellChat\"] with 14 slots" 对象#添加亚群信息cellchat <- addMeta(cellchat, meta = meta)cellchat <- setIdent(cellchat, ident.use = "labels (cellchat)#识别过度表达的配体受体相互作用cellchat <- identifyOverExpressedInteractions(cellchat)#将基因表达数据投射到PPI网络上cellchat 保存CellChat对象以便后续使用saveRDS(cellchat, file = "cellchat_humanSkin_LS.rds")---参考来源CellChat-githubCellChat