From 9c141326aa9c38bb6cfc9e316b53325ed488d07a Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Mon, 2 Nov 2020 15:04:40 +0000 Subject: [PATCH] enter the commit message for your changes. Lines starting --- boxplot_stat_all.R | 69 +++++++++++++++++++++++-------------------- boxplot_stat_log.R | 73 +++++++++++++++++++++++++++------------------- 2 files changed, 80 insertions(+), 62 deletions(-) diff --git a/boxplot_stat_all.R b/boxplot_stat_all.R index a71969a..169084b 100755 --- a/boxplot_stat_all.R +++ b/boxplot_stat_all.R @@ -7,6 +7,7 @@ getwd() # Input #============= source("boxplot_stat_function.R") +source("boxplot_function.R") # for sam source("plot_data.R") #============= @@ -39,7 +40,7 @@ npa_plot_annot = annotate_figure(npa_plot , top = text_grob(my_sample_npa , color = "blue" , face = "bold" - , size = 14) + , size = 18) , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_npa, ")") , color = "blue" , hjust = 1 @@ -51,44 +52,46 @@ npa_plot_annot = annotate_figure(npa_plot , rot = 90 , size = 18)) npa_plot_annot -#dev.off() +#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------- -# SAM +# SAM: NO STATS +# FIXME: error handling! +# For now, just calling plotting function without stats #------------- -#my_sample_sam = "SAM" -#fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam +my_sample_sam = "SAM" +fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam -#cat("\nPlotting boxplots with stats for:", my_sample_sam -# , "\n========================================================\n") +cat("\nPlotting boxplots with stats for:", my_sample_sam + , "\n========================================================\n") -#plots_sam = doMyPlots(lf_fp_sam) -#sam_plot = ggpubr::ggarrange(plotlist = plots_sam -# , align = "hv" -# , ncol = 7 -# , nrow = 5 -# , common.legend = T) +plots_sam = doMyPlots(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(my_sample_sam -# , color = "blue" -# , face = "bold" -# , size = 14) -# , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")") -# , color = "blue" -# , hjust = 1 -# , x = 0.98 -# , face = "italic" -# , size = 10) -# , left = text_grob("Levels (pg/ml)" -# , color = "black" -# , rot = 90 -# , size = 18)) -#sam_plot_annot -#dev.off() +sam_plot_annot = annotate_figure(sam_plot + , top = text_grob(my_sample_sam + , color = "blue" + , face = "bold" + , size = 18) + , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")") + , color = "blue" + , hjust = 1 + , x = 0.98 + , face = "italic" + , size = 10) + , left = text_grob("Levels (pg/ml)" + , color = "black" + , rot = 90 + , size = 18)) +sam_plot_annot +#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------- # SERUM #------------- -my_sample_serum = "serum" +my_sample_serum = "SERUM" fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum cat("\nPlotting boxplots with stats for:", my_sample_serum @@ -105,7 +108,7 @@ serum_plot_annot = annotate_figure(serum_plot , top = text_grob(my_sample_serum , color = "blue" , face = "bold" - , size = 14) + , size = 18) , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_serum, ")") , color = "blue" , hjust = 1 @@ -119,3 +122,5 @@ serum_plot_annot = annotate_figure(serum_plot serum_plot_annot dev.off() ############################################################### +# END OF SCRIPT # +############################################################### diff --git a/boxplot_stat_log.R b/boxplot_stat_log.R index 0953113..15cf3d0 100644 --- a/boxplot_stat_log.R +++ b/boxplot_stat_log.R @@ -40,8 +40,9 @@ revised_nrow = nrow(lf_fp_npa); revised_nrow orig_nrow == revised_nrow head(lf_fp_npa$value) - +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # log all values and reassign +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# lf_fp_npa$value = log10(lf_fp_npa$value) head(lf_fp_npa$value) vl_temp_fix2 = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",] @@ -77,46 +78,56 @@ npa_plot_annot = annotate_figure(npa_plot , rot = 90 , size = 18)) npa_plot_annot -#dev.off() +#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------- # SAM #------------- -#my_sample_sam = "SAM" -#fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam +head(lf_fp_sam$value) -#cat("\nPlotting boxplots with stats for:", my_sample_sam -# , "\n========================================================\n") +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +# log all values and reassign +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +lf_fp_sam$value = log10(lf_fp_sam$value) +head(lf_fp_sam$value) -#plots_sam = doMyPlots(lf_fp_sam) -#sam_plot = ggpubr::ggarrange(plotlist = plots_sam -# , align = "hv" -# , ncol = 7 -# , nrow = 5 -# , common.legend = T) +my_sample_sam = "SAM" +fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam + +cat("\nPlotting boxplots with stats for:", my_sample_sam + , "\n========================================================\n") + +plots_sam = doMyPlots(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(my_sample_sam -# , color = "blue" -# , face = "bold" -# , size = 14) -# , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")") -# , color = "blue" -# , hjust = 1 -# , x = 0.98 -# , face = "italic" -# , size = 10) -# , left = text_grob("Levels (pg/ml)" -# , color = "black" -# , rot = 90 -# , size = 18)) -#sam_plot_annot -#dev.off() +sam_plot_annot = annotate_figure(sam_plot + , top = text_grob(my_sample_sam + , color = "blue" + , face = "bold" + , size = 14) + , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")") + , color = "blue" + , hjust = 1 + , x = 0.98 + , face = "italic" + , size = 10) + , left = text_grob("Levels (pg/ml)" + , color = "black" + , rot = 90 + , size = 18)) +sam_plot_annot +#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=# #------------------------------------------ #------------- # SERUM #------------- head(lf_fp_serum$value) -# reassign +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +# log all values and reassign +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# lf_fp_serum$value = log10(lf_fp_serum$value) head(lf_fp_serum$value) @@ -151,3 +162,5 @@ serum_plot_annot = annotate_figure(serum_plot serum_plot_annot dev.off() ############################################################### +# END OF SCRIPT # +###############################################################