lineage: toggle for "all lineages"

This commit is contained in:
Tanushree Tunstall 2022-03-02 15:54:09 +00:00
parent 6c6709e41e
commit bf3194259e
2 changed files with 13 additions and 0 deletions

View file

@ -7,6 +7,8 @@
lin_count_bp <- function( lf_data = lin_lf lin_count_bp <- function( lf_data = lin_lf
, x_categ = "sel_lineages" , x_categ = "sel_lineages"
, y_count = "p_count" , y_count = "p_count"
, all_lineages = F
, use_lineages = c("L1", "L2", "L3", "L4")
, bar_fill_categ = "count_categ" , bar_fill_categ = "count_categ"
, display_label_col = "p_count" , display_label_col = "p_count"
, bar_stat_stype = "identity" , 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", "SNP diversity")
#, y_label = c("Count") #, 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 g = ggplot(lf_data
, aes( x = factor( eval(parse(text = x_categ)), ordered = T ) , aes( x = factor( eval(parse(text = x_categ)), ordered = T )
, y = eval(parse(text = y_count)) , y = eval(parse(text = y_count))

View file

@ -7,6 +7,8 @@
lin_count_bp_diversity <- function( lf_data = lin_wf lin_count_bp_diversity <- function( lf_data = lin_wf
, x_categ = "sel_lineages" , x_categ = "sel_lineages"
, y_count = "snp_diversity" , y_count = "snp_diversity"
, all_lineages = F
, use_lineages = c("L1", "L2", "L3", "L4")
#, bar_fill_categ = "count_categ" #, bar_fill_categ = "count_categ"
, display_label_col = "snp_diversity_f" , display_label_col = "snp_diversity_f"
, bar_stat_stype = "identity" , 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("Count", "SNP diversity")
, y_label = c("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 g = ggplot(lf_data
, aes( x = factor( eval(parse(text = x_categ)), ordered = T ) , aes( x = factor( eval(parse(text = x_categ)), ordered = T )
, y = eval(parse(text = y_count)) , y = eval(parse(text = y_count))