just added some minor tweaks for the logo plots with OR

This commit is contained in:
Tanushree Tunstall 2022-01-16 13:31:32 +00:00
parent 9546355241
commit 1244581cdd
2 changed files with 41 additions and 10 deletions

View file

@ -49,6 +49,7 @@ LogoPlotCustomH <- function(plot_df
, symbol_colname = "mutant_type"
, y_axis_log = F
, log_value = log10
, y_scale_increment = 5
, rm_empty_pos = F
, my_logo_col = "chemistry"
, x_lab = "Position"
@ -80,6 +81,11 @@ LogoPlotCustomH <- function(plot_df
}else{
plot_df = 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)
#-------------------
# logo data: LogOR
#-------------------
@ -91,6 +97,13 @@ LogoPlotCustomH <- function(plot_df
logo_df_plot = logo_df[, c(x_axis_colname, symbol_colname, log_colname)]
logo_dfP_wf = as.matrix(logo_df_plot %>% spread(x_axis_colname, log_colname, fill = 0.0))
#!!! 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_lim = round_any(y_max, y_scale_increment, f = ceiling)
} else {
#-------------------
@ -138,7 +151,7 @@ LogoPlotCustomH <- function(plot_df
ytt_col = "black"
}
LogoPlot = ggseqlogo(logo_dfP_wf
p0 = ggseqlogo(logo_dfP_wf
, method = "custom"
, col_scheme = my_logo_col
, seq_type = "aa") +
@ -157,21 +170,37 @@ LogoPlotCustomH <- function(plot_df
, colour = xtt_col)
, axis.title.y = element_text(size = y_tts
, colour = ytt_col)
, legend.title = element_text(size = y_tts
, legend.title = element_text(size = leg_tts
, colour = ytt_col)
, legend.text = element_text(size = leg_ts)
, legend.text = element_text(size = leg_ts)
, legend.position = leg_pos
, legend.direction = leg_dir
, plot.background = element_rect(fill = theme_bgc)
, legend.text = element_text(size = leg_ts)
, legend.title = element_text(size = leg_tts))+
, plot.background = element_rect(fill = theme_bgc))+
scale_x_discrete(x_lab
#, breaks
, labels = position_or
, limits = factor(1:length(position_or))) +
ylab(y_lab)
, 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)
, limits = c(0, y_lim))
if (y_axis_log){
if (grepl("Log", y_lab)){
y_lab = y_lab
}else{
y_lab = paste("Log", y_lab)
}
LogoPlot = p0 + ylab(y_lab)
}
return(LogoPlot)
}

View file

@ -7,9 +7,11 @@ LogoPlotCustomH (plot_df = merged_df3
, x_axis_colname = "position"
, y_axis_colname = "or_mychisq"
, symbol_colname = "mutant_type"
, y_axis_log = T
, y_axis_log = F
, log_value = log10
, rm_empty_pos = T
, y_scale_increment = 5
, rm_empty_pos = F
, my_logo_col = 'chemistry'
, x_lab = "Position"
, y_lab = "Odds Ratio"