comparison multivariate_wrapper.R @ 4:5526f8258e8a draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/multivariate.git commit 0f382a5296aae9bfc77df06b0a5ad493eb3c01f3
author ethevenot
date Wed, 28 Feb 2018 09:59:25 -0500
parents e91de3b04320
children
comparison
equal deleted inserted replaced
3:e91de3b04320 4:5526f8258e8a
1 #!/usr/bin/env Rscript 1 #!/usr/bin/env Rscript
2 2
3 library(batch) ## parseCommandArgs 3 library(batch) ## parseCommandArgs
4
5 # Constants
6 argv <- commandArgs(trailingOnly = FALSE)
7 script.path <- sub("--file=","",argv[grep("--file=",argv)])
8 prog.name <- basename(script.path)
9
10 # Print help
11 if (length(grep('-h', argv)) >0) {
12 cat("Usage:", prog.name,
13 "dataMatrix_in myDataMatrix.tsv",
14 "sampleMetadata_in mySampleData.tsv",
15 "variableMetadata_in myVariableMetadata.tsv",
16 "respC ...",
17 "predI ...",
18 "orthoI ...",
19 "testL ...",
20 "typeC ...",
21 "parAsColC ...",
22 "parCexN ...",
23 "parPc1I ...",
24 "parPc2I ...",
25 "parMahalC ...",
26 "parLabVc ...",
27 "algoC ...",
28 "crossvalI ...",
29 "log10L ...",
30 "permI ...",
31 "scaleC ...",
32 "sampleMetadata_out mySampleMetadata_out.tsv",
33 "variableMetadata_out myVariableMetadata_out.tsv",
34 "figure figure.pdf",
35 "information information.txt",
36 "\n")
37 quit(status = 0)
38 }
4 39
5 ######## 40 ########
6 # MAIN # 41 # MAIN #
7 ######## 42 ########
8 43
43 78
44 tesL <- eval(parse(text = tesC), envir = envC) 79 tesL <- eval(parse(text = tesC), envir = envC)
45 80
46 if(!tesL) { 81 if(!tesL) {
47 82
48 sink(NULL) 83 sink()
49 stpTxtC <- ifelse(is.na(txtC), 84 stpTxtC <- ifelse(is.na(txtC),
50 paste0(tesC, " is FALSE"), 85 paste0(tesC, " is FALSE"),
51 txtC) 86 txtC)
52 87
53 stop(stpTxtC, 88 stop(stpTxtC,
72 107
73 xMN <- t(as.matrix(read.table(argVc["dataMatrix_in"], 108 xMN <- t(as.matrix(read.table(argVc["dataMatrix_in"],
74 check.names = FALSE, 109 check.names = FALSE,
75 header = TRUE, 110 header = TRUE,
76 row.names = 1, 111 row.names = 1,
77 sep = "\t"))) 112 sep = "\t",
113 comment.char = "")))
78 114
79 samDF <- read.table(argVc["sampleMetadata_in"], 115 samDF <- read.table(argVc["sampleMetadata_in"],
80 check.names = FALSE, 116 check.names = FALSE,
81 header = TRUE, 117 header = TRUE,
82 row.names = 1, 118 row.names = 1,
83 sep = "\t") 119 sep = "\t",
120 comment.char = "")
84 flgF("identical(rownames(xMN), rownames(samDF))", txtC = "Sample names (or number) in the data matrix (first row) and sample metadata (first column) are not identical; use the 'Check Format' module in the 'Quality Control' section") 121 flgF("identical(rownames(xMN), rownames(samDF))", txtC = "Sample names (or number) in the data matrix (first row) and sample metadata (first column) are not identical; use the 'Check Format' module in the 'Quality Control' section")
85 122
86 varDF <- read.table(argVc["variableMetadata_in"], 123 varDF <- read.table(argVc["variableMetadata_in"],
87 check.names = FALSE, 124 check.names = FALSE,
88 header = TRUE, 125 header = TRUE,
89 row.names = 1, 126 row.names = 1,
90 sep = "\t") 127 sep = "\t",
128 comment.char = "")
91 flgF("identical(colnames(xMN), rownames(varDF))", txtC = "Variable names (or number) in the data matrix (first column) and sample metadata (first column) are not identical; use the 'Check Format' module in the 'Quality Control' section") 129 flgF("identical(colnames(xMN), rownames(varDF))", txtC = "Variable names (or number) in the data matrix (first column) and sample metadata (first column) are not identical; use the 'Check Format' module in the 'Quality Control' section")
92 130
93 flgF("argVc['respC'] == 'none' || (argVc['respC'] %in% colnames(samDF))", 131 flgF("argVc['respC'] == 'none' || (argVc['respC'] %in% colnames(samDF))",
94 txtC = paste0("Y Response argument (", argVc['respC'], ") must be either none or one of the column names (first row) of your sample metadata")) 132 txtC = paste0("Y Response argument (", argVc['respC'], ") must be either none or one of the column names (first row) of your sample metadata"))
95 if(argVc["respC"] != "none") { 133 if(argVc["respC"] != "none") {
425 quote = FALSE, 463 quote = FALSE,
426 row.names = FALSE, 464 row.names = FALSE,
427 sep = "\t") 465 sep = "\t")
428 466
429 # Output ropLs 467 # Output ropLs
430 if ( ! is.null(argVc['ropls_out'])) 468 if (!is.null(argVc['ropls_out']) && !is.na(argVc['ropls_out']))
431 save(ropLs, file = argVc['ropls_out']) 469 save(ropLs, file = argVc['ropls_out'])
432 470
433 ## Closing 471 ## Closing
434 ##-------- 472 ##--------
435 473
436 cat("\nEnd of '", modNamC, "' Galaxy module call: ", 474 cat("\nEnd of '", modNamC, "' Galaxy module call: ",
437 as.character(Sys.time()), "\n", sep = "") 475 as.character(Sys.time()), "\n", sep = "")
438 476
477 cat("\n\n\n============================================================================")
478 cat("\nAdditional information about the call:\n")
479 cat("\n1) Parameters:\n")
480 print(cbind(value = argVc))
481
482 cat("\n2) Session Info:\n")
483 sessioninfo <- sessionInfo()
484 cat(sessioninfo$R.version$version.string,"\n")
485 cat("Main packages:\n")
486 for (pkg in names(sessioninfo$otherPkgs)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
487 cat("Other loaded packages:\n")
488 for (pkg in names(sessioninfo$loadedOnly)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
489
490 cat("============================================================================\n")
491
439 sink() 492 sink()
440 493
441 options(stringsAsFactors = strAsFacL) 494 options(stringsAsFactors = strAsFacL)
442 495
443 rm(list = ls()) 496 rm(list = ls())