From 61c7a30835af8ee4965f21eb586ff1f53a4e644f Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Thu, 4 Aug 2022 10:26:18 +0100 Subject: [PATCH] minor tidy and leble adjust sizes for simple barplots --- scripts/Header_TT.R | 3 ++- scripts/functions/position_count_bp.R | 2 +- scripts/functions/stability_count_bp.R | 13 +++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/Header_TT.R b/scripts/Header_TT.R index e500edb..db6c582 100755 --- a/scripts/Header_TT.R +++ b/scripts/Header_TT.R @@ -223,7 +223,8 @@ consurf_palette2 = c("0" = "yellow2" , "9" = "darkorchid4") -consurf_colours = c("0" = rgb(1.00,1.00,0.59) +consurf_colours = c(#"0" = rgb(1.00,1.00,0.59) + "nsd" = rgb(1.00,1.00,0.59) , "1" = rgb(0.63,0.16,0.37) , "2" = rgb(0.94,0.49,0.67) , "3" = rgb(0.98,0.78,0.86) diff --git a/scripts/functions/position_count_bp.R b/scripts/functions/position_count_bp.R index 876a0fc..75e9917 100755 --- a/scripts/functions/position_count_bp.R +++ b/scripts/functions/position_count_bp.R @@ -95,7 +95,7 @@ site_snp_count_bp <- function (plotdf # FIXME: should really be legend title # but atm being using as plot title #my_leg_title - bp_plot_title = paste0("Total nsSNPs: ", tot_muts + bp_plot_title = paste0("Total SNPs: ", tot_muts , "\nTotal sites: ", tot_sites) #------------- diff --git a/scripts/functions/stability_count_bp.R b/scripts/functions/stability_count_bp.R index 136cd67..190a71b 100644 --- a/scripts/functions/stability_count_bp.R +++ b/scripts/functions/stability_count_bp.R @@ -24,16 +24,20 @@ stability_count_bp <- function(plotdf , geom_ls = 10 # geom_label size , yaxis_title = "Number of nsSNPs" , bp_plot_title = "" - , label_categories = c("Destabilising", "Stabilising") + , label_categories = c("LEVEL1", "LEVEL2") , title_colour = "chocolate4" , subtitle_text = NULL , sts = 20 - , subtitle_colour = "pink" + , subtitle_colour = "#350E20FF" #brown #, leg_position = c(0.73,0.8) # within plot area , leg_position = "top" , bar_fill_values = c("#F8766D", "#00BFC4")){ - -# OutPlot_count = ggplot(plotdf, aes(x = eval(parse(text = df_colname)))) + + + # convert to factor and get labels + plotdf[[df_colname]] = as.factor(plotdf[[df_colname]]) + label_categories = levels(plotdf[[df_colname]]) + + #OutPlot_count = ggplot(plotdf, aes(x = eval(parse(text = df_colname)))) + OutPlot_count = ggplot(plotdf, aes_string(x = df_colname)) + geom_bar(aes(fill = eval(parse(text = df_colname))), show.legend = TRUE) + geom_label(stat = "count" @@ -57,6 +61,7 @@ stability_count_bp <- function(plotdf labs(title = bp_plot_title , subtitle = subtitle_text , y = yaxis_title) + + scale_fill_discrete(name = leg_title , labels = label_categories) +