rm(list = ls())
################# ##############input data 
dir_path <- "C:\\Users\\liyix\\OneDrive\\Desktop\\"
dir_path_name <- dir(dir_path,pattern = "*.",full.names = T)
#dir_path_name
library(openxlsx)
getSheetNames(grep("heatmap.xlsx",dir_path_name,value = T))
## [1] "Sheet1"
data_1 <- read.xlsx(grep("heatmap.xlsx",dir_path_name,value = T),sheet = 1)
##View(Guide)
#dim(data_1) #[1] 139   7
#head(data_1)
row.names(data_1) <- data_1$Feature
data_1$Feature <- NULL
data_1$`Avg(KS-viability)` <- data_1$`Sum(H317)` <- NULL
colnames(data_1) <- c("C", "K", "L","S")
#colnames(data_1)
head(data_1)
##                                         C    K    L     S
## atom:element_metal_group_I_II        -8.0 0.00 4.83  2.17
## atom:element_metal_transistion_metal -4.5 0.00 0.00  3.67
## bond:C(=O)N_carbamate                 0.0 5.67 3.17  3.17
## bond:C(=O)N_carbamate_dithio         -9.0 0.00 4.17 -1.17
## bond:C(=O)N_carboxamide_(NHR)        -3.5 2.67 0.00  2.17
## bond:C(=O)O_acidAnhydride             0.0 0.00 0.00  0.00
library(pheatmap)
data_1 <- data_1[1:20,]
#tiff(filename = paste0(dir_path,Sys.Date(),"-heatmap_with_feature_1.tiff"),res = 300,
 #    width = 20, height =25, units = "cm", pointsize =20,
#     compression = "lzw",bg = "white")
pheatmap(data_1,cluster_row = T, cluster_col = T, na_col = "gray90",
         show_colnames = T,annotation_legend = T,
         main = NA,treeheight_col = 50,legend= T,border_color = "white",
         fontsize = 5,legend_breaks = seq(-9,9,3),angle_col = 0,
         show_rownames = F,scale = "none",
         color = colorRampPalette(c("white", "red"))(100))

pheatmap(data_1,cluster_row = T, cluster_col = T, na_col = "gray90",
         show_colnames = T,annotation_legend = T,
         main = NA,treeheight_col = 50,legend= T,border_color = "white",
         fontsize = 5,legend_breaks = seq(-9,9,3),angle_col = 0,
         show_rownames = F,scale = "none",
         color = colorRampPalette(c("green","white", "red"))(100))

#dev.off()