added try catch for error handling

This commit is contained in:
Tanushree Tunstall 2020-11-02 16:26:22 +00:00
parent 9c141326aa
commit 8033c1785f
3 changed files with 69 additions and 54 deletions

27
boxplot_stat_log.R Normal file → Executable file
View file

@ -7,12 +7,13 @@ getwd()
# Input
#=============
source("boxplot_stat_function.R")
source("boxplot_function.R")
source("plot_data.R")
#=============
# Output
#=============
outfile_bp = paste0("boxplots_stats_npa_serum_LOG", ".pdf")
outfile_bp = paste0("boxplots_stats_all_LOG", ".pdf")
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
pdf(output_boxplot_stats, width=22, height=16)
###############################################################
@ -49,10 +50,10 @@ vl_temp_fix2 = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",]
vl_temp_fix2$value[1:20]
#------------------------------------------
my_sample_npa = "NPA"
title_npa = "NPA"
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
cat("\nPlotting boxplots with stats for:", my_sample_npa
cat("\nPlotting boxplots with stats for:", title_npa
, "\n========================================================\n")
plots_npa = doMyPlotsStats(lf_fp_npa)
@ -63,10 +64,10 @@ npa_plot = ggpubr::ggarrange(plotlist = plots_npa
, common.legend = T)
#npa_plot
npa_plot_annot = annotate_figure(npa_plot
, top = text_grob(my_sample_npa
, top = text_grob(title_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
@ -90,10 +91,10 @@ head(lf_fp_sam$value)
lf_fp_sam$value = log10(lf_fp_sam$value)
head(lf_fp_sam$value)
my_sample_sam = "SAM"
title_sam = "SAM"
fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
cat("\nPlotting boxplots with stats for:", my_sample_sam
cat("\nPlotting boxplots with stats for:", title_sam
, "\n========================================================\n")
plots_sam = doMyPlots(lf_fp_sam)
@ -104,10 +105,10 @@ sam_plot = ggpubr::ggarrange(plotlist = plots_sam
, common.legend = T)
#sam_plot
sam_plot_annot = annotate_figure(sam_plot
, top = text_grob(my_sample_sam
, top = text_grob(title_sam
, color = "blue"
, face = "bold"
, size = 14)
, size = 18)
, bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")")
, color = "blue"
, hjust = 1
@ -131,10 +132,10 @@ head(lf_fp_serum$value)
lf_fp_serum$value = log10(lf_fp_serum$value)
head(lf_fp_serum$value)
my_sample_serum = "serum"
title_serum = "SERUM"
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
cat("\nPlotting boxplots with stats for:", my_sample_serum
cat("\nPlotting boxplots with stats for:", title_serum
, "\n========================================================\n")
plots_serum = doMyPlotsStats(lf_fp_serum)
@ -145,10 +146,10 @@ serum_plot = ggpubr::ggarrange(plotlist = plots_serum
, common.legend = T)
#serum_plot
serum_plot_annot = annotate_figure(serum_plot
, top = text_grob(my_sample_serum
, top = text_grob(title_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