diff --git a/boxplot_with_stats.R b/boxplot_with_stats.R index 8fa217d..cdc34b1 100755 --- a/boxplot_with_stats.R +++ b/boxplot_with_stats.R @@ -11,6 +11,10 @@ getwd() #============= 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() @@ -18,12 +22,23 @@ 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") - ) +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) %>% @@ -35,8 +50,12 @@ 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) + , 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)