diff --git a/R/fit.R b/R/fit.R index b2e5a60..a7f3093 100644 --- a/R/fit.R +++ b/R/fit.R @@ -1,15 +1,4 @@ #!/usr/bin/env Rscript -# Load Required Packages -for (lib in c( - 'dplyr', - 'pbapply', - 'lmerTest', - 'parallel', - 'lme4', - 'multcomp' -)) { - suppressPackageStartupMessages(require(lib, character.only = TRUE)) -} # Function to augment data for logistic fitting augment_data <- function(formula, random_effects_formula, dat_sub){ diff --git a/R/maaslin3.R b/R/maaslin3.R index e9e162f..38ff622 100755 --- a/R/maaslin3.R +++ b/R/maaslin3.R @@ -24,12 +24,6 @@ # THE SOFTWARE. ############################################################################### -# load in the required libraries, report an error if they are not installed - -for (lib in c('optparse', 'logging', 'data.table', 'dplyr')) { - suppressPackageStartupMessages(require(lib, character.only = TRUE)) -} - ############################################################### # If running on the command line, load other Maaslin3 modules # ############################################################### @@ -44,8 +38,12 @@ if (identical(environment(), globalenv()) && sub("--file=", "", script_options[grep("--file=", script_options)]) script_dir <- dirname(script_path) script_name <- basename(script_path) - - for (R_file in dir(script_dir, pattern = "*.R$")) + R_files <- c("fit.R", "utility_scripts.R", "vis.R") + # load in the required libraries, report an error if they are not installed + for (lib in c('optparse', 'logging', 'data.table', 'dplyr', 'pbapply','lmerTest','parallel','lme4','multcomp','ggplot2','viridis',"grid",'RColorBrewer','patchwork','scales')) { + suppressPackageStartupMessages(require(lib, character.only = TRUE)) + } + for (R_file in R_files) { if (!(R_file == script_name)) source(file.path(script_dir, R_file)) diff --git a/R/viz.R b/R/viz.R index caa348f..de5d3c6 100644 --- a/R/viz.R +++ b/R/viz.R @@ -23,11 +23,6 @@ # THE SOFTWARE. ############################################################################### -# Load libararies -for (lib in c('dplyr', 'ggplot2', 'viridis', "grid", 'RColorBrewer', 'patchwork', 'scales')) { - suppressPackageStartupMessages(require(lib, character.only = TRUE)) -} - # MaAsLin3 theme based on Nature journal requirements nature_theme <- function(x_axis_labels, y_label) { # set default text format based on categorical and length