Mercurial > repos > melpetera > generic_filter
comparison GalFilter/filter_wrap.R @ 3:cfd7c4aa5c26 draft default tip
Uploaded
author | melpetera |
---|---|
date | Fri, 03 Jan 2020 04:09:28 -0500 |
parents | 2c9afaf849ad |
children |
comparison
equal
deleted
inserted
replaced
2:12cf1eed21f4 | 3:cfd7c4aa5c26 |
---|---|
8 # Original data: used with filter_script.R # | 8 # Original data: used with filter_script.R # |
9 # Starting date: 04-09-2014 # | 9 # Starting date: 04-09-2014 # |
10 # V-1: Restriction of old filter wrapper to Filter according to factors # | 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 # | 11 # V-1.1: Modification to allow the choice of meta-data table for filtering # |
12 # V-2: Addition of numerical filter # | 12 # V-2: Addition of numerical filter # |
13 # V-2.5: -h option + additional information in stdout # | |
13 # # | 14 # # |
14 # # | 15 # # |
15 # Input files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt # | 16 # Input files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt # |
16 # Output files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt # | 17 # Output files: dataMatrix.txt ; sampleMetadata.txt ; variableMetadata.txt # |
17 # # | 18 # # |
18 ################################################################################################ | 19 ################################################################################################ |
19 | 20 |
20 | 21 |
21 library(batch) #necessary for parseCommandArgs function | 22 library(batch) #necessary for parseCommandArgs function |
23 | |
24 # Constants | |
25 argv <- commandArgs(trailingOnly = FALSE) | |
26 script.path <- sub("--file=","",argv[grep("--file=",argv)]) | |
27 prog.name <- basename(script.path) | |
28 | |
29 # Help | |
30 if (length(grep('-h', argv)) >0) { | |
31 cat("Usage:", prog.name, | |
32 "dataMatrix_in myDataMatrix.tsv", | |
33 "sampleMetadata_in mySampleMetadata.tsv", | |
34 "variableMetadata_in myVariableMetadata.tsv", | |
35 "...", | |
36 "\n") | |
37 quit(status = 0) | |
38 } | |
39 | |
22 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects | 40 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects |
23 | 41 |
24 source_local <- function(...){ | 42 source_local <- function(...){ |
25 argv <- commandArgs(trailingOnly = FALSE) | 43 argv <- commandArgs(trailingOnly = FALSE) |
26 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | 44 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
29 #Import the different functions | 47 #Import the different functions |
30 source_local("filter_script.R","RcheckLibrary.R","miniTools.R") | 48 source_local("filter_script.R","RcheckLibrary.R","miniTools.R") |
31 | 49 |
32 | 50 |
33 if(length(args) < 8){ stop("NOT enough argument !!!") } | 51 if(length(args) < 8){ stop("NOT enough argument !!!") } |
52 | |
53 | |
54 cat('\nJob starting time:\n',format(Sys.time(), "%a %d %b %Y %X"), | |
55 '\n\n--------------------------------------------------------------------', | |
56 '\nParameters used in "Generic Filter":\n\n') | |
57 print(args) | |
58 cat('--------------------------------------------------------------------\n\n') | |
59 | |
34 | 60 |
35 list_num <- NULL | 61 list_num <- NULL |
36 if(!is.null(args$parm_col)){ | 62 if(!is.null(args$parm_col)){ |
37 for( i in which(names(args)=="num_file") ){ | 63 for( i in which(names(args)=="num_file") ){ |
38 if(args[[i+2]] %in% c("lower","upper")){ | 64 if(args[[i+2]] %in% c("lower","upper")){ |
57 | 83 |
58 #filters(ion.file.in, meta.samp.file.in, meta.ion.file.in, | 84 #filters(ion.file.in, meta.samp.file.in, meta.ion.file.in, |
59 # NUM, ls.num, FACT, ls.fact, | 85 # NUM, ls.num, FACT, ls.fact, |
60 # ion.file.out, meta.samp.file.out, meta.ion.file.out) | 86 # ion.file.out, meta.samp.file.out, meta.ion.file.out) |
61 | 87 |
88 | |
89 cat('\n--------------------------------------------------------------------', | |
90 '\nInformation about R (version, Operating System, attached or loaded packages):\n\n') | |
91 sessionInfo() | |
92 cat('--------------------------------------------------------------------\n', | |
93 '\nJob ending time:\n',format(Sys.time(), "%a %d %b %Y %X")) | |
94 | |
95 | |
62 #delete the parameters to avoid the passage to the next tool in .RData image | 96 #delete the parameters to avoid the passage to the next tool in .RData image |
63 rm(args) | 97 rm(args) |