Mercurial > repos > marie-tremblay-metatoul > normalization
annotate NmrNormalization_wrapper.R @ 6:221cbd549c40 draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 4bbd4d65e954192aff1a4d210001deb625667136
author | workflow4metabolomics |
---|---|
date | Tue, 30 Jul 2019 09:43:57 -0400 |
parents | 3d00a98974b7 |
children |
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) |
6
221cbd549c40
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 4bbd4d65e954192aff1a4d210001deb625667136
workflow4metabolomics
parents:
5
diff
changeset
|
17 options(scipen=999) |
5
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 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
21 ## Libraries laoding |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
22 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
23 # For parseCommandArgs function |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
24 library(batch) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
25 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
26 # Constants |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
27 argv <- commandArgs(trailingOnly = FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
28 script.path <- sub("--file=","",argv[grep("--file=",argv)]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
29 prog.name <- basename(script.path) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
30 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
31 # Print help |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
32 if (length(grep('-h', argv)) >0) { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
33 cat("Usage:", prog.name, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
34 "dataMatrix myDataMatrix.tsv", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
35 "scalingMethod PQN|QuantitativeVariable", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
36 "graphType None|Overlay|One_per_individual", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
37 "logOut myLog.txt", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
38 "dataMatrixOut myDataMatrixOutput.tsv", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
39 "graphOut myGraph.pdf", |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
40 "\n") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
41 quit(status = 0) |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
44 # R script call |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
45 source_local <- function(fname) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
46 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
47 argv <- commandArgs(trailingOnly = FALSE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
48 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
|
49 source(paste(base_dir, fname, sep="/")) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
50 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
51 #Import the different functions |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
52 source_local("NmrNormalization_script.R") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
53 source_local("DrawSpec.R") |
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 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
57 ## Errors ????????????????????? |
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 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
62 ## Constants |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
63 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
64 topEnvC <- environment() |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
65 flagC <- "\n" |
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 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
69 ## Script |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
70 ##------------------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
71 if(!runExampleL) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
72 argLs <- parseCommandArgs(evaluate=FALSE) |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
75 ## Parameters Loading |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
76 ##------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
77 # Inputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
78 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
|
79 names <- rownames(data) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
80 ## 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
|
81 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
|
82 stop("Data are not numeric") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
83 ## 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
|
84 data <- as.data.frame(lapply(data, as.numeric)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
85 rownames(data) <- names |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
86 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
87 scaling <- argLs[["scalingMethod"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
88 graphique <- argLs[["graphType"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
89 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
90 if (scaling=='PQN') |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
91 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
92 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
|
93 factor<- argLs[["factor"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
94 ControlGroup <- argLs[["controlGroup"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
95 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
96 if (scaling=='QuantitativeVariable') |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
97 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
98 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
|
99 factor <- argLs[["factor"]] |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
102 # Outputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
103 nomGraphe <- argLs[["graphOut"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
104 dataMatrixOut <- argLs[["dataMatrixOut"]] |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
105 log <- argLs[["logOut"]] |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
108 ## Checking R packages |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
109 ##-------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
110 sink(log) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
111 cat("\tPACKAGE INFO\n") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
112 pkgs=c("batch") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
113 for(pkg in pkgs) { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
114 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
|
115 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
|
116 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
117 cat("\n") |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
120 ## Checking arguments |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
121 ##------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
122 error.stock <- "\n" |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
123 if(length(error.stock) > 1) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
124 stop(error.stock) |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
127 ## Computation |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
128 ##------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
129 NormalizationResults <- NmrNormalization(dataMatrix=data,scalingMethod=scaling,sampleMetadata=metadataSample, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
130 bioFactor=factor,ControlGroup=ControlGroup, |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
131 graph=graphique,nomFichier=nomGraphe,savLog.txtC=log) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
132 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
133 data_normalized <- NormalizationResults[[1]] |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
136 ## Graphical outputs |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
137 ##------------------ |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
138 if (graphique != "None") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
139 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
140 # Graphic Device opening |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
141 pdf(nomGraphe,onefile=TRUE) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
142 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
143 if (graphique == "Overlay") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
144 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
145 # Global spectral window |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
146 spectra <- data.frame(t(data_normalized)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
147 drawSpec(spectra,xlab="", ylab="Intensity", main="") |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
148 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
149 else |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
150 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
151 for (i in 1:ncol(data_normalized)) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
152 { |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
153 spectra <- t(data_normalized[,i]) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
154 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
|
155 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
156 } |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
157 dev.off() |
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 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
161 ## Saving |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
162 ##------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
163 # Data |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
164 data_normalized <- cbind(rownames(data_normalized),data_normalized) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
165 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
|
166 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
|
167 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
168 |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
169 ## Ending |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
170 ##--------------------- |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
171 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
|
172 sink() |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
173 options(stringsAsFactors = strAsFacL) |
3d00a98974b7
planemo upload for repository https://github.com/workflow4metabolomics/normalization commit 1aedb0fe77d56139bc8f5ded1fee1e455e8e9495
lecorguille
parents:
diff
changeset
|
174 rm(list = ls()) |