42 lines
1 KiB
R
Executable file
42 lines
1 KiB
R
Executable file
#!/usr/bin/Rscript
|
|
getwd()
|
|
setwd("~/git/mosaic_2020/")
|
|
getwd()
|
|
############################################################
|
|
# TASK: boxplots at T1
|
|
# FIXME: currently not rendering, problem with NAs for stats?
|
|
############################################################
|
|
#=============
|
|
# Input
|
|
#=============
|
|
source("boxplot_linear.R")
|
|
|
|
mediators = levels(as.factor(lf_test$mediator))
|
|
|
|
plots <- list()
|
|
|
|
for (i in mediators) {
|
|
single=lf_test[lf_test$mediator==i,]
|
|
|
|
p2 = ggboxplot(single
|
|
, x = "timepoint"
|
|
, y = "value"
|
|
, color = "obesity"
|
|
, palette = c("#00BFC4", "#F8766D")
|
|
)
|
|
|
|
stat_npa2 <- single %>%
|
|
group_by(timepoint, mediator) %>%
|
|
wilcox_test(value ~ obesity, paired = F) %>%
|
|
add_significance("p")
|
|
stat_npa2
|
|
|
|
stat_npa2 <- stat_npa2 %>%
|
|
add_xy_position(x = "timepoint", dodge = 0.8)
|
|
|
|
p2 = p2 + stat_pvalue_manual(stat_npa2
|
|
, label = "{p} {p.signif}"
|
|
, hide.ns=T
|
|
, tip.length = 0)
|
|
plots[[i]] <- p2
|
|
}
|