annotate asca_wrapper.R @ 0:93312041f1d5 draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
author marie-tremblay-metatoul
date Fri, 21 Sep 2018 05:51:14 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
1 #!/usr/bin/env Rscript
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
2
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
3 ###################################################################################################
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
4 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
5 # MetStaT ASCA.calculate function
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
6 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
7 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
8 # R-Package: MetStaT
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
9 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
10 # Version: 1.0
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
11 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
12 # Author (asca.calculate): Tim Dorscheidt
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
13 # Author (wrapper & .r adaptation for workflow4metabolomics.org): M. Tremblay-Franco & Y. Guitton #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
14 #
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
15 # Expected parameters from the commandline
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
16 # input files:
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
17 # dataMatrix
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
18 # sampleMetadata
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
19 # variableMetadata
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
20 # params:
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
21 # Factors (Factor1 & Factor2)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
22 # scaling
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
23 # Number of permutations
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
24 # Significance threshold
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
25 # output files:
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
26 # sampleMetadata
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
27 # variableMetadata
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
28 # Graphical outputs
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
29 # Information text
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
30 ###################################################################################################
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
31 pkgs=c("MetStaT","batch","pcaMethods")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
32 for(pkg in pkgs) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
33 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
34 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
35 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
36
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
37
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
38 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
39
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
40 #Redirect all stdout to the log file
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
41 sink(listArguments$information)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
42
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
43 # ----- PACKAGE -----
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
44 cat("\tPACKAGE INFO\n")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
45 sessionInfo()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
46
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
47 source_local <- function(fname) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
48 argv <- commandArgs(trailingOnly = FALSE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
49 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
50 source(paste(base_dir, fname, sep="/"))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
51 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
52
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
53 #load asca_w4m function
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
54 source_local("asca_w4m.R")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
55 source_local("ASCA.Calculate_w4m.R")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
56 source_local("ASCA.PlotScoresPerLevel_w4m.R")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
57 print("first loadings OK")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
58
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
59 ## libraries
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
60 ##----------
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
61
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
62 cat('\n\nRunning ASCA.calculate\n');
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
63 options(warn=-1);
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
64 #remove rgl warning
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
65 options(rgl.useNULL = TRUE);
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
66
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
67
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
68 ## constants
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
69 ##----------
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
70
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
71 modNamC <- "asca" ## module name
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
72
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
73 topEnvC <- environment()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
74 flgC <- "\n"
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
75
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
76 ## functions
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
77 ##----------For manual input of function
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
78 ##--end function
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
79
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
80 flgF <- function(tesC,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
81 envC = topEnvC,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
82 txtC = NA) { ## management of warning and error messages
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
83
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
84 tesL <- eval(parse(text = tesC), envir = envC)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
85
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
86 if(!tesL) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
87
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
88 sink(NULL)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
89 stpTxtC <- ifelse(is.na(txtC),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
90 paste0(tesC, " is FALSE"),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
91 txtC)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
92
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
93 stop(stpTxtC,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
94 call. = FALSE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
95
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
96 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
97
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
98 } ## flgF
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
99
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
100
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
101 ## log file
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
102 ##---------
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
103 cat("\nStart of the '", modNamC, "' Galaxy module call: ",
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
104 format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
105
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
106
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
107 ## arguments
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
108 ##----------
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
109 ## loading files and checks
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
110 xMN <- t(as.matrix(read.table(listArguments[["dataMatrix_in"]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
111 check.names = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
112 header = TRUE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
113 row.names = 1,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
114 sep = "\t")))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
115 varIdDM <- rownames(xMN)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
116
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
117 samDF <- read.table(listArguments[["sampleMetadata_in"]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
118 check.names = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
119 header = TRUE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
120 row.names = 1,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
121 sep = "\t")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
122 obsIdSMD <- rownames(samDF)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
123
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
124 varDF <- read.table(listArguments[["variableMetadata_in"]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
125 check.names = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
126 header = TRUE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
127 row.names = 1,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
128 sep = "\t")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
129 varIdVDM <- rownames(varDF)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
130
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
131 result <- asca_w4m(xMN, samDF, c(listArguments[["factor1"]],listArguments[["factor2"]]), varDF, as.numeric(listArguments[["threshold"]]),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
132 scaling=listArguments[["scaling"]], listArguments[["nPerm"]])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
133
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
134
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
135 ##saving
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
136
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
137 if (exists("result")) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
138 ## writing output files
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
139 cat("\n\nWriting output files\n\n");
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
140 write.table(data.frame(cbind(obsIdSMD, result[[4]])),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
141 file = listArguments$sampleMetadata_out,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
142 quote = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
143 row.names = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
144 sep = "\t")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
145
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
146 write.table(data.frame(cbind(varIdVDM, result[[5]])),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
147 file = listArguments$variableMetadata_out,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
148 quote = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
149 row.names = FALSE,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
150 sep = "\t")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
151
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
152 # Graphical display for each significant parameter
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
153 print(result[[3]])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
154 cat("\n p-value of Residuals must not be taken into account\n")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
155
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
156 if (any(result[[2]] < as.numeric(listArguments[["threshold"]])))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
157 {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
158 data.asca.permutation <- result[[2]]
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
159 design <- data.matrix(samDF[, colnames(samDF) %in% c(listArguments[["factor1"]],listArguments[["factor2"]])])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
160
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
161 pdf(listArguments$figure, onefile=TRUE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
162 par(mfrow=c(1,3))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
163 if (data.asca.permutation[1] < as.numeric(listArguments[["threshold"]]))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
164 {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
165 eigenvalues <- data.frame(1:length(unique(design[,1])), result[[1]]$'1'$svd$var.explained[1:length(unique(design[,1]))])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
166 colnames(eigenvalues) <- c("PC", "explainedVariance")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
167 barplot(eigenvalues[,2], names.arg=eigenvalues[,1], ylab="% of explained variance", xlab="Principal component")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
168 noms <- levels(as.factor(samDF[, listArguments$factor1]))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
169 ASCA.PlotScoresPerLevel_w4m(result[[1]], ee="1", interaction=0, factorName=listArguments$factor1, factorModalite=noms)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
170
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
171 v1 <- paste(listArguments[["factor1"]],"_XLOAD-p1", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
172 v2 <- paste(listArguments[["factor1"]],"_XLOAD-p2", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
173 f1.loadings <- data.matrix(result[[5]][,c(v1, v2)])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
174 f1.loadings.leverage <- diag(f1.loadings%*%t(f1.loadings))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
175 names(f1.loadings.leverage) <- colnames(xMN)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
176 f1.loadings.leverage <- sort(f1.loadings.leverage, decreasing=TRUE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
177 barplot(f1.loadings.leverage[f1.loadings.leverage > 0.001], main="Leverage values")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
178 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
179 if (data.asca.permutation[2] < as.numeric(listArguments[["threshold"]]))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
180 {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
181 eigenvalues <- data.frame(1:length(unique(design[,2])), result[[1]]$'2'$svd$var.explained[1:length(unique(design[,2]))])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
182 colnames(eigenvalues) <- c("PC", "explainedVariance")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
183 barplot(eigenvalues[,2], names.arg=eigenvalues[,1], ylab="% of explained variance", xlab="Principal component")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
184 noms <- levels(as.factor(samDF[, listArguments$factor2]))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
185 ASCA.PlotScoresPerLevel_w4m(result[[1]], ee="2", interaction=0, factorName=listArguments$factor2, factorModalite=noms)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
186
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
187 v1 <- paste(listArguments[["factor2"]],"_XLOAD-p1", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
188 v2 <- paste(listArguments[["factor2"]],"_XLOAD-p2", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
189 f2.loadings <- data.matrix(result[[5]][,c(v1, v2)])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
190 f2.loadings.leverage <- diag(f2.loadings%*%t(f2.loadings))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
191 names(f2.loadings.leverage) <- colnames(xMN)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
192 f2.loadings.leverage <- sort(f2.loadings.leverage, decreasing=TRUE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
193 barplot(f2.loadings.leverage[f2.loadings.leverage > 0.001], main="Leverage values")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
194 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
195 if (data.asca.permutation[3] < as.numeric(listArguments[["threshold"]]))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
196 {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
197 eigenvalues <- data.frame(1:(length(unique(design[,1]))*length(unique(design[,2]))), result[[1]]$'12'$svd$var.explained[1:(length(unique(design[,1]))*length(unique(design[,2])))])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
198 colnames(eigenvalues) <- c("PC", "explainedVariance")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
199 barplot(eigenvalues[,2], names.arg=eigenvalues[,1], ylab="% of explained variance", xlab="Principal component")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
200 noms1 <- data.matrix(levels(as.factor(samDF[, listArguments$factor1])))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
201 noms2 <- data.matrix(levels(as.factor(samDF[, listArguments$factor2])))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
202 noms <- apply(noms1, 1, FUN=function(x){paste(x, "-", noms2, sep="")})
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
203 noms <- apply(noms, 1, FUN=function(x){c(noms)})
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
204 ASCA.PlotScoresPerLevel_w4m(result[[1]], ee="12", interaction=1, factorModalite=noms[,1])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
205
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
206 v1 <- "Interact_XLOAD-p1"
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
207 v2 <- "Interact_XLOAD-p2"
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
208 f1f2.loadings <- data.matrix(result[[5]][, c(v1, v2)])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
209 f1f2.loadings.leverage <- diag(f1f2.loadings%*%t(f1f2.loadings))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
210 names(f1f2.loadings.leverage) <- colnames(xMN)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
211 f1f2.loadings.leverage <- sort(f1f2.loadings.leverage, decreasing=TRUE)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
212 barplot(f1f2.loadings.leverage[f1f2.loadings.leverage > 0.001], main="Leverage values")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
213 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
214 dev.off()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
215 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
216
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
217 tryCatch({
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
218 save(result, file="asca.RData");
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
219 }, warning = function(w) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
220 print(paste("Warning: ", w));
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
221 }, error = function(err) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
222 stop(paste("ERROR saving result RData object:", err));
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
223 });
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
224 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
225
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
226 ## ending
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
227 ##-------
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
228
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
229 cat("\nEnd of the '", modNamC, "' Galaxy module call: ",
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
230 format(Sys.time(), "%a %d %b %Y %X"), "\n", sep = "")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
231
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
232 sink()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
233
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
234 # options(stringsAsFactors = strAsFacL)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
235
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
236
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
237 rm(list = ls())