介绍
复现GMM文章的的Fig3图。
加载R包
library(tidyr)
library(tidyverse)
library(dplyr)
library(ggsci)
library(ggpubr)
导入数据
所有的数据可以通过下列链接下载:
百度网盘链接: https://pan.baidu.com/s/1isKEK1G5I6X90KYqLufmWw
提取码: t9ca
图3A
- 数据
load('01_data/plot_data/F3AB.RData')
head(mydata)
fit <- aov(auc ~ data_type*disease_type,data = mydata)
a <- summary(fit)
R2data <- data.frame('type'=c('Data type','Disease category','Interaction'),'R2'=c(a[[1]][["Sum Sq"]][1]/sum(a[[1]][["Sum Sq"]]),a[[1]][["Sum Sq"]][2]/sum(a[[1]][["Sum Sq"]]),a[[1]][["Sum Sq"]][3]/sum(a[[1]][["Sum Sq"]])),
p=c(paste0('p < ','2e-16'),paste0('p < ','2e-16'),paste0('p = ','0.109')))
R2data$type <- factor(R2data$type,levels=c('Data type','Disease category','Interaction'))
- 画图
p1 <- ggplot(R2data, aes(x=type, y=R2))+
geom_bar(data=R2data,mapping = aes(x=type, y=R2,fill=type),stat="identity",
position = 'dodge',width = 0.4,alpha=0.3)+
scale_fill_manual(values = c("#8c510a","#01665e",'black'))+
geom_text(data=R2data,aes(label=round(R2,3)), vjust=-0.004)+
geom_text(data=R2data,aes(label=p), vjust=-1.5)+
theme(axis.ticks.x = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"))+
labs( title = "ANOVA: ext−AUC~Data_type*Disease_category")+
theme(text = element_text(size=13,face = 'plain',family =''))
p1
图3B
- 数据
load('01_data/plot_data/F3AB.RData')
head(mydata)
fit <- aov(auc ~ disease_type*data_type,data = mydata)
a <- summary(fit)
R2data <- data.frame('type'=c('Disease category','Data type','Interaction'),'R2'=c(a[[1]][["Sum Sq"]][1]/sum(a[[1]][["Sum Sq"]]),a[[1]][["Sum Sq"]][2]/sum(a[[1]][["Sum Sq"]]),a[[1]][["Sum Sq"]][3]/sum(a[[1]][["Sum Sq"]])),
p=c(paste0('p < ','2e-16'),paste0('p = ','0.163'),paste0('p = ','0.109')))
R2data$type <- factor(R2data$type,levels=c('Disease category','Data type','Interaction'))
- 画图
p2 <- ggplot(R2data, aes(x=type, y=R2))+
geom_bar(data=R2data,mapping = aes(x=type, y=R2,fill=type),stat="identity",
position = 'dodge',width = 0.4,alpha=0.3)+
scale_fill_manual(values = c("#8c510a","#01665e",'black'))+
geom_text(data=R2data,aes(label=round(R2,3)), vjust=-0.004)+
geom_text(data=R2data,aes(label=p), vjust=-1.5)+
theme(axis.ticks.x = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"))+
labs( title = "ANOVA: ext−AUC~Disease_category*Data_type")+
theme(text = element_text(size=13,face = 'plain',family =''))
p2
图3C
- 数据
load('01_data/plot_data/F3C.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)))
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
图3D
- 数据
load('01_data/plot_data/F3D.RData')
head(data)
- 画图
p4 <- ggboxplot(data, x = "level", y = "auc",color = 'level', palette = c('#774ec7','#a2c4b1'),
facet.by = "disease",outlier.shape = NA,nrow = 1)+
geom_jitter(data,mapping=aes(color=level),width =0.2,size=2)+
scale_shape_manual(values = c(19, 15))+
stat_compare_means(label.y = 1.05)+
theme(axis.text.x = element_blank(),axis.ticks=element_blank(),legend.position="top")+
xlab("Data type") + ylab("ext-AUC")+
labs(shape = "Data type")+
theme(text = element_text(size=13,face = 'plain',family ='',colour = 'black'))
p4