From 9784cba232bc8523387401d713a07166d920f3ea Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Tue, 6 Oct 2020 18:15:50 +0100 Subject: [PATCH] generated labelled ps_plots_combined.R and capital "P" for position in barplots coloured aa for Lig --- scripts/plotting/barplots_subcolours_aa_LIG.R | 8 ++-- scripts/plotting/ps_plots_combined.R | 37 ++++++++++++++----- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/scripts/plotting/barplots_subcolours_aa_LIG.R b/scripts/plotting/barplots_subcolours_aa_LIG.R index f00466b..9f7a70f 100755 --- a/scripts/plotting/barplots_subcolours_aa_LIG.R +++ b/scripts/plotting/barplots_subcolours_aa_LIG.R @@ -20,7 +20,7 @@ library(ggplot2) library(data.table) source("barplot_colour_function.R") #source("subcols_axis.R") -source("subcols_axis_PS.R") +source("subcols_axis.R") # should return the following dfs, directories and variables # mut_pos_cols @@ -218,7 +218,7 @@ svg(plot_bp_aa_subcols_ligand, width = 26, height = 4) g = ggplot(df, aes(factor(position, ordered = T))) -outPlot = g + +OutPlot = g + coord_cartesian(xlim = c(1, my_xlim) #, ylim = c(0, 6) , ylim = c(0, max(snp_count)) @@ -249,10 +249,10 @@ outPlot = g + , axis.ticks.x = element_blank()) + labs(title = "" #title = my_title - , x = "position" + , x = "Position" , y = "Frequency") -print(outPlot) +print(OutPlot) dev.off() #!!!!!!!!!!!!!!!! diff --git a/scripts/plotting/ps_plots_combined.R b/scripts/plotting/ps_plots_combined.R index afcdc25..d62d8ee 100644 --- a/scripts/plotting/ps_plots_combined.R +++ b/scripts/plotting/ps_plots_combined.R @@ -219,6 +219,7 @@ p2 = g2 + , colour = "black" , fill = "lightgray" , stat = "identity") + + scale_y_continuous(limits = c(0, 450))+ theme(axis.text.x = element_blank() , axis.text.y = element_text(size = my_ats , angle = 0 @@ -235,17 +236,33 @@ p2 ######################################################################## # end of DUET barplots # ######################################################################## -#======= -# output -#======= -ps_plots_combined = "af_or_combined_PS.svg" -plot_ps_plots_combined = paste0(plotdir,"/", ps_plots_combined ) +#============================ +# combined plot 1: UNlabelled +#============================ +ps_combined = "af_or_combined_PS.svg" +plot_ps_combined = paste0(plotdir,"/", ps_combined) +cat("combined plot Unlabelled:", plot_ps_combined) -svg(plot_ps_plots_combined , width = 26, height = 12) - -#theme_set(theme_gray()) # to preserve default theme -printFile = cowplot::plot_grid(p1, p2, p3 +svg(plot_ps_combined , width = 26, height = 12) +OutPlot_combined = cowplot::plot_grid(p1, p2, p3 , ncol = 1 , align = 'v') -printFile +OutPlot_combined dev.off() + +#============================ +# combined plot 2: labelled +#============================ +ps_combined_labelled = "af_or_combined_PS_labelled.svg" +plot_ps_combined_labelled = paste0(plotdir,"/", ps_combined_labelled) +cat("combined plot Labelled:", plot_ps_combined_labelled) + +svg(plot_ps_combined_labelled , width = 26, height = 12) +OutPlot_combined_labelled = cowplot::plot_grid(p1, p2, p3 + , ncol = 1 + , labels = c("(a)", "(b)", "(c)") + , label_size = 21 + , align = 'v' + , hjust = -0.4) +OutPlot_combined_labelled +dev.off() \ No newline at end of file