AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
This commit is contained in:
parent
cd9b1ad245
commit
c9d7ea9fad
10 changed files with 208 additions and 128 deletions
|
@ -81,13 +81,11 @@ LogoPlotCustomH <- function(plot_df
|
|||
|
||||
|
||||
if (rm_empty_y){
|
||||
cat(paste0("Original Rows: ",nrow(plot_df)))
|
||||
plot_df = plot_df[!is.na(plot_df[y_axis_colname]),]
|
||||
cat("\nRemoving empty positions...\n")
|
||||
cat(paste0("Plotting Rows after removing NAs: ",nrow(plot_df)))
|
||||
}
|
||||
|
||||
y_max = max(plot_df[[y_axis_colname]], na.rm = T)
|
||||
cat("\nRemoving y scale incremenet:", y_axis_increment)
|
||||
y_lim = round_any(y_max, y_axis_increment, f = ceiling)
|
||||
|
||||
#-------------------
|
||||
# logo data: LogOR
|
||||
|
@ -98,8 +96,10 @@ LogoPlotCustomH <- function(plot_df
|
|||
plot_df[log_colname] = log_value(plot_df[y_axis_colname])
|
||||
logo_df = plot_df[, c(x_axis_colname, symbol_colname, log_colname)]
|
||||
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))
|
||||
|
||||
logo_df_plot = logo_df_plot %>% spread(x_axis_colname, y_axis_colname, fill = 0.0)
|
||||
rownames(logo_df_plot) = logo_df_plot$mutant_type
|
||||
logo_df_plot$mutant_type = NULL
|
||||
logo_dfP_wf=as.matrix(logo_df_plot)
|
||||
#!!! For consideration: to add y_axis 'breaks' and 'limits' !!!
|
||||
#y_max = max(plot_df[[log_colname]], na.rm = T)
|
||||
#y_axis_increment =
|
||||
|
@ -114,18 +114,28 @@ LogoPlotCustomH <- function(plot_df
|
|||
#-------------------
|
||||
logo_df = plot_df[, c(x_axis_colname, symbol_colname, y_axis_colname)]
|
||||
logo_df_plot = logo_df[, c(x_axis_colname, symbol_colname, y_axis_colname)]
|
||||
logo_dfP_wf = as.matrix(logo_df_plot %>% spread(x_axis_colname, y_axis_colname, fill = 0.0))
|
||||
logo_df_plot = logo_df_plot %>% spread(x_axis_colname, y_axis_colname, fill = 0.0)
|
||||
rownames(logo_df_plot) = logo_df_plot$mutant_type
|
||||
logo_df_plot$mutant_type = NULL
|
||||
logo_dfP_wf=as.matrix(logo_df_plot)
|
||||
|
||||
#logo_dfP_wf = as.matrix(logo_df_plot %>% spread(x_axis_colname, y_axis_colname, fill = 0.0))
|
||||
}
|
||||
|
||||
#class(logo_dfP_wf)
|
||||
|
||||
rownames(logo_dfP_wf) = logo_dfP_wf[,1]
|
||||
#rownames(logo_dfP_wf) = logo_dfP_wf[,1]
|
||||
#dim(logo_dfP_wf)
|
||||
|
||||
logo_dfP_wf = logo_dfP_wf[,-1]
|
||||
#logo_dfP_wf = logo_dfP_wf[,-1]
|
||||
#str(logo_dfP_wf)
|
||||
|
||||
#y_max = max(plot_df[[y_axis_colname]], na.rm = T)
|
||||
y_max = max(colSums(logo_dfP_wf))
|
||||
cat("\nRemoving y scale incremenet:", y_axis_increment)
|
||||
y_lim = round_any(y_max, y_axis_increment, f = ceiling)
|
||||
|
||||
|
||||
#colnames(logo_dfP_wf)
|
||||
position_or = as.numeric(colnames(logo_dfP_wf))
|
||||
|
||||
|
@ -167,11 +177,12 @@ LogoPlotCustomH <- function(plot_df
|
|||
ggplot() +
|
||||
geom_logo(logo_dfP_wf
|
||||
, method = "custom"
|
||||
#, method = "bits"
|
||||
, col_scheme = my_logo_col
|
||||
, seq_type = "aa") +
|
||||
#ylab("my custom height") +
|
||||
theme( axis.ticks.x = element_blank()
|
||||
, axis.ticks.length = unit(0, "pt")
|
||||
theme( axis.ticks = element_blank()
|
||||
#, axis.ticks.length = unit(0, "pt")
|
||||
, axis.title.x = element_blank()
|
||||
# , axis.text.x = element_blank() # turn this off and the below on if you want to visually
|
||||
# verify positions.
|
||||
|
@ -206,10 +217,13 @@ LogoPlotCustomH <- function(plot_df
|
|||
, labels = position_or
|
||||
, limits = factor(1:length(position_or))) +
|
||||
|
||||
scale_y_continuous(y_lab
|
||||
, breaks = seq(0, (y_lim), by = y_axis_increment)
|
||||
#, labels = seq(0, (y_lim), by = y_axis_increment)
|
||||
, limits = c(0, y_lim)) +
|
||||
scale_y_continuous(y_lab,
|
||||
breaks = seq(0,
|
||||
(y_lim),
|
||||
by = y_axis_increment
|
||||
),
|
||||
limits = c(0, y_lim)
|
||||
) +
|
||||
labs(y=y_lab),
|
||||
position_annotation(plot_df,
|
||||
bg = theme_bgc,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue