library(openxlsx) a <- loadWorkbook('Dxterity2/Dxterity4.xlsx') sheetNames <- sheets(a) a11<- read.xlsx('Dxterity2/Dxterity4.xlsx', sheet=2) a11[1:5,1:5] dim(a11) colnames(a11) rownames(a11) which(colnames(a11)=="Timepoint") ### 7 to 40 row_hc<- which(a11[,5]=="HC") row_A<- which(a11[,5]=="A" & a11[,4]=="SLE") length(row_A) data_hc<- a11[c(row_hc), c(10:43)] updated_col<- c(25,27,28,31,23,33,34,14,15,16,18,3,4,17,20,32,30) data_hc1<- data_hc[,updated_col] colnames(data_hc1) data_SLEA<- a11[c(row_A), c(10:43)] updated_col<- c(25,27,28,31,23,33,34,14,15,16,18,3,4,17,20,32,30) data_SLEA1<- data_SLEA[,updated_col] rslea<- a11$Client.Specimen.ID[as.numeric(rownames(data_SLEA1))] #rownames(data_SLEA1)<- rslea rhc<- a11$Client.Specimen.ID[as.numeric(rownames(data_hc1))] rownames(data_hc1)<- rhc .rowNamesDF(data_hc1, make.names=T) <- rhc .rowNamesDF(data_SLEA1, make.names=T) <- rslea cor_hc<- cor(data_hc1,method = "pearson") cor_SLEA<- cor(data_SLEA1,method = "pearson") ########################################################### library(grid) library(ggplotify) markerhccvid<- rbind(data_hc1,data_SLEA1) markerhccvid1<- markerhccvid library(pheatmap) library(RColorBrewer) library(viridis) mat_breaks <- seq(min(markerhccvid1), max(markerhccvid1), length.out = 90) p<- pheatmap( mat = markerhccvid1, color = inferno(length(mat_breaks) - 1), breaks = mat_breaks, border_color = NA, show_colnames = TRUE, show_rownames = TRUE, #annotation_col = mat_col, #annotation_colors = mat_colors, drop_levels = TRUE, fontsize = 14, main = "Heatmap of HC and SLE at Timepoint A" ) pdf("Dxterity2/heatmap_hc_SLEA.pdf", 7, 8) p dev.off() ######################################## mat_breaks <- seq(-1, 1, length.out = 90) p1<- pheatmap( mat = cor_hc, color = inferno(length(mat_breaks) - 1), breaks = mat_breaks, border_color = NA, show_colnames = TRUE, show_rownames = TRUE, #annotation_col = mat_col, #annotation_colors = mat_colors, drop_levels = TRUE, fontsize = 14, main = "Correlation heatmap of HC" ) pdf("Dxterity2/corr_heatmap_hc.pdf", 7, 8) p1 dev.off() ##### cluster_rows=FALSE, cluster_cols=FALSE mat_breaks <- seq(-1, 1, length.out = 90) p11<- pheatmap( mat = cor_hc, color = inferno(length(mat_breaks) - 1), breaks = mat_breaks, border_color = NA, show_colnames = TRUE, show_rownames = TRUE, #annotation_col = mat_col, #annotation_colors = mat_colors, drop_levels = TRUE, fontsize = 14,cluster_rows=FALSE, cluster_cols=FALSE, main = "Ordered correlation heatmap of HC", ) pdf("Dxterity2/ordered_corr_heatmap_hc.pdf", 7, 8) p11 dev.off() ############################################################################ ######################################## mat_breaks <- seq(-1, 1, length.out = 90) p2<- pheatmap( mat = cor_SLEA, color = inferno(length(mat_breaks) - 1), breaks = mat_breaks, border_color = NA, show_colnames = TRUE, show_rownames = TRUE, #annotation_col = mat_col, #annotation_colors = mat_colors, drop_levels = TRUE, fontsize = 14, main = "Correlation heatmap of SLE at timepoint A" ) pdf("Dxterity2/corr_heatmap_SLEA.pdf", 7, 8) p2 dev.off() ##### cluster_rows=FALSE, cluster_cols=FALSE mat_breaks <- seq(-1, 1, length.out = 90) p21<- pheatmap( mat = cor_SLEA, color = inferno(length(mat_breaks) - 1), breaks = mat_breaks, border_color = NA, show_colnames = TRUE, show_rownames = TRUE, #annotation_col = mat_col, #annotation_colors = mat_colors, drop_levels = TRUE, fontsize = 14,cluster_rows=FALSE, cluster_cols=FALSE, main = "Ordered correlation heatmap of SLE at timepoint A", ) pdf("Dxterity2/ordered_corr_heatmap_SLEA.pdf", 7, 8) p21 dev.off()