0
|
1 #!/usr/bin/Rscript --vanilla --slave --no-site-file
|
|
2
|
|
3 ################################################################################################
|
|
4 # WRAPPER FOR filter_script.R (GENERIC FILTERS) #
|
|
5 # #
|
|
6 # Author: Melanie PETERA based on Marion LANDI's filters' wrapper #
|
|
7 # User: Galaxy #
|
|
8 # Original data: used with filter_script.R #
|
|
9 # Starting date: 04-09-2014 #
|
|
10 # V-1: Restriction of old filter wrapper to Filter according to factors #
|
|
11 # V-1.1: Modification to allow the choice of meta-data table for filtering #
|
|
12 # V-2: Addition of numerical filter #
|
|
13 # #
|
|
14 # #
|
|
15 # Input files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt #
|
|
16 # Output files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt #
|
|
17 # #
|
|
18 ################################################################################################
|
|
19
|
|
20
|
|
21 library(batch) #necessary for parseCommandArgs function
|
|
22 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
|
|
23
|
|
24 source_local <- function(...){
|
|
25 argv <- commandArgs(trailingOnly = FALSE)
|
|
26 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
|
|
27 for(i in 1:length(list(...))){source(paste(base_dir, list(...)[[i]], sep="/"))}
|
|
28 }
|
|
29 #Import the different functions
|
|
30 source_local("filter_script.R","RcheckLibrary.R","miniTools.R")
|
|
31
|
|
32
|
|
33 if(length(args) < 8){ stop("NOT enough argument !!!") }
|
|
34
|
|
35 list_num <- NULL
|
|
36 if(!is.null(args$parm_col)){
|
|
37 for( i in which(names(args)=="num_file") ){
|
|
38 if(args[[i+2]] %in% c("lower","upper")){
|
|
39 list_num <- c(list_num, list(c(args[[i]], args[[i+1]], args[[i+2]],args[[i+3]])))
|
|
40 }
|
|
41 if(args[[i+2]] %in% c("between","extremity")){
|
|
42 list_num <- c(list_num, list(c(args[[i]], args[[i+1]], args[[i+2]],args[[i+3]],args[[i+4]])))
|
|
43 }
|
|
44 }
|
|
45 }
|
|
46
|
|
47 list_fact <- NULL
|
|
48 if(!is.null(args$factor_col)){
|
|
49 for( i in which(names(args)=="qual_file") ){
|
|
50 list_fact <- c(list_fact, list(c(args[[i+1]], args[[i+2]], args[[i]])))
|
|
51 }
|
|
52 }
|
|
53
|
|
54 filters(args$dataMatrix_in, args$sampleMetadata_in, args$variableMetadata_in,
|
|
55 args$Numeric, list_num, args$Factors, list_fact,
|
|
56 args$dataMatrix_out, args$sampleMetadata_out, args$variableMetadata_out)
|
|
57
|
|
58 #filters(ion.file.in, meta.samp.file.in, meta.ion.file.in,
|
|
59 # NUM, ls.num, FACT, ls.fact,
|
|
60 # ion.file.out, meta.samp.file.out, meta.ion.file.out)
|
|
61
|
|
62 #delete the parameters to avoid the passage to the next tool in .RData image
|
|
63 rm(args)
|