rm(list = ls())
###############################input data 
dir_path <- "C:\\Users\\liyix\\OneDrive\\Desktop\\"
dir_path_name <- list.files(pattern = ".*csv",dir_path,full.names = T, recursive = F)
dir_path_name
## [1] "C:\\Users\\liyix\\OneDrive\\Desktop\\abc.csv"    
## [2] "C:\\Users\\liyix\\OneDrive\\Desktop\\results.csv"
data_1 <- read.csv(grep("abc.csv",dir_path_name,value = T),header = T,stringsAsFactors = F)
###############################input data 
library(igraph)
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
library(ggplot2)
data_2 <- data_1[, grep('AUC',colnames(data_1),fixed = T, useBytes = T)]
head(data_2)
##         AUC     SD_AUC
## 1 0.8148506 0.03624724
## 2 0.7219305 0.04111358
## 3 0.7349742 0.02234813
## 4 0.6902538 0.02238117
## 5 0.7937966 0.07925068
## 6 0.7816694 0.04798778
###################################
ggplot(data_1, aes(x = AUC)) +
  geom_density(alpha=0.5,color="black", fill="lightblue") +
  geom_histogram(aes(y=..density..), alpha=0.5, 
                 position="identity",colour="black", fill="white",bins=10)+
  scale_y_discrete(expand = c(0, 0)) +
  scale_x_continuous(expand = c(0, 0),limits = c(0.5, 1.01),
                     breaks = seq(0.5,1,.1))+
  scale_fill_manual(values = categorical_pal(8)[2])+
  #geom_vline(aes(xintercept=max(AUC)),
  #          color="blue", linetype="dashed", size=1)+
  labs(x="AUC-ROC", 
       y= "Density", title="")+
  theme(panel.spacing = unit(0.1, "cm"),
        legend.position= "none",
        axis.ticks = element_line(colour = "black", 
                                  size = 0.5, linetype = "solid"),
        axis.line = element_line(colour = "black", 
                                 size = 0.5, linetype = "solid"),
        axis.text =element_text(face="plain", color="black", family = "sans",
                                size=14,angle = 0),
        panel.background = element_rect(fill = "white",
                                        colour = "white",
                                        size = 0.5, linetype = "solid"),
        panel.grid.major = element_line(size = 1, linetype = 'dashed',
                                        colour = "white"),
        axis.title = element_text(color="black", size=14, face="plain",family="sans"))
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).

?geom_density
## starting httpd help server ...
##  done
##########################output
ggsave(filename = paste0(Sys.Date(),"-auc-roc.tif"), plot = last_plot(), 
       device = "tiff", path = dir_path,
       scale = 1, width = 13, height = 12, units = "cm",
       dpi = 300, limitsize = TRUE, compression = "lzw")
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).