From cd9b1ad245bb5bee83990e1a1a224986526847d6 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Tue, 16 Aug 2022 14:45:31 +0100 Subject: [PATCH] stability and cons revised bp out --- .../plotting_thesis/basic_barplots2.R | 114 +++++++++ .../basic_barplots_layout_v2.R | 233 ++++++++---------- 2 files changed, 222 insertions(+), 125 deletions(-) diff --git a/scripts/plotting/plotting_thesis/basic_barplots2.R b/scripts/plotting/plotting_thesis/basic_barplots2.R index 3cccf5e..b75d049 100644 --- a/scripts/plotting/plotting_thesis/basic_barplots2.R +++ b/scripts/plotting/plotting_thesis/basic_barplots2.R @@ -321,6 +321,120 @@ sensP # coord_flip() + scale_x_reverse() # sensP2 +############################################################## +#=================== +# Stability +#=================== +# duetP +duetP = stability_count_bp(plotdf = df3 + , df_colname = "duet_outcome" + , leg_title = "mCSM-DUET" + #, label_categories = labels_duet + , yaxis_title = "Number of nsSNPs" + , leg_position = "none" + , subtitle_text = "mCSM-DUET" + , bar_fill_values = c("#F8766D", "#00BFC4") + , subtitle_colour= "black" + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5 +) +duetP + +# foldx +foldxP = stability_count_bp(plotdf = df3 + , df_colname = "foldx_outcome" + #, leg_title = "FoldX" + #, label_categories = labels_foldx + , yaxis_title = "" + , leg_position = "none" + , subtitle_text = "FoldX" + , bar_fill_values = c("#F8766D", "#00BFC4") + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5 +) + + +# deepddg +deepddgP = stability_count_bp(plotdf = df3 + , df_colname = "deepddg_outcome" + #, leg_title = "DeepDDG" + #, label_categories = labels_deepddg + , yaxis_title = "" + , leg_position = "none" + , subtitle_text = "DeepDDG" + , bar_fill_values = c("#F8766D", "#00BFC4") + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5 +) + + +# deepddg +dynamut2P = stability_count_bp(plotdf = df3 + , df_colname = "ddg_dynamut2_outcome" + #, leg_title = "Dynamut2" + #, label_categories = labels_ddg_dynamut2_outcome + , yaxis_title = "" + , leg_position = "none" + , subtitle_text = "Dynamut2" + , bar_fill_values = c("#F8766D", "#00BFC4") + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5 +) +dynamut2P + + +# provean +proveanP = stability_count_bp(plotdf = df3 + , df_colname = "provean_outcome" + #, leg_title = "PROVEAN" + #, label_categories = labels_provean + , yaxis_title = "Number of nsSNPs" + , leg_position = "none" # top + , subtitle_text = "PROVEAN" + , bar_fill_values = c("#D01C8B", "#F1B6DA") # light pink and deep + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5 +) + +# snap2 +snap2P = stability_count_bp(plotdf = df3 + , df_colname = "snap2_outcome" + #, leg_title = "SNAP2" + #, label_categories = labels_snap2 + , yaxis_title = "" + , leg_position = "none" # top + , subtitle_text = "SNAP2" + , bar_fill_values = c("#D01C8B", "#F1B6DA") # light pink and deep + , sts = 10 + , lts = 8 + , ats = 12 + , als = 11 + , ltis = 11 + , geom_ls = 2.5) + + +############################################################## + ############################## # FIXME for other genes: ATTEMPTED to derive numbers ############################## diff --git a/scripts/plotting/plotting_thesis/basic_barplots_layout_v2.R b/scripts/plotting/plotting_thesis/basic_barplots_layout_v2.R index 2265ced..77062b8 100644 --- a/scripts/plotting/plotting_thesis/basic_barplots_layout_v2.R +++ b/scripts/plotting/plotting_thesis/basic_barplots_layout_v2.R @@ -1,145 +1,127 @@ +duetP +foldxP +deepddgP +dynamut2P +proveanP +snap2P + mLigP mmLigP posC_lig ppi2P posC_ppi2 peP - - +sensP +#======================== +# Common title settings +#========================= 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 +# extract common legends +# lig affinity 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 -# ) +# stability +common_legend_outcome = get_legend(duetP + + guides(color = guide_legend(nrow = 1)) + + theme(legend.position = "top")) +# conservation +cons_common_legend_outcome = get_legend(snap2P + + guides(color = guide_legend(nrow = 1)) + + theme(legend.position = "top")) +################################################################### +#================================== +# Stability+Consevation: COMBINE +#================================== +tt_size = 10 +#---------------------------- +# stability and consv title +#---------------------------- +tt_size = 10 +tt_stab = ggdraw() + + draw_label( + paste0("Stability outcome"), + fontfamily = title_theme$family, + fontface = title_theme$face, + #size = title_theme$size + size = tt_size + ) + +tt_cons = ggdraw() + + draw_label( + paste0("Conservation outcome"), + fontfamily = title_theme$family, + fontface = title_theme$face, + size = tt_size + ) + +#---------------------- +# Output plot +#----------------------- +stab_cons_CLP = paste0(outdir_images + ,tolower(gene) + ,"_stab_cons_BP_CLP.png") + +print(paste0("plot filename:", stab_cons_CLP)) +png(stab_cons_CLP, units = "in", width = 10, height = 5, res = 300 ) + +cowplot::plot_grid( + cowplot::plot_grid( + cowplot::plot_grid( + tt_stab, + common_legend_outcome, + nrow = 2 + ), + cowplot::plot_grid( + duetP, + foldxP, + deepddgP, + dynamut2P, + nrow = 1, + labels = c("A", "B", "C", "D"), + label_size = 12), + nrow = 2, + rel_heights=c(1,10) + ), + NULL, + cowplot::plot_grid( + cowplot::plot_grid( + cowplot::plot_grid( + tt_cons, + cons_common_legend_outcome, + nrow = 2 + ), + cowplot::plot_grid( + proveanP, + snap2P, + nrow=1, + labels = c("E", "F"), + align = "hv"), + nrow = 2, + rel_heights = c(1, 10), + label_size = 12), + nrow=1 + ), + rel_widths = c(2,0.15,1), + nrow=1 +) + +dev.off() + +################################################################# +#======================================= +# Affinity barplots: COMBINE ALL three +#======================================== -# #------------- -# # 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( @@ -150,7 +132,9 @@ lig_affT = ggdraw() + size = 8 ) -p1 = cowplot::plot_grid(cowplot::plot_grid(lig_affT,common_legend_outcome, nrow=2), +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) @@ -217,7 +201,6 @@ mut_impact_CLP = paste0(outdir_images 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" @@ -270,5 +253,5 @@ print(paste0("plot filename:", sensCLP)) png(sensCLP, units = "in", width = 1, height = 1, res = 300 ) sensP dev.off() - +###########################################################