From efe67036736f51b1bec352fbf710bb3b727e93aa Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Sun, 16 Jan 2022 14:45:39 +0000 Subject: [PATCH] attempted omitting snp from logo plot for OR --- scripts/functions/logoP.R | 25 ++++++++++--------------- scripts/functions/logoP_snp.R | 3 --- scripts/functions/tests/test_logoP.R | 7 ++----- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/scripts/functions/logoP.R b/scripts/functions/logoP.R index d25fd24..3066d9c 100644 --- a/scripts/functions/logoP.R +++ b/scripts/functions/logoP.R @@ -49,22 +49,17 @@ LogoPlotCustomH <- function(plot_df , symbol_colname = "mutant_type" , y_axis_log = F , log_value = log10 - , y_scale_increment = 5 - , rm_empty_pos = F + , y_axis_increment = 5 + , rm_empty_y = F , my_logo_col = "chemistry" , x_lab = "Position" , y_lab = "Odds Ratio" , x_ats = 12 # text size , x_tangle = 90 # text angle - #, theme_bgc - #, xfont_bgc - #, yfont_bgc , y_ats = 22 , y_tangle = 0 , x_tts = 20 # title size , y_tts = 23 - #, xtt_col = - #, ytt_col = , leg_pos = "none" # can be top, left, right and bottom or c(0.8, 0.9) , leg_dir = "horizontal" #can be vertical or horizontal , leg_ts = 15 # leg text size @@ -75,7 +70,7 @@ LogoPlotCustomH <- function(plot_df ################################# # Data processing for logo plot ################################# - if (rm_empty_pos){ + if (rm_empty_y){ plot_df = plot_df[!is.na(plot_df[y_axis_colname]),] cat("\nRemoving empty positions...\n") }else{ @@ -83,8 +78,8 @@ LogoPlotCustomH <- function(plot_df } y_max = max(plot_df['or_mychisq'], na.rm = T) - cat("\nRemoving y scale incremenet:", y_scale_increment) - y_lim = round_any(y_max, y_scale_increment, f = ceiling) + cat("\nRemoving y scale incremenet:", y_axis_increment) + y_lim = round_any(y_max, y_axis_increment, f = ceiling) #------------------- # logo data: LogOR @@ -99,10 +94,10 @@ LogoPlotCustomH <- function(plot_df #!!! For consideration: to add y_axis 'breaks' and 'limits' !!! #y_max = max(plot_df[[log_colname]], na.rm = T) - #y_scale_increment = - #cat("\nRemoving y scale incremenet:", y_scale_increment) + #y_axis_increment = + #cat("\nRemoving y scale incremenet:", y_axis_increment) - #y_lim = round_any(y_max, y_scale_increment, f = ceiling) + #y_lim = round_any(y_max, y_axis_increment, f = ceiling) } else { @@ -184,8 +179,8 @@ LogoPlotCustomH <- function(plot_df , limits = factor(1:length(position_or))) LogoPlot = p0 + scale_y_continuous(y_lab - , breaks = seq(0, (y_lim), by = y_scale_increment) - #, labels = seq(0, (y_lim), by = y_scale_increment) + , breaks = seq(0, (y_lim), by = y_axis_increment) + #, labels = seq(0, (y_lim), by = y_axis_increment) , limits = c(0, y_lim)) if (y_axis_log){ diff --git a/scripts/functions/logoP_snp.R b/scripts/functions/logoP_snp.R index 52eeafa..fa01541 100644 --- a/scripts/functions/logoP_snp.R +++ b/scripts/functions/logoP_snp.R @@ -23,7 +23,6 @@ LogoPlotSnps <- function(plot_df , symbol_mut_colname = "mutant_type" , symbol_wt_colname = "mutant_type" , omit_snp_count = c(0) # can be 1, 2, etc. - , my_logo_col = "chemistry" , x_lab = "Position" , y_lab = "Count" @@ -52,8 +51,6 @@ LogoPlotSnps <- function(plot_df max_mut = max(table(plot_df[[x_axis_colname]])) # Subset Data as specified by user - pos_freqC = c(1:max_mut) - cat("\nDisplaying nsSNP position frequency:\n") print(table(plot_df$mut_pos_occurrence)) diff --git a/scripts/functions/tests/test_logoP.R b/scripts/functions/tests/test_logoP.R index 006c43e..9daeb42 100644 --- a/scripts/functions/tests/test_logoP.R +++ b/scripts/functions/tests/test_logoP.R @@ -1,17 +1,14 @@ - #source("~/git/LSHTM_analysis/config/gid.R") #source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R") - LogoPlotCustomH (plot_df = merged_df3 , x_axis_colname = "position" , y_axis_colname = "or_mychisq" , symbol_colname = "mutant_type" , y_axis_log = F , log_value = log10 - , y_scale_increment = 5 - - , rm_empty_pos = F + , y_axis_increment = 5 + , rm_empty_y = T , my_logo_col = 'chemistry' , x_lab = "Position" , y_lab = "Odds Ratio"