UKB-project / 22_Plot_AUC_PRAUC_diseases.R
22_Plot_AUC_PRAUC_diseases.R
Raw
### CREATE PLOTFOR FIG 

# srun -p interactive --pty bash

library(MetBrewer)
library(readxl)
library(ggplot2)
library(ggthemes)
library(readxl)
library(tidyverse)
library(dplyr)
library(ggalt)

death <- read.csv("path.../death_results_full_10yr.csv")
disease <- read.csv("path.../disease_results_full_10yr.csv")
disease_5yr <- read.csv("path.../disease_results_full_5yr.csv")

table <- rbind(disease, death)
table$Onset <- '10'
disease_5yr$Onset <- '5'
table <- rbind(table, disease_5yr)
table[,1] <- rep(c('m1','m2','m3','m4','m5', 'd1', 'd2'), 20)
table <- table[which(table$Outcome %in% c('DEATH', 'ST', 'PD', 'RA', 'LUNG', 'LIV', 'IHD', 'Diab', 'COPD', 'AL', 'ALS')),]

AUC <- table[-3]
PRAUC <- table[-2]

AUC <- AUC[c(1,2,7)]
AUC <- reshape(AUC, idvar = "Naming", timevar = "X", direction = "wide")

PRAUC <- PRAUC[c(1,2,7)]
PRAUC <- reshape(PRAUC, idvar = "Naming", timevar = "X", direction = "wide")

My_Theme = theme(
  axis.title.x = element_text(size = 20),
  axis.text.x = element_text(size = 20),
  axis.text.y = element_text(size = 20),
  axis.title.y = element_text(size = 24),
  strip.text = element_text(size = 20, face = "bold"),
  legend.text=element_text(size=24),
  legend.title=element_text(size=24, face = "bold"), legend.position = "none")

# DO NULL AUC 
AUC$Naming = factor(AUC$Naming, levels=unique(AUC$Naming[order(AUC$AUC.d1)]))

pdf('path.../plot_AUC_basic.pdf', width = 5, height = 4)
scales::hue_pal()(2)
ggplot(AUC, aes(x = AUC.m1, xend = AUC.m2, y = Naming)) + 
  geom_dumbbell(size=3, color="#e3e2e1",
                colour_x = "#5b8124", colour_xend = "#bad744",
                dot_guide=TRUE, dot_guide_size=0.25) +
  scale_y_discrete(limits = rev, name = NULL) +
  xlab('AUC')+
  theme_minimal() +
  theme(panel.grid.major.x=element_line(size=0.09)) + xlim(0.5,0.9)
dev.off()


# DO NULL PRAUC 

join <- AUC[c(1,7)]

PRAUC <- left_join(PRAUC, join, by = 'Naming')

PRAUC$Naming = factor(PRAUC$Naming, levels=unique(PRAUC$Naming[order(PRAUC$AUC.d1)]))


pdf('path.../plot_PRAUC_null_updated_ROC_P.pdf', width = 5, height = 4)
scales::hue_pal()(2)
ggplot(PRAUC, aes(x = PRAUC.m1, xend = PRAUC.m2, y = Naming)) + 
  geom_dumbbell(size=3, color="#e3e2e1",
                colour_x = "#5b8124", colour_xend = "#bad744",
                dot_guide=TRUE, dot_guide_size=0.25) +
  scale_y_discrete(limits = rev, name = NULL) +
  xlab('PRAUC')+
  theme_minimal() +
  theme(panel.grid.major.x=element_line(size=0.09)) + xlim(0.2,0.7)
dev.off()

# DO FULL AUC 
AUC$Naming = factor(AUC$Naming, levels=unique(AUC$Naming[order(AUC$AUC.d1)]))

pdf('path.../plot_AUC_full_updated_ROC_P.pdf', width = 5, height = 4)
scales::hue_pal()(2)
ggplot(AUC, aes(x = AUC.m4, xend = AUC.m5, y = Naming)) + 
  geom_dumbbell(size=3, color="#e3e2e1",
                colour_x = "cadetblue4", colour_xend = "cadetblue3",
                dot_guide=TRUE, dot_guide_size=0.25) +
  scale_y_discrete(limits = rev, name = NULL) +
  xlab('AUC')+
  theme_minimal() +
  theme(panel.grid.major.x=element_line(size=0.09)) + xlim(0.5,0.9)
dev.off()

# DO FULL PRAUC 

join <- AUC[c(1,8)]

PRAUC <- left_join(PRAUC, join, by = 'Naming')

PRAUC$Naming = factor(PRAUC$Naming, levels=unique(PRAUC$Naming[order(PRAUC$AUC.d1)]))


pdf('path.../plot_PRAUC_full_updated_ROC_P.pdf', width = 5, height = 4)
scales::hue_pal()(2)
ggplot(PRAUC, aes(x = PRAUC.m4, xend = PRAUC.m5, y = Naming)) + 
  geom_dumbbell(size=3, color="#e3e2e1",
                colour_x = "cadetblue4", colour_xend = "cadetblue3",
                dot_guide=TRUE, dot_guide_size=0.25) +
  scale_y_discrete(limits = rev, name = NULL) +
  xlab('PRAUC')+
  theme_minimal() +
  theme(panel.grid.major.x=element_line(size=0.09))+ xlim(0.2,0.7)
dev.off()