61 lines
1.9 KiB
R
Executable file
61 lines
1.9 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")
|
|
|
|
#######################################################
|
|
med_names = c("eotaxin3", "il12p70", "itac", "il13")
|
|
lf_test = lf_fp_npa[lf_fp_npa$mediator%in%med_names,]
|
|
|
|
mediators = levels(as.factor(lf_test$mediator))
|
|
|
|
plots <- list()
|
|
|
|
for (i in mediators) {
|
|
single=lf_test[lf_test$mediator==i,]
|
|
|
|
max_y = max(single$value, na.rm = T)
|
|
cat("Plotting:", i, "max_y:", max_y, "\n")
|
|
|
|
p2 = ggplot(single)+ geom_boxplot(aes(x = timepoint
|
|
, y = value
|
|
, color = obesity
|
|
#, palette = c("#00BFC4", "#F8766D")
|
|
))+
|
|
theme(axis.text.x = element_text(size = 15)
|
|
, axis.text.y = element_text(size = 15
|
|
, angle = 0
|
|
, hjust = 1
|
|
, vjust = 0)
|
|
, axis.title.x = element_blank()
|
|
, axis.title.y = element_blank()
|
|
, legend.position = "none"
|
|
, plot.title = element_text(size = 20, hjust = 0.5))
|
|
|
|
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
|
|
, y.position = max_y
|
|
, label = "{p} {p.signif}"
|
|
, hide.ns=T
|
|
, tip.length = 0)+
|
|
scale_y_continuous(expand = expansion(mult = c(0.05, 0.25)))
|
|
plots[[i]] <- p2
|
|
}
|
|
|
|
cowplot::plot_grid(plotlist=plots, align = 'hv', ncol=2, nrow=2)
|