Mercurial > repos > marie-tremblay-metatoul > normalization
annotate NmrNormalization_wrapper.R @ 5:3d00a98974b7 draft
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
author | lecorguille |
---|---|
date | Tue, 02 Oct 2018 12:14:47 -0400 |
parents | |
children | 221cbd549c40 |
rev | line source |
---|---|
5
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
2 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
3 ## 070115_NmrBucketing2galaxy_v1.R |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
4 ## Marie Tremblay-Franco |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
5 ## MetaboHUB: The French Infrastructure for Metabolomics and Fluxomics |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
6 ## www.metabohub.fr/en |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
7 ## marie.tremblay-franco@toulouse.inra.fr |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
8 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
9 runExampleL <- FALSE |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
10 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
11 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
12 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
13 ## Options |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
14 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
15 strAsFacL <- options()$stringsAsFactors |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
16 options(stringsAsFactors = FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
17 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
18 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
19 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
20 ## Libraries laoding |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
21 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
22 # For parseCommandArgs function |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
23 library(batch) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
24 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
25 # Constants |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
26 argv <- commandArgs(trailingOnly = FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
27 script.path <- sub("--file=","",argv[grep("--file=",argv)]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
28 prog.name <- basename(script.path) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
29 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
30 # Print help |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
31 if (length(grep('-h', argv)) >0) { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
32 cat("Usage:", prog.name, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
33 "dataMatrix myDataMatrix.tsv", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
34 "scalingMethod PQN|QuantitativeVariable", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
35 "graphType None|Overlay|One_per_individual", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
36 "logOut myLog.txt", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
37 "dataMatrixOut myDataMatrixOutput.tsv", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
38 "graphOut myGraph.pdf", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
39 "\n") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
40 quit(status = 0) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
41 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
42 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
43 # R script call |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
44 source_local <- function(fname) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
45 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
46 argv <- commandArgs(trailingOnly = FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
47 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
48 source(paste(base_dir, fname, sep="/")) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
49 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
50 #Import the different functions |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
51 source_local("NmrNormalization_script.R") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
52 source_local("DrawSpec.R") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
53 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
54 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
55 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
56 ## Errors ????????????????????? |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
57 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
58 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
59 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
60 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
61 ## Constants |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
62 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
63 topEnvC <- environment() |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
64 flagC <- "\n" |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
65 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
66 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
67 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
68 ## Script |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
69 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
70 if(!runExampleL) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
71 argLs <- parseCommandArgs(evaluate=FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
72 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
73 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
74 ## Parameters Loading |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
75 ##------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
76 # Inputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
77 data <- read.table(argLs[["dataMatrix"]], check.names=FALSE, header=TRUE, sep="\t", row.names=1) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
78 names <- rownames(data) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
79 ## Add a test to check if all values are numercical |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
80 if (!all(vapply(data, is.numeric, FUN.VALUE = FALSE))) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
81 stop("Data are not numeric") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
82 ## Integer conversion to avoid stack overflow when computin the sum |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
83 data <- as.data.frame(lapply(data, as.numeric)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
84 rownames(data) <- names |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
85 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
86 scaling <- argLs[["scalingMethod"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
87 graphique <- argLs[["graphType"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
88 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
89 if (scaling=='PQN') |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
90 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
91 metadataSample <- read.table(argLs[["sampleMetadata"]],check.names=FALSE,header=TRUE,sep="\t") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
92 factor<- argLs[["factor"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
93 ControlGroup <- argLs[["controlGroup"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
94 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
95 if (scaling=='QuantitativeVariable') |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
96 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
97 metadataSample <- read.table(argLs[["sampleMetadata"]],check.names=FALSE,header=TRUE,sep="\t") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
98 factor <- argLs[["factor"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
99 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
100 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
101 # Outputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
102 nomGraphe <- argLs[["graphOut"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
103 dataMatrixOut <- argLs[["dataMatrixOut"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
104 log <- argLs[["logOut"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
105 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
106 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
107 ## Checking R packages |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
108 ##-------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
109 sink(log) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
110 cat("\tPACKAGE INFO\n") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
111 pkgs=c("batch") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
112 for(pkg in pkgs) { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
113 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE))) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
114 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
115 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
116 cat("\n") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
117 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
118 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
119 ## Checking arguments |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
120 ##------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
121 error.stock <- "\n" |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
122 if(length(error.stock) > 1) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
123 stop(error.stock) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
124 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
125 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
126 ## Computation |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
127 ##------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
128 NormalizationResults <- NmrNormalization(dataMatrix=data,scalingMethod=scaling,sampleMetadata=metadataSample, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
129 bioFactor=factor,ControlGroup=ControlGroup, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
130 graph=graphique,nomFichier=nomGraphe,savLog.txtC=log) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
131 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
132 data_normalized <- NormalizationResults[[1]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
133 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
134 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
135 ## Graphical outputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
136 ##------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
137 if (graphique != "None") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
138 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
139 # Graphic Device opening |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
140 pdf(nomGraphe,onefile=TRUE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
141 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
142 if (graphique == "Overlay") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
143 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
144 # Global spectral window |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
145 spectra <- data.frame(t(data_normalized)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
146 drawSpec(spectra,xlab="", ylab="Intensity", main="") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
147 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
148 else |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
149 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
150 for (i in 1:ncol(data_normalized)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
151 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
152 spectra <- t(data_normalized[,i]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
153 drawSpec(spectra,xlab="", ylab="Intensity", main=colnames(data_normalized)[i]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
154 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
155 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
156 dev.off() |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
157 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
158 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
159 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
160 ## Saving |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
161 ##------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
162 # Data |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
163 data_normalized <- cbind(rownames(data_normalized),data_normalized) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
164 colnames(data_normalized) <- c("Variable",colnames(data_normalized)[-1]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
165 write.table(data_normalized,file=argLs$dataMatrixOut,quote=FALSE,row.names=FALSE,sep="\t") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
166 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
167 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
168 ## Ending |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
169 ##--------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
170 cat("\nEnd of 'Normalization' Galaxy module call: ", as.character(Sys.time()), sep = "") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
171 sink() |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
172 options(stringsAsFactors = strAsFacL) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
173 rm(list = ls()) |