介绍
复现GMM文章的的Fig2图。
加载R包
library(tidyr)
library(tidyverse)
library(dplyr)
library(ggsci)
library(ggpubr)
导入数据
所有的数据可以通过下列链接下载:
百度网盘链接: https://pan.baidu.com/s/1isKEK1G5I6X90KYqLufmWw
提取码: t9ca
图2A
- 数据
load('01_data/plot_data/F2A.RData')
stat.test <- compare_means(
auc~group1,data = auc_external,
method = "wilcox.test") %>%
mutate(y.position = seq(from=1.15, to=1.9,length.out=10))
x <- stat.test$p.adj
stat.test$p.adj.signif<-ifelse(x<0.05, ifelse(x<0.01, ifelse(x<0.001, ifelse(x<=0.0001, '****','***'),'**'),'*'),'ns')
- 画图
p1 <- ggviolin(auc_external, x = "group1", y = "auc", fill = "group1",alpha = 0.3,
palette = "jco",add = "boxplot",width = 0.6)+
geom_hline(yintercept =0.5,color='#dbdcdc')+
geom_hline(yintercept =0.6,color='#ffd09a')+
geom_hline(yintercept =0.7,color='#ffcbd8')+
geom_hline(yintercept =0.8,color='#7b77ff')+
# stat_compare_means()+
ylim(0.05,1.9)+
theme(legend.position="none")+
xlab("") + ylab("External AUC")+
ggtitle("Disease category")+
theme(axis.text.x=element_text(angle=20, hjust=0.8,face = 'plain',size=13),
text = element_text(size=13,face = 'plain',family ='',colour = 'black')) +
stat_pvalue_manual(stat.test,label = "p.adj.signif")
p1
图2B
- 数据
load('01_data/plot_data/F2B.RData')
head(self.e)
stat.test <- compare_means(
auc~level,data = self.e,
# group.by = "level",
method = "wilcox.test") %>%
mutate(y.position = seq(from=1.35, to=1.7,length.out=3))
x <- stat.test$p.adj
stat.test$p.adj.signif <- ifelse(x<0.05, ifelse(x<0.01, ifelse(x<0.001, ifelse(x<=0.0001, '****','***'),'**'),'*'),'ns')
- 画图
p2 <- ggviolin(self.e, x = "level", y = "auc", fill = "level",alpha = 0.3,
palette = c('#774ec7','#bd93cc','#a2c4b1'),add = "boxplot",width = 0.5)+
geom_hline(yintercept =0.5,color='#dbdcdc')+
geom_hline(yintercept =0.6,color='#ffd09a')+
geom_hline(yintercept =0.7,color='#ffcbd8')+
geom_hline(yintercept =0.8,color='#7b77ff')+
ylim(0.05,1.9)+
# stat_compare_means()+
theme(legend.position="none")+
ylab("External AUC")+xlab('')+
ggtitle('Data type')+
theme(axis.text.x=element_text(angle=20, hjust=0.8,face = 'plain',size=13),
text = element_text(size=13,face = 'plain',family ='',colour = 'black')) +
stat_pvalue_manual(stat.test,label = "p.adj.signif")
p2
图2C
- 数据
load('01_data/plot_data/F2C.RData')
head(self.e)
stat.test <- compare_means(
auc~group1,data = self.e, group.by = "level",
method = "wilcox.test") %>%
mutate(y.position = c(seq(from=1, to=1.5,length.out=10),rep(seq(from=1, to=1.3,length.out=6), times=2)))
x <- stat.test$p.adj
stat.test$p.adj.signif <- ifelse(x<0.05, ifelse(x<0.01, ifelse(x<0.001, ifelse(x<=0.0001, '****','***'),'**'),'*'),'ns')
- 画图
p3 <- ggboxplot(self.e, x = "group1", y = "auc",color = "group1", palette = "jco", add = "jitter",
width = 0.5,add.params = list(size=1))+
facet_wrap(vars(level),scales = "free")+
stat_compare_means(aes(label = paste0('p = ',..p.format..)),label.y = 1.5,hjust=-0.01)+
theme(axis.text.x = element_blank(),axis.ticks=element_blank(),legend.position="none")+
xlab("Disease category") + ylab("External AUC")+
labs(color = "disease type")+
theme(text = element_text(size=13,face = 'plain',family ='',colour = 'black')) +
stat_pvalue_manual(stat.test,label = "p.adj.signif")
p3
图2D
- 数据
load('01_data/plot_data/F2D.RData')
head(self.e)
stat.test <- compare_means(
auc~level,data = self.e, group.by = "subtype",
method = "wilcox.test") %>%
mutate(y.position = rep(seq(from=1, to=1.15,length.out=3), times=4))
x <- stat.test$p.adj
stat.test$p.adj.signif <- ifelse(x<0.05, ifelse(x<0.01, ifelse(x<0.001, ifelse(x<=0.0001, '****','***'),'**'),'*'),'ns')
- 画图
p4 <- ggboxplot(self.e, x = "level", y = "auc",color = "level", add = "jitter",
palette = c('#774ec7','#bd93cc','#a2c4b1'),
width = 0.5,add.params = list(size=1))+
facet_wrap(vars(subtype),nrow = 1)+
stat_compare_means(aes(label = paste0('p = ',..p.format..)),label.y = 1.25,hjust=-0.01)+
theme(axis.text.x = element_blank(),axis.ticks=element_blank(),legend.position="none")+
xlab("Data type") + ylab("External AUC")+
theme(text = element_text(size=13,face = 'plain',family ='',colour = 'black')) +
stat_pvalue_manual(stat.test,label = "p.adj.signif")
p4