scDiffCom包是一个用于单细胞数据中细胞间通讯分析的R工具包。😘
该工具包结合了最新的生物学知识库和单细胞表达数据,通过识别配体-受体相互作用来揭示细胞间的信号传递关系。💪
scDiffCom不仅提供了基于表达的相互作用预测,还考虑了配体、受体及其下游信号通路的活性和差异性,能够揭示在不同实验条件或细胞状态下细胞通讯的动态变化。🧐
rm(list = ls())
# Install the development version from GitHub
#devtools::install_github("CyrilLagger/scDiffCom")
library(Seurat)
library(scDiffCom)
library(data.table)
library(tidyverse)
seurat_object <- scDiffCom::seurat_sample_tms_liver
seurat_object

table(seurat_object[["cell_type"]])

# Cells can be grouped based on mice age
table(seurat_object[["age_group"]])

如果你需要并行运算,提高速度的话,就加载这个包,然后设置用到的核心数。😘
这里数据量比较小,我们就不用了。😏
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
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"
)
)

scdiffcom_object

# 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)

# Retrieve the ORA results
ORA_results <- GetTableORA(scdiffcom_object, categories = "all", simplified = TRUE)
# Categories available
names(ORA_results)

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)")

# 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")
)

# 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")
)

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的列与默认值相同就行。😜
custom_LRI <- LRI_mouse$LRI_curated[1:100, ]
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")]
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)
)
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"
)
)
# Run ORA with the cell type families as extra annotation
scdiffcom_object <- RunORA(
object = scdiffcom_object,
extra_annotations = list(
cell_families_relation
),
overwrite = FALSE
)
最后祝大家早日不卷!~
点个在看吧各位~ ✐.ɴɪᴄᴇ ᴅᴀʏ 〰