attempted omitting snp from logo plot for OR

This commit is contained in:
Tanushree Tunstall 2022-01-16 14:45:39 +00:00
parent 1244581cdd
commit efe6703673
3 changed files with 12 additions and 23 deletions

View file

@ -49,22 +49,17 @@ LogoPlotCustomH <- function(plot_df
, symbol_colname = "mutant_type" , symbol_colname = "mutant_type"
, y_axis_log = F , y_axis_log = F
, log_value = log10 , log_value = log10
, y_scale_increment = 5 , y_axis_increment = 5
, rm_empty_pos = F , rm_empty_y = F
, my_logo_col = "chemistry" , my_logo_col = "chemistry"
, x_lab = "Position" , x_lab = "Position"
, y_lab = "Odds Ratio" , y_lab = "Odds Ratio"
, x_ats = 12 # text size , x_ats = 12 # text size
, x_tangle = 90 # text angle , x_tangle = 90 # text angle
#, theme_bgc
#, xfont_bgc
#, yfont_bgc
, y_ats = 22 , y_ats = 22
, y_tangle = 0 , y_tangle = 0
, x_tts = 20 # title size , x_tts = 20 # title size
, y_tts = 23 , y_tts = 23
#, xtt_col =
#, ytt_col =
, leg_pos = "none" # can be top, left, right and bottom or c(0.8, 0.9) , 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_dir = "horizontal" #can be vertical or horizontal
, leg_ts = 15 # leg text size , leg_ts = 15 # leg text size
@ -75,7 +70,7 @@ LogoPlotCustomH <- function(plot_df
################################# #################################
# Data processing for logo plot # Data processing for logo plot
################################# #################################
if (rm_empty_pos){ if (rm_empty_y){
plot_df = plot_df[!is.na(plot_df[y_axis_colname]),] plot_df = plot_df[!is.na(plot_df[y_axis_colname]),]
cat("\nRemoving empty positions...\n") cat("\nRemoving empty positions...\n")
}else{ }else{
@ -83,8 +78,8 @@ LogoPlotCustomH <- function(plot_df
} }
y_max = max(plot_df['or_mychisq'], na.rm = T) y_max = max(plot_df['or_mychisq'], na.rm = T)
cat("\nRemoving y scale incremenet:", y_scale_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)
#------------------- #-------------------
# logo data: LogOR # logo data: LogOR
@ -99,10 +94,10 @@ LogoPlotCustomH <- function(plot_df
#!!! For consideration: to add y_axis 'breaks' and 'limits' !!! #!!! For consideration: to add y_axis 'breaks' and 'limits' !!!
#y_max = max(plot_df[[log_colname]], na.rm = T) #y_max = max(plot_df[[log_colname]], na.rm = T)
#y_scale_increment = #y_axis_increment =
#cat("\nRemoving y scale incremenet:", y_scale_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 { } else {
@ -184,8 +179,8 @@ LogoPlotCustomH <- function(plot_df
, limits = factor(1:length(position_or))) , limits = factor(1:length(position_or)))
LogoPlot = p0 + scale_y_continuous(y_lab LogoPlot = p0 + scale_y_continuous(y_lab
, breaks = seq(0, (y_lim), by = y_scale_increment) , breaks = seq(0, (y_lim), by = y_axis_increment)
#, labels = seq(0, (y_lim), by = y_scale_increment) #, labels = seq(0, (y_lim), by = y_axis_increment)
, limits = c(0, y_lim)) , limits = c(0, y_lim))
if (y_axis_log){ if (y_axis_log){

View file

@ -23,7 +23,6 @@ LogoPlotSnps <- function(plot_df
, symbol_mut_colname = "mutant_type" , symbol_mut_colname = "mutant_type"
, symbol_wt_colname = "mutant_type" , symbol_wt_colname = "mutant_type"
, omit_snp_count = c(0) # can be 1, 2, etc. , omit_snp_count = c(0) # can be 1, 2, etc.
, my_logo_col = "chemistry" , my_logo_col = "chemistry"
, x_lab = "Position" , x_lab = "Position"
, y_lab = "Count" , y_lab = "Count"
@ -52,8 +51,6 @@ LogoPlotSnps <- function(plot_df
max_mut = max(table(plot_df[[x_axis_colname]])) max_mut = max(table(plot_df[[x_axis_colname]]))
# Subset Data as specified by user # Subset Data as specified by user
pos_freqC = c(1:max_mut)
cat("\nDisplaying nsSNP position frequency:\n") cat("\nDisplaying nsSNP position frequency:\n")
print(table(plot_df$mut_pos_occurrence)) print(table(plot_df$mut_pos_occurrence))

View file

@ -1,17 +1,14 @@
#source("~/git/LSHTM_analysis/config/gid.R") #source("~/git/LSHTM_analysis/config/gid.R")
#source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R") #source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
LogoPlotCustomH (plot_df = merged_df3 LogoPlotCustomH (plot_df = merged_df3
, x_axis_colname = "position" , x_axis_colname = "position"
, y_axis_colname = "or_mychisq" , y_axis_colname = "or_mychisq"
, symbol_colname = "mutant_type" , symbol_colname = "mutant_type"
, y_axis_log = F , y_axis_log = F
, log_value = log10 , log_value = log10
, y_scale_increment = 5 , y_axis_increment = 5
, rm_empty_y = T
, rm_empty_pos = F
, my_logo_col = 'chemistry' , my_logo_col = 'chemistry'
, x_lab = "Position" , x_lab = "Position"
, y_lab = "Odds Ratio" , y_lab = "Odds Ratio"