#!/usr/bin/Rscript getwd() setwd("~/git/mosaic_2020/") getwd() ############################################################### # TASK: boxplots with stats for NPA, SAM and SERUM # for each mediator, at each timepoint by group # TODO: check boxplot_stat_function.R # output plots even if stats fail due to data containing only LLODs # however for a given mediator, if there is error for ANY timepoint # stats will not be added for the entire plot! To be handled in # next iteration! ############################################################### #============= # Input #============= source("boxplot_stat_function.R") source("plot_data_ns.R") #============= # Output #============= outfile_bp = paste0("boxplots_stats_all_NS-%03d.svg") output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats svg(output_boxplot_stats, width=22, height=16) ############################################################### #=============================== # data assignment for plots #=============================== table(lf_fp_npa$mediator) table(lf_fp_npa$T1_resp_score, lf_fp_npa$timepoint, lf_fp_npa$mediator == "eotaxin") #------------- # NPA #------------- title_npa = "NPA (non-severe)" fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa cat("\nPlotting boxplots with stats for:", title_npa , "\n========================================================\n") plots_npa = doMyPlotsStats(lf_fp_npa) npa_plot = ggpubr::ggarrange(plotlist = plots_npa , align = "hv" , ncol = 7 , nrow = 5 , common.legend = T) #npa_plot npa_plot_annot = annotate_figure(npa_plot , top = text_grob(title_npa , color = "blue" , face = "bold" , size = 18) , bottom = text_grob(paste0("Mosaic data\nFP non-severe adults (n=", fp_npa, ")") , color = "blue" , hjust = 1 , x = 0.98 , face = "italic" , size = 15) , left = text_grob("Levels (pg/ml)" , color = "black" , rot = 90 , size = 18)) npa_plot_annot #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------- # SAM: NO STATS # FIXME: error handling! # For now, just calling plotting function without stats #------------- title_sam = "SAM (non-severe)" fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam cat("\nPlotting boxplots with stats for:", title_sam , "\n========================================================\n") #plots_sam = doMyPlots(lf_fp_sam) plots_sam = doMyPlotsStats(lf_fp_sam) sam_plot = ggpubr::ggarrange(plotlist = plots_sam , align = "hv" , ncol = 7 , nrow = 5 , common.legend = T) #sam_plot sam_plot_annot = annotate_figure(sam_plot , top = text_grob(title_sam , color = "blue" , face = "bold" , size = 18) , bottom = text_grob(paste0("Mosaic data\nFP non-severe adults (n=", fp_sam, ")") , color = "blue" , hjust = 1 , x = 0.98 , face = "italic" , size = 15) , left = text_grob("Levels (pg/ml)" , color = "black" , rot = 90 , size = 18)) sam_plot_annot #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------- # SERUM #------------- title_serum = "SERUM (non-severe)" fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum cat("\nPlotting boxplots with stats for:", title_serum , "\n========================================================\n") plots_serum = doMyPlotsStats(lf_fp_serum) serum_plot = ggpubr::ggarrange(plotlist = plots_serum , align = "hv" , ncol = 7 , nrow = 5 , common.legend = T) #serum_plot serum_plot_annot = annotate_figure(serum_plot , top = text_grob(title_serum , color = "blue" , face = "bold" , size = 18) , bottom = text_grob(paste0("Mosaic data\nFP non-severe adults (n=", fp_serum, ")") , color = "blue" , hjust = 1 , x = 0.98 , face = "italic" , size = 15) , left = text_grob("Levels (pg/ml)" , color = "black" , rot = 90 , size = 18)) serum_plot_annot dev.off() ############################################################### # END OF SCRIPT # ###############################################################