68 lines
2.7 KiB
R
68 lines
2.7 KiB
R
library(ggpubr)
|
|
###################################################################
|
|
|
|
####################################
|
|
lf_bp_with_stats <- function(lf_df
|
|
, x_grp = "mutation_info"
|
|
, y_var = "param_value"
|
|
, facet_var = "param_type"
|
|
, n_facet_row = 1
|
|
, y_scales = "free_y"
|
|
, p_title = ""
|
|
, colour_categ = ""
|
|
, colour_bp_strip = "khaki2"
|
|
, stat_grp_comp = c("DM", "OM")
|
|
, stat_method = "wilcox.test"
|
|
, my_paired = FALSE
|
|
#, stat_label = "p.format")
|
|
, stat_label = c("p.format", "p.signif")
|
|
, my_ats = 22 # axis text size
|
|
, my_als = 20 # axis label size
|
|
, my_fls = 20 # facet label size
|
|
, my_pts = 22 # plot title size
|
|
) {
|
|
my_comparisonsL <- list( stat_grp_comp )
|
|
|
|
bp_statP <- ggplot(lf_df, aes(x = eval(parse(text = x_grp))
|
|
, y = eval(parse(text = y_var)) )) +
|
|
|
|
facet_wrap(~ eval(parse(text = facet_var))
|
|
, nrow = n_facet_row
|
|
, scales = y_scales) +
|
|
|
|
geom_boxplot(fill = "white", outlier.colour = NA
|
|
#, position = position_dodge(width = 0.9)
|
|
, width = 0.2) +
|
|
|
|
geom_point(position = position_jitterdodge(dodge.width = 0.01)
|
|
, alpha = 0.5
|
|
, show.legend = FALSE
|
|
, 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.direction = "vertical") +
|
|
|
|
labs(title = p_title
|
|
, x = ""
|
|
, y = "")+
|
|
|
|
stat_compare_means(comparisons = my_comparisonsL
|
|
, method = stat_method
|
|
, paired = my_paired
|
|
#, label = "p.format")
|
|
, label = stat_label[1])
|
|
|
|
return(bp_statP)
|
|
|
|
}
|