This commit is contained in:
Tanushree Tunstall 2022-08-05 16:13:57 +01:00
parent 6cb9998c4c
commit 33925dafe9
4 changed files with 142 additions and 99 deletions

View file

@ -25,7 +25,7 @@ lf_bp <- function(lf_df = lf_duet
, make_boxplot = FALSE
, bp_width = c("auto", 0.5)
, add_stats = TRUE
, stat_grp_comp = c("DM", "OM")
, stat_grp_comp = c("R", "S")
, stat_method = "wilcox.test"
, my_paired = FALSE
, stat_label = c("p.format", "p.signif") ){
@ -129,77 +129,77 @@ lf_bp <- function(lf_df = lf_duet
# TODO: plot_ly()
#############################
lf_bp_plotly <- function(lf_df
, p_title = ""
, colour_categ = ""
, x_grp = mutation_info
, y_var = param_value
, facet_var = param_type
, n_facet_row = 1
, y_scales = "free_y"
, colour_bp_strip = "khaki2"
, dot_size = 3
, dot_transparency = 0.3
, violin_quantiles = c(0.25, 0.5, 0.75) # can be NULL
, my_ats = 20 # axis text size
, my_als = 18 # axis label size
, my_fls = 18 # facet label size
, my_pts = 22 # plot title size)
#, make_boxplot = FALSE
, bp_width = c("auto", 0.5)
#, add_stats = FALSE
#, stat_grp_comp = c("DM", "OM")
#, stat_method = "wilcox.test"
#, my_paired = FALSE
#, stat_label = c("p.format", "p.signif")
){
OutPlotly = ggplot(lf_df, aes(x = eval(parse(text = x_grp))
, y = eval(parse(text = y_var))
, label1 = x_grp
, label2 = y_var
, lable3 = colour_categ) ) +
facet_wrap(~ eval(parse(text = facet_var))
, nrow = n_facet_row
, scales = y_scales) +
geom_violin(trim = T
, scale = "width"
, draw_quantiles = violin_quantiles) +
geom_beeswarm(priority = "density"
, size = dot_size
, alpha = dot_transparency
, show.legend = FALSE
, cex = 0.8
, aes(colour = factor(eval(parse(text = colour_categ) ) ) ) ) +
theme(axis.text.x = element_text(size = my_ats)
, axis.text.y = element_text(size = my_ats
, angle = 0
, hjust = 1
, vjust = 0)
, axis.title.x = element_text(size = my_ats)
, axis.title.y = element_text(size = my_ats)
, plot.title = element_text(size = my_pts
, hjust = 0.5
, colour = "black"
, face = "bold")
, strip.background = element_rect(fill = colour_bp_strip)
, strip.text.x = element_text(size = my_fls
, colour = "black")
, legend.title = element_text(color = "black"
, size = my_als)
, legend.text = element_text(size = my_ats)
, legend.position = "none")+
labs(title = p_title
, x = ""
, y = "")
OutPlotly = ggplotly(OutPlotly
#, tooltip = c("label")
)
return(OutPlotly)
}
# lf_bp_plotly <- function(lf_df
# , p_title = ""
# , colour_categ = ""
# , x_grp = mutation_info
# , y_var = param_value
# , facet_var = param_type
# , n_facet_row = 1
# , y_scales = "free_y"
# , colour_bp_strip = "khaki2"
# , dot_size = 3
# , dot_transparency = 0.3
# , violin_quantiles = c(0.25, 0.5, 0.75) # can be NULL
# , my_ats = 20 # axis text size
# , my_als = 18 # axis label size
# , my_fls = 18 # facet label size
# , my_pts = 22 # plot title size)
# #, make_boxplot = FALSE
# , bp_width = c("auto", 0.5)
# #, add_stats = FALSE
# #, stat_grp_comp = c("DM", "OM")
# #, stat_method = "wilcox.test"
# #, my_paired = FALSE
# #, stat_label = c("p.format", "p.signif")
# ){
#
# OutPlotly = ggplot(lf_df, aes(x = eval(parse(text = x_grp))
# , y = eval(parse(text = y_var))
# , label1 = x_grp
# , label2 = y_var
# , lable3 = colour_categ) ) +
#
# facet_wrap(~ eval(parse(text = facet_var))
# , nrow = n_facet_row
# , scales = y_scales) +
#
# geom_violin(trim = T
# , scale = "width"
# , draw_quantiles = violin_quantiles) +
#
# geom_beeswarm(priority = "density"
# , size = dot_size
# , alpha = dot_transparency
# , show.legend = FALSE
# , cex = 0.8
# , aes(colour = factor(eval(parse(text = colour_categ) ) ) ) ) +
# theme(axis.text.x = element_text(size = my_ats)
# , axis.text.y = element_text(size = my_ats
# , angle = 0
# , hjust = 1
# , vjust = 0)
# , axis.title.x = element_text(size = my_ats)
# , axis.title.y = element_text(size = my_ats)
# , plot.title = element_text(size = my_pts
# , hjust = 0.5
# , colour = "black"
# , face = "bold")
# , strip.background = element_rect(fill = colour_bp_strip)
# , strip.text.x = element_text(size = my_fls
# , colour = "black")
# , legend.title = element_text(color = "black"
# , size = my_als)
# , legend.text = element_text(size = my_ats)
# , legend.position = "none")+
#
# labs(title = p_title
# , x = ""
# , y = "")
#
# OutPlotly = ggplotly(OutPlotly
# #, tooltip = c("label")
# )
# return(OutPlotly)
#
# }