首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >🤩 scDiffCom | 看过来吧!~细胞间通讯怎么做差异分析呢!?

🤩 scDiffCom | 看过来吧!~细胞间通讯怎么做差异分析呢!?

作者头像
生信漫卷
发布2024-11-26 09:12:09
发布2024-11-26 09:12:09
4200
举报

写在前面

scDiffCom包是一个用于单细胞数据中细胞间通讯分析的R工具包。😘

该工具包结合了最新的生物学知识库和单细胞表达数据,通过识别配体-受体相互作用来揭示细胞间的信号传递关系。💪

scDiffCom不仅提供了基于表达的相互作用预测,还考虑了配体、受体及其下游信号通路的活性和差异性,能够揭示在不同实验条件或细胞状态下细胞通讯的动态变化。🧐

用到的包

代码语言:javascript
复制
rm(list = ls())
# Install the development version from GitHub
#devtools::install_github("CyrilLagger/scDiffCom")
library(Seurat)
library(scDiffCom)
library(data.table)
library(tidyverse)

示例数据

代码语言:javascript
复制
seurat_object <- scDiffCom::seurat_sample_tms_liver
seurat_object

查看数据的metaata

细胞分类

代码语言:javascript
复制
table(seurat_object[["cell_type"]])

分组

代码语言:javascript
复制
# Cells can be grouped based on mice age
table(seurat_object[["age_group"]])

并行运算

如果你需要并行运算,提高速度的话,就加载这个包,然后设置用到的核心数。😘

这里数据量比较小,我们就不用了。😏

代码语言:javascript
复制
library(future)
plan(sequential) # sequentially in the current R process, equivalent to do nothing
#plan(multisession, workers = 4) # background R sessions
#plan(multicore, workers = 4) # forked R processes, not Windows/not RStudio

开始细胞间通讯差异分析

代码语言:javascript
复制
scdiffcom_object <- run_interaction_analysis(
  seurat_object = seurat_object,
  LRI_species = "mouse",
  seurat_celltype_id = "cell_type",
  seurat_condition_id = list(
    column_name = "age_group",
    cond1_name = "YOUNG",
    cond2_name = "OLD"
  )
)

代码语言:javascript
复制
scdiffcom_object

查看结果

代码语言:javascript
复制
# Retrieve and display all detected CCIs
CCI_detected <- GetTableCCI(scdiffcom_object, type = "detected", simplified = TRUE)

# Number of CCIs per regulation type (here with age)
table(CCI_detected$REGULATION)

代码语言:javascript
复制
# Retrieve the ORA results
ORA_results <- GetTableORA(scdiffcom_object, categories = "all", simplified = TRUE)

# Categories available
names(ORA_results)

火山图可视化

代码语言:javascript
复制
ggplot(CCI_detected, 
       aes(
         x = LOGFC,
         y = -log10(BH_P_VALUE_DE + 1E-2),
         colour = REGULATION
         )) +
  geom_point() + 
  theme_minimal()+
  scale_colour_manual(values = c("UP" = "#FB8072", "DOWN" = "#1965B0", "FLAT" = "#B2DF8A", "NSC" = "grey")) + 
  xlab("log(FC)") + 
  ylab("-log10(Adj. p-value)")

ORA富集分析结果可视化

代码语言:javascript
复制
# Plot the most over-represented up-regulated LRIs
PlotORA(object = scdiffcom_object,
        category = "LRI",
        regulation = "UP") + 
  theme_minimal()+
  theme(legend.position = 'right',
        legend.key.size = unit(0.4, "cm")
        )

代码语言:javascript
复制
# Plot the most over-represented down-regulated LRIs
PlotORA(object = scdiffcom_object,
        category = "LRI",
        regulation = "DOWN") + 
  theme_minimal()+
  theme(legend.position = 'right',
        legend.key.size = unit(0.4, "cm")
        )

网络可视化

代码语言:javascript
复制
if (!require("visNetwork")) install.packages("visNetwork")
if (!require("igraph")) install.packages("igraph")
if (!require("kableExtra")) install.packages("kableExtra")
if (!require("RColorBrewer")) install.packages("RColorBrewer")

BuildNetwork(
  object = scdiffcom_object
)

使用配体-受体相互作用的自定义数据库

scDiffcom还可以使用自己的LRI数据库和关联的注释。😘

这里我们以删减版mouse数据库为例。🫠

其实这里可以是任何数据库,只要它是data.table的列与默认值相同就行。😜

代码语言:javascript
复制
custom_LRI <- LRI_mouse$LRI_curated[1:100, ]

代码语言:javascript
复制
custom_LRI_GO <- LRI_mouse$LRI_curated_GO[LRI %in% custom_LRI$LRI]
custom_LRI_KEGG <- LRI_mouse$LRI_curated_KEGG[LRI %in% custom_LRI$LRI][, c("LRI", "KEGG_ID")]

代码语言:javascript
复制
scdiffcom_object_customlri <-  run_interaction_analysis(
  seurat_object = seurat_object,
  LRI_species = "custom",
  seurat_celltype_id = "cell_type",
  seurat_condition_id = list(
    column_name = "age_group",
    cond1_name = "YOUNG",
    cond2_name = "OLD"
  ),
  custom_LRI_tables = list(LRI = custom_LRI, custom_GO = custom_LRI_GO, custom_KEGG = custom_LRI_KEGG)
)

对自定义类别进行ORA分析

代码语言:javascript
复制
cell_families_relation <- data.table(
  EMITTER_CELLTYPE = c(
    "B cell",
    "T cell",
    "endothelial cell of hepatic sinusoid",
    "hepatocyte",
    "myeloid leukocyte"
  ),
  EMITTER_CELLFAMILY = c(
    "leukocyte",
    "leukocyte",
    "endothelial cell",
    "epithelial cell",
    "leukocyte"
  )
)

代码语言:javascript
复制
# Run ORA with the cell type families as extra annotation
scdiffcom_object <- RunORA(
  object = scdiffcom_object,
  extra_annotations = list(
    cell_families_relation
  ),
  overwrite = FALSE
)

最后祝大家早日不卷!~


点个在看吧各位~ ✐.ɴɪᴄᴇ ᴅᴀʏ 〰

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-11-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信漫卷 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 写在前面
  • 用到的包
  • 示例数据
  • 查看数据的metaata
    • 细胞分类
    • 分组
  • 并行运算
  • 开始细胞间通讯差异分析
  • 查看结果
  • 火山图可视化
  • ORA富集分析结果可视化
  • 网络可视化
  • 使用配体-受体相互作用的自定义数据库
  • 对自定义类别进行ORA分析
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档