mLigP mmLigP posC_lig ppi2P posC_ppi2 peP theme_georgia <- function(...) { theme_gray(base_family = "sans", ...) + theme(plot.title = element_text(face = "bold")) } title_theme <- calc_element("plot.title", theme_georgia()) ############################################################### common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol) # extract common legend common_legend_outcome = get_legend(mLigP + guides(color = guide_legend(nrow = 1)) + theme(legend.position = "top")) # ############################################################### # #================================ # # Lig Affinity: outcome + site # #================================ # ligT = paste0(common_bp_title, " ligand") # lig_affT = ggdraw() + # draw_label( # ligT, # fontfamily = title_theme$family, # fontface = title_theme$face, # #size = title_theme$size # size = 8 # ) # #------------- # # Outplot # #------------- # ligaffP = paste0(outdir_images # ,tolower(gene) # ,"_lig_oc.png") # # #svg(affP, width = 20, height = 5.5) # print(paste0("plot filename:", ligaffP)) # png(ligaffP, units = "in", width = 6, height = 4, res = 300 ) # cowplot::plot_grid(cowplot::plot_grid(lig_affT,common_legend_outcome, # nrow = 2, # rel_heights = c(1,1) # ), # cowplot::plot_grid(mLigP, mmLigP, posC_lig # , nrow = 1 # #, labels = c("A", "B", "C","D") # , rel_widths = c(1,1,1.8) # , align = "h"), # nrow = 2, # labels = c("A", ""), # label_size = 12, # rel_heights = c(1,8)) # dev.off() # ############################################################# # #================================ # # PPI2 Affinity: outcome + site # #================================ # ppi2T = paste0(common_bp_title, " PP-interface") # ppi2_affT = ggdraw() + # draw_label( # ppi2T, # fontfamily = title_theme$family, # fontface = title_theme$face, # #size = title_theme$size # size = 8 # ) # # # #------------- # # Outplot: PPI2 # #------------- # ppiaffP = paste0(outdir_images # ,tolower(gene) # ,"_ppi2_oc.png") # # #svg(affP, width = 20, height = 5.5) # print(paste0("plot filename:", ppiaffP)) # png(ppiaffP, units = "in", width = 6, height = 4, res = 300 ) # # # cowplot::plot_grid(cowplot::plot_grid(ppi2_affT, common_legend_outcome, # nrow = 2, # rel_heights = c(1,1)), # cowplot::plot_grid(ppi2P, posC_ppi2 # , nrow = 1 # , rel_widths = c(1.2,1.8) # , align = "h" # , label_size = my_label_size), # nrow = 2, # labels = c("B", ""), # label_size = 12, # rel_heights = c(1,8) # ) # # dev.off() # ############################################################# #peP # pe counts #================================ # PE + All position count #================================ # peT_allT = ggdraw() + # draw_label( # paste0("All mutation sites"), # fontfamily = title_theme$family, # fontface = title_theme$face, # #size = title_theme$size # size = 8 # ) # #------------------------ # # Outplot: lig+ppi2+pe # #------------------------ # pe_allCL = paste0(outdir_images # ,tolower(gene) # ,"_pe_oc.png") # # #svg(affP, width = 20, height = 5.5) # print(paste0("plot filename:", pe_allCL)) # png(pe_allCL, units = "in", width = 6, height = 4, res = 300 ) # # # cowplot::plot_grid(peT_allT, # cowplot::plot_grid(peP, posC_all # , nrow = 1 # , rel_widths = c(1, 2) # , align = "h"), # nrow = 2, # labels = c("C", "", ""), # label_size = 12, # rel_heights = c(1,8)) # # dev.off() #=========================================== # COMBINE ALL three #========================================== ligT = paste0(common_bp_title, " ligand") lig_affT = ggdraw() + draw_label( ligT, fontfamily = title_theme$family, fontface = title_theme$face, #size = title_theme$size size = 8 ) p1 = cowplot::plot_grid(cowplot::plot_grid(lig_affT,common_legend_outcome, nrow=2), cowplot::plot_grid(mLigP, mmLigP, posC_lig , nrow = 1 , rel_widths = c(1,1,1.8) , align = "h"), nrow = 2, rel_heights = c(1,8) ) #p1 ########################################################### ppi2T = paste0(common_bp_title, " PP-interface") ppi2_affT = ggdraw() + draw_label( ppi2T, fontfamily = title_theme$family, fontface = title_theme$face, #size = title_theme$size size = 8 ) ########################################################### p2 = cowplot::plot_grid(cowplot::plot_grid(ppi2_affT, common_legend_outcome, nrow=2), cowplot::plot_grid(ppi2P, posC_ppi2 , nrow = 1 , rel_widths = c(1.2,1.8) , align = "h"), nrow = 2, rel_heights = c(1,8) ) #p2 ########################################################### # PE + All position count peT_allT = ggdraw() + draw_label( paste0("All mutation sites"), fontfamily = title_theme$family, fontface = title_theme$face, #size = title_theme$size size = 8 ) p3 = cowplot::plot_grid(cowplot::plot_grid(peT_allT, nrow = 2 , rel_widths = c(1,3),axis = "lr"), cowplot::plot_grid( peP2, posC_all, nrow = 2, rel_widths = c(1,1), align = "v", axis = "lr", rel_heights = c(1,8) ), rel_heights = c(1,18), nrow = 2,axis = "lr") p3 #=============== # Final combine #=============== w = 11.79 h = 3.5 mut_impact_CLP = paste0(outdir_images ,tolower(gene) ,"_mut_impactCLP.png") #svg(affP, width = 20, height = 5.5) print(paste0("plot filename:", mut_impact_CLP)) png(mut_impact_CLP, units = "in", width = w, height = h, res = 300 ) cowplot::plot_grid(p1, p2, p3 , nrow = 1 , labels = "AUTO" , label_size = 12 , rel_widths = c(3,2,2) #, rel_heights = c(1) ) dev.off() ################################################## sensP consurfP #================= # Combine sensitivity + ConSurf # or ConSurf #================= w = 3 h = 3 # sens_conP = paste0(outdir_images # ,tolower(gene) # ,"_sens_cons_CLP.png") # # print(paste0("plot filename:", sens_conP)) # png(sens_conP, units = "in", width = w, height = h, res = 300 ) # # cowplot::plot_grid(sensP, consurfP, # nrow = 2, # rel_heights = c(1, 1.5) # ) # # dev.off() conCLP = paste0(outdir_images ,tolower(gene) ,"_consurf_BP.png") print(paste0("plot filename:", conCLP)) png(conCLP, units = "in", width = w, height = h, res = 300 ) consurfP dev.off() #================================ # Sensitivity numbers: geom_tile #================================ sensCLP = paste0(outdir_images ,tolower(gene) ,"_sensN_tile.png") print(paste0("plot filename:", sensCLP)) png(sensCLP, units = "in", width = 1, height = 1, res = 300 ) sensP dev.off()