rm(list = ls())
###########################INPUT DATA
dir_path <- "C:\\Users\\liyix\\OneDrive\\Desktop\\data\\"
dir_path_files <- list.files(pattern = ".*.csv",dir_path,recursive = F, all.files = F,full.names = T)
dir_path_files
## [1] "C:\\Users\\liyix\\OneDrive\\Desktop\\data\\2020-08-26-FDR_less_than_005.csv"
## [2] "C:\\Users\\liyix\\OneDrive\\Desktop\\data\\data.csv"
data_1 <- read.csv(dir_path_files[grep("data.csv",dir_path_files)],header = T,stringsAsFactors = F)
dim(data_1) #[1] 1686 3
## [1] 1686 3
head(data_1)
## Compound Pathway FDR
## 1 DOGIDQKFVLKMLQ Signaling by GPCR 0.000184884
## 2 DOGIDQKFVLKMLQ GPCR ligand binding 0.001972108
## 3 DOGIDQKFVLKMLQ Gastrin-CREB signaling pathway via PKC and MAPK 0.031449229
## 4 DOGIDQKFVLKMLQ Neuroactive ligand-receptor interaction 0.007447434
## 5 DOGIDQKFVLKMLQ Peptide G-protein coupled receptors 0.006169997
## 6 DOGIDQKFVLKMLQ Retrograde endocannabinoid signaling 0.031449229
data_2 <- data_1[data_1$FDR < 0.005,]
dim(data_2) #[1] 56 3
## [1] 56 3
length(unique(data_2$Compound)) #[1] 33
## [1] 33
length(unique(data_2$Pathway)) #[1] 32
## [1] 32
#############################OUTPUT DATA
write.table(data_2, paste0(Sys.Date(),"-","FDR_less_than_005.txt"),sep = "\t")
write.csv(data_2, paste0(dir_path,Sys.Date(),"-","FDR_less_than_005.csv"),row.names = FALSE)
################################DRAW plot
library(ggplot2)
p <- ggplot(data = data_2, aes(x=Pathway, y=Compound,fill = "red")) +
geom_tile(aes(height = 0.8),size=0.001,colour = "green") + xlab("") + ylab("") +
theme(panel.spacing = unit(0.1, "cm"),
axis.text.x = element_blank(),
axis.text.y = element_text(face="plain", color="black",
size=5, angle=0,hjust = 0, family = "sans"),
axis.ticks.x = element_blank(),
axis.ticks.y = element_line(size = .2),
legend.position = "",
panel.border = element_blank(),
panel.background = element_rect(fill = "gray95"),
panel.grid = element_blank()) +
scale_x_discrete(expand = c(0, 0))+
scale_y_discrete(expand = c(0, 0))
p

###################################################save plot
ggsave(filename = paste0(Sys.Date(),"-","hp.tif"),
plot = p, device = "tiff", path = dir_path,
width = 10, height = 11, units = "cm",
dpi = 300, limitsize = TRUE,compression = "lzw")
ggsave(filename = paste0(Sys.Date(),"-","hp.pdf"),
plot = p, device = "pdf", path = dir_path,
width = 10, height = 11, units = "cm",
dpi = 300, limitsize = TRUE)