view Intchecks/wrapper_intensity_check.R @ 6:ec75de7f1e08 draft default tip

Uploaded
author melpetera
date Mon, 11 Dec 2023 12:56:20 +0000
parents 49c36c54e0cf
children
line wrap: on
line source

#!/usr/bin/Rscript --vanilla --slave --no-site-file


#############################################################################
# WRAPPER for INTENSITY CHECK                                               #
#                                                                           #
#Script: Script_intensity_check.R                                           #
#Xml: xml_intensity_check.xml                                               #
#                                                                           #
#                                                                           #
# Input: Data Matrix, VariableMetadata, SampleMetadata                      #
# Output: VariableMetadata, Graphics                                        #
#                                                                           #
#                                                                           #
#############################################################################

source_local <- function(...){
  argv <- commandArgs(trailingOnly = FALSE)
  base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
  for(i in 1:length(list(...))){source(paste(base_dir, list(...)[[i]], sep="/"))}
}
#Import the different functions
source_local("parseargs.R", "Script_intensity_check.R", "RcheckLibrary.R")

args = parse_args() #interpretation of arguments given in command line as an R list of objects


if(length(args) < 7){ stop("NOT enough argument !!!") }

cat('\nJob starting time:\n',format(Sys.time(), "%a %d %b %Y %X"),
'\n\n--------------------------------------------------------------------', 
'\nIntensity Check parameters:\n\n')
print(args)
cat('--------------------------------------------------------------------\n\n')

class_col <- NULL
test_fold <- NULL
class1 <- NULL
fold_frac <- NULL
logarithm <- NULL
if(args$method == "each_class"){ 
  class_col <- args$class_col
  test_fold <- args$test_fold
  if(args$test_fold == "Yes"){
    logarithm <- args$logarithm
  }
}
if(args$method == "one_class"){
  class_col <- args$class_col
  class1 <- args$class1
  test_fold <- args$test_fold
  if(args$test_fold == "Yes"){
    fold_frac <- args$fold_frac
    logarithm <- args$logarithm
  }
}

err_no_option <- NULL

if(((args$method == "no_class")&&(args$chosen_stat == "None"))||
   ((args$method != "no_class") && (args$chosen_stat == "None") && (test_fold == "No"))){
  err_no_option<- "You did not select any computational option. Program can not be executed."
  stop("\n- - - - - - - - -\n",err_no_option,"\n- - - - - - - - -\n")
}


if(is.null(err_no_option)){

  intens_check(args$dataMatrix_in, args$sampleMetadata_in, args$variableMetadata_in, args$method, args$chosen_stat, 
             class_col, test_fold, class1, fold_frac, logarithm, args$variableMetadata_out, args$graphs_out)
}


cat('\n--------------------------------------------------------------------',
'\nInformation about R (version, Operating System, attached or loaded packages):\n\n')
sessionInfo()
cat('--------------------------------------------------------------------\n',
'\nJob ending time:\n',format(Sys.time(), "%a %d %b %Y %X"))


#delete the parameters to avoid the passage to the next tool in .RData image
rm(args)