From bf3194259e2bba024c0ddedd5fd070ee3f01bcf4 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Wed, 2 Mar 2022 15:54:09 +0000 Subject: [PATCH] lineage: toggle for "all lineages" --- scripts/functions/bp_lineage.R | 7 +++++++ scripts/functions/bp_lineage_diversity.R | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/scripts/functions/bp_lineage.R b/scripts/functions/bp_lineage.R index d21a465..e5116f3 100644 --- a/scripts/functions/bp_lineage.R +++ b/scripts/functions/bp_lineage.R @@ -7,6 +7,8 @@ lin_count_bp <- function( lf_data = lin_lf , x_categ = "sel_lineages" , y_count = "p_count" + , all_lineages = F + , use_lineages = c("L1", "L2", "L3", "L4") , bar_fill_categ = "count_categ" , display_label_col = "p_count" , bar_stat_stype = "identity" @@ -29,6 +31,11 @@ lin_count_bp <- function( lf_data = lin_lf , y_label = c("Count", "SNP diversity") #, y_label = c("Count") ) { + if(!all_lineages){ + #lf_data = lf_data[lf_data$sel_lineages%in%use_lineages,] + lf_data = lf_data[lf_data[[x_categ]]%in%use_lineages,] + } + g = ggplot(lf_data , aes( x = factor( eval(parse(text = x_categ)), ordered = T ) , y = eval(parse(text = y_count)) diff --git a/scripts/functions/bp_lineage_diversity.R b/scripts/functions/bp_lineage_diversity.R index ee0cada..40a7210 100644 --- a/scripts/functions/bp_lineage_diversity.R +++ b/scripts/functions/bp_lineage_diversity.R @@ -7,6 +7,8 @@ lin_count_bp_diversity <- function( lf_data = lin_wf , x_categ = "sel_lineages" , y_count = "snp_diversity" + , all_lineages = F + , use_lineages = c("L1", "L2", "L3", "L4") #, bar_fill_categ = "count_categ" , display_label_col = "snp_diversity_f" , bar_stat_stype = "identity" @@ -29,6 +31,10 @@ lin_count_bp_diversity <- function( lf_data = lin_wf #, y_label = c("Count", "SNP diversity") , y_label = c("SNP diversity") ) { + if(!all_lineages){ + lf_data = lf_data[lf_data[[x_categ]]%in%use_lineages,] + } + g = ggplot(lf_data , aes( x = factor( eval(parse(text = x_categ)), ordered = T ) , y = eval(parse(text = y_count))