cellphonedb v5受配体多组比较气泡图(原创函数)
2024-09-07 本文已影响0人
KS科研分享与服务
前面我们发布了关于cellchat的函数(连夜更新---别说两组了,这个cellchat多组比较气泡图函数10组也能做了)。因为cellchat比较好入手,所以先开刀。很多小伙伴说有没有cpdb的,其实在写函数之初,我们就考虑到了,只不过先从cellchat好入手,本来以为套用可能大差不差,结果cpdb在数据上有很大出入,所以这次费了点时间。However,最终效果刚刚的!
参考:函数B站解说视频(一定要看使用方法哦!):https://www.bilibili.com/video/BV1EreueiE7Q/?spm_id_from=333.999.0.0&vd_source=05b5479545ba945a8f5d7b2e7160ea34
函数主体:也是支持多组,支持自选受配体,自选pathway,自定义分类!
image.png
看看演示:load data
library(ggplot2)
library(tidyr)
#load data
GO_pvals <- read.delim("./GO_cpdb/statistical_analysis_pvalues_08_15_2024_132104.txt", check.names = FALSE)
GO_means <- read.delim("./GO_cpdb/statistical_analysis_means_08_15_2024_132104.txt", check.names = FALSE)
WT_pvals <- read.delim("./WT_cpdb/statistical_analysis_pvalues_08_15_2024_132617.txt", check.names = FALSE)
WT_means <- read.delim("./WT_cpdb/statistical_analysis_means_08_15_2024_132617.txt", check.names = FALSE)
data = list(list(pval=GO_pvals, means=GO_means),
list(pval=WT_pvals, means=WT_means))
测试1:选定通路
#测试1:cpdb_anno没有pathway,用cpdb默认的,用通路选择
cpdb_interLR <- read.csv(file="cpdb_interLR",header = T)
#选定pathway,注释文件中没有pathway
ks_cpdb_Group_bubble(cpdb_data = data,
group_names = c("GO","WT"),
analysis_cells = "Endothelial",
pathway = c("Signaling by Transforming growth factor","Signaling by Semaphorin"),
cpdb_anno = cpdb_interLR,
tag_pos = c(0.5,0.12),
sig = F)
#随机换种celltype试试
ks_cpdb_Group_bubble(cpdb_data = data,
group_names = c("GO","WT"),
analysis_cells = "Macrophages",
pathway = c("Adhesion by Laminin","Signaling by Integrin"),
cpdb_anno = cpdb_interLR,
tag_pos = c(0.4,0.2),
sig = F)
#只显示显著的,sig=T
ks_cpdb_Group_bubble(cpdb_data = data,
group_names = c("GO","WT"),
analysis_cells = "Endothelial",
pathway = c("Signaling by Transforming growth factor","Signaling by Semaphorin"),
cpdb_anno = cpdb_interLR,
tag_pos = c(0.5,0.12),
sig = T)
image.png
测试2:自选受配体,自定义分类!
#测试2
#自选受配体对,注释文件带pathway注释
cpdb_interLR_anno <- read.csv(file = 'cpdb_interLR_anno.csv', header = T, row.names = 1)
select_LR <- read.csv('plot_pairs.csv', header = F)
ks_cpdb_Group_bubble(cpdb_data = data,
group_names = c("GO","WT"),
analysis_cells = "Endothelial",
select_LR = select_LR$V1,
cpdb_anno = cpdb_interLR_anno,
tag_pos = c(0.4,0.2),
sig = F)
没毛病,非常完美!希望对你有所帮助!