From 424c1d184d4d9c9581e8bc257a5e7d2874b2fc99 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Thu, 4 Aug 2022 19:29:20 +0100 Subject: [PATCH] added linage barplots --- .../lineage_barplots_combined.R | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 scripts/plotting/plotting_thesis/lineage_barplots_combined.R diff --git a/scripts/plotting/plotting_thesis/lineage_barplots_combined.R b/scripts/plotting/plotting_thesis/lineage_barplots_combined.R new file mode 100644 index 0000000..01f6428 --- /dev/null +++ b/scripts/plotting/plotting_thesis/lineage_barplots_combined.R @@ -0,0 +1,68 @@ +# get plotting_dfs() +# using dfs [lf and wf] from lineage_dfL +#=============================== +# lineage sample and SNP count +#=============================== +lin_countP = lin_count_bp(lf_data = lineage_dfL[['lin_lf']] + , all_lineages = F + , x_categ = "sel_lineages" + , y_count = "p_count" + , use_lineages = c("L1", "L2", "L3", "L4") + , bar_fill_categ = "count_categ" + , display_label_col = "p_count" + , bar_stat_stype = "identity" + , d_lab_size = 10 + , d_lab_col = "black" + , my_xats = 25 # x axis text size + , my_yats = 25 # y axis text size + , my_xals = 25 # x axis label size + , my_yals = 25 # y axis label size + , my_lls = 25 # legend label size + , bar_col_labels = c("SNPs", "Total Samples") + , bar_col_values = c("grey50", "gray75") + , bar_leg_name = "" + , leg_location = "top" + , y_log10 = F + , y_scale_percent = FALSE + , y_label = c("Count") + ) + +#=============================== +# lineage SNP diversity count +#=============================== +lin_diversityP = lin_count_bp_diversity(lf_data = lineage_dfL[['lin_wf']] + , x_categ = "sel_lineages" + , y_count = "snp_diversity" + #, all_lineages = F + , use_lineages = c("L1", "L2", "L3", "L4") + , display_label_col = "snp_diversity_f" + , bar_stat_stype = "identity" + , x_lab_angle = 90 + , d_lab_size =10 + , my_xats = 25 # x axis text size + , my_yats = 25 # y axis text size + , my_xals = 25 # x axis label size + , my_yals = 25 # y axis label size + , my_lls = 25 # legend label size + , y_log10 = F + , y_scale_percent = F + , leg_location = "top" + , y_label = "SNP diversity") + +#============================================= +# Output plots: Lineage count and Diversity +#============================================= +lineage_bp_CL = paste0(outdir_images + ,tolower(gene) + ,"_lineage_bp_CL.svg") + +cat("Lineage barplots:", lineage_bp_CL) +svg(lineage_bp_CL, width = 8, height = 15) + +cowplot::plot_grid(lin_countP, lin_diversityP + #, labels = c("(a)", "(b)", "(c)", "(d)") + , nrow = 2 + , labels = "AUTO" + , label_size = 25) + +dev.off() \ No newline at end of file