diff --git a/boxplot_with_stats.R b/boxplot_with_stats.R index 039534e..b07850f 100755 --- a/boxplot_with_stats.R +++ b/boxplot_with_stats.R @@ -15,6 +15,8 @@ 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)) +mediators = levels(as.factor(lf_fp_npa$mediator)) +lf_test = lf_fp_npa plots <- list() @@ -29,6 +31,7 @@ p2 = ggplot(single)+ geom_boxplot(aes(x = timepoint , color = obesity #, palette = c("#00BFC4", "#F8766D") ))+ + scale_colour_manual(values=c("blue", "red")) + theme(axis.text.x = element_text(size = 15) , axis.text.y = element_text(size = 15 , angle = 0 @@ -62,6 +65,9 @@ plots[[i]] <- p2 } cowplot::plot_grid(plotlist=plots, align = 'hv', ncol=2, nrow=2) +pdf("test.pdf", width = 22, height = 16) +cowplot::plot_grid(plotlist=plots, align = 'hv', ncol=7, nrow=5) +dev.off() ################################################################## #======= # facet @@ -118,7 +124,7 @@ p3 = ggplot(lf_test)+ geom_boxplot(aes(x = timepoint , vjust = 0) , axis.title.x = element_blank() , axis.title.y = element_blank() - , strip.text.x = element_text(size = 20) + , strip.text.x = element_text(size = 20,margin = margin(0.05,0,0.07,0, "cm")) , legend.position = "top" , legend.title = element_text(color = "black", size = 20) , legend.text = element_text(size = 15) @@ -182,9 +188,7 @@ my_summary = lf_fp_npa %>% get_summary_stats(value) my_summary my_max_df = subset(my_summary - , select = c("mediator", "timepoint" - #, "obesity" - , "max")) + , select = c("mediator", "timepoint", "max")) head(my_max_df); head(stat_npa3) @@ -205,8 +209,7 @@ p3 = ggplot(lf_fp_npa)+ geom_boxplot(aes(x = timepoint , y = value , color = obesity))+ scale_colour_manual(values=c("blue", "red")) + - scale_y_log10()+ - + #scale_y_log10()+ theme(axis.text.x = element_text(size = 15) , axis.text.y = element_text(size = 15 , angle = 0 @@ -214,7 +217,7 @@ p3 = ggplot(lf_fp_npa)+ geom_boxplot(aes(x = timepoint , vjust = 0) , axis.title.x = element_blank() , axis.title.y = element_blank() - , strip.text.x = element_text(size = 20) + , strip.text.x = element_text(size = 20, margin = margin(2,0,2,0, "cm")) , legend.position = "top" , legend.title = element_text(color = "black", size = 20) , legend.text = element_text(size = 15) @@ -225,6 +228,7 @@ p3 = ggplot(lf_fp_npa)+ geom_boxplot(aes(x = timepoint #p3 p4 = p3 + stat_pvalue_manual(stat_npa3_v2 , y.position = "my_y_pos" + , step.increase = 0.08 #, y.position = 50 , label = "{p_format} {p.signif}" , hide.ns=T @@ -232,4 +236,4 @@ p4 = p3 + stat_pvalue_manual(stat_npa3_v2 #scale_y_continuous(expand = expansion(mult = c(0.05, 0.25))) p4 -dev.off() +dev.off() \ No newline at end of file