annotate asics_wrapper.R @ 4:0ff2d9211ebe draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 3791815505685d0038e392a702860843fe1d443e
author marie-tremblay-metatoul
date Fri, 21 Sep 2018 07:42:53 -0400
parents b55559a2854f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
2
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
3 ## 29122017_asics_wrapper.R
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
4 ## Remi Servien, Patrick Tardivel, Marie Tremblay-Franco and Gaelle Lefort
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
5 ## marie.tremblay-franco@inra.fr
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
6
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
7 runExampleL <- FALSE
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
8
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
9 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
10 ## Options
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
11 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
12 strAsFacL <- options()$stringsAsFactors
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
13 options(stringsAsFactors=FALSE)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
14
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
15
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
16 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
17 ## Libraries loading
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
18 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
19 # ParseCommandArgs function
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
20 library(batch)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
21 library(ASICS)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
22
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
23
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
24
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
25 # R script call
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
26 source_local <- function(fname)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
27 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
28 argv <- commandArgs(trailingOnly=FALSE)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
29 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
30 source(paste(base_dir, fname, sep="/"))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
31 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
32 #Import the different functions
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
33 source_local("DrawSpec.R")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
34
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
35
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
36 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
37 ## Errors ?????????????????????
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
38 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
39
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
40
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
41 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
42 ## Constants
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
43 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
44 topEnvC <- environment()
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
45 flagC <- "\n"
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
46
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
47
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
48 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
49 ## Script
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
50 ##------------------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
51 if(!runExampleL)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
52 argLs <- parseCommandArgs(evaluate=FALSE)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
53
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
54 # Standards loading
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
55 load(argLs[["standards"]])
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
56
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
57 ## Parameters Loading
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
58 ##-------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
59 # Inputs
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
60 ## Spectrum to annotate
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
61 zipfile= argLs[["zipfile"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
62 directory=unzip(zipfile, list=F)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
63 directory=paste(getwd(),strsplit(directory[1],"/")[[1]][2],sep="/")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
64
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
65
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
66 ##Exclusion zone(s)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
67 exclusionZones <- argLs[["zone_exclusion_choices.choice"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
68 exclusionZonesBorders <- NULL
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
69 if (!is.null(argLs$zone_exclusion_left))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
70 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
71 for(i in which(names(argLs)=="zone_exclusion_left"))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
72 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
73 # exclusionZonesBorders <- c(exclusionZonesBorders,list(c(argLs[[i]],argLs[[i+1]])))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
74 exclusionZonesBorders <- c(exclusionZonesBorders,argLs[[i]],argLs[[i+1]])
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
75 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
76 exclusionZonesBorders <- matrix(exclusionZonesBorders, byrow=T, ncol=2)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
77 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
78 if (is.null(argLs$zone_exclusion_left))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
79 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
80 exclusionZonesBorders <- matrix(c(0,0), byrow=T, ncol=2)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
81 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
82 ## Maximal allowed shift
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
83 shift <- argLs[["shift"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
84
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
85 ## Graphical zone(s)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
86 graphicalZones <- argLs[["zone_graphical_choices.choice"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
87 graphicalZonesBorders <- NULL
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
88 if (!is.null(argLs$zone_exclusion_left))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
89 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
90 for(i in which(names(argLs)=="zone_graphical_left"))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
91 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
92 graphicalZonesBorders <- c(graphicalZonesBorders,list(c(argLs[[i]],argLs[[i+1]])))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
93 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
94 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
95
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
96 # Outputs
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
97 logOut <- argLs[["logOut"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
98 proportionEstimation <- argLs[["proportionEstimation"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
99 graphOut <- argLs[["graphOut"]]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
100
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
101 sink(logOut)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
102 cat("\tPACKAGE INFO\n")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
103 # pkgs=c("batch", "ASICS")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
104 pkgs=c("batch", "ASICS")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
105 for(pkg in pkgs) {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
106 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
107 cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
108 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
109 cat("\n")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
110
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
111
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
112 ## Checking arguments
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
113 ##-------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
114 error.stock <- "\n"
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
115 if(length(error.stock) > 1)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
116 stop(error.stock)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
117
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
118
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
119 ## Computation
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
120 ##------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
121 # annotation.Asics <- ASICS(directory, exclusion.areas=matrix(exclusionZonesBorders, byrow=T, ncol=2),
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
122 # max.shift=shift, which.spectra="last", library.metabolites=NULL,
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
123 # threshold.noise=0.02, seed=1234, nb.iter.signif=400)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
124 annotation.Asics <- ASICS(directory, exclusion.areas=exclusionZonesBorders,
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
125 max.shift=shift, which.spectra="last", library.metabolites=NULL,
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
126 threshold.noise=0.02, seed=1234, nb.iter.signif=400)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
127
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
128
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
129 ## Saving
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
130 ##-------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
131 # Identified metabolites
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
132 metabolites.estimation <- present_metabolites(annotation.Asics)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
133 colnames(metabolites.estimation) <- c("Metabolite",colnames(metabolites.estimation)[-1])
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
134 write.table(metabolites.estimation,file=argLs$proportionEstimation,row.names=FALSE,quote=FALSE,sep="\t")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
135
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
136
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
137 ## Graphical display
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
138 ##------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
139 # Raw and annotated spectra comparison
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
140 pdf(graphOut,onefile=TRUE)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
141
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
142 ## Graphical output: overlay of raw and estimated spectra
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
143 ppm.metabolites.estimation <- data.frame(round(ppm_grid(annotation.Asics),3),
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
144 original_mixture(annotation.Asics))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
145 colnames(ppm.metabolites.estimation) <- c("PPM", "EstimatedProportion")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
146 ppm.metabolites.estimation <- ppm.metabolites.estimation[order(ppm.metabolites.estimation[,1],decreasing=T), ]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
147
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
148 mix <- data.frame(t(ppm.metabolites.estimation[,2]))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
149 colnames(mix) <- ppm.metabolites.estimation[,1]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
150 ppm <- ppm.metabolites.estimation[,1]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
151
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
152 estimatedMix <- data.frame(round(ppm_grid(annotation.Asics),3), reconstituted_mixture(annotation.Asics))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
153 colnames(estimatedMix) <- c("PPM","EstimatedProportion")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
154 estimatedMix <- estimatedMix[order(estimatedMix[,1],decreasing=T), ]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
155 estimatedMix <- estimatedMix[,2]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
156
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
157 ## Whole spectra
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
158 GraphRange <- 1:ncol(mix)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
159 tempVal <- trunc(length(GraphRange)/10)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
160 xPos <- c(10:0) * tempVal
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
161 plot(1:ncol(mix), mix, type='l', xlab="", main="", xaxt="n", ylab="")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
162 axis(1, at=xPos, labels=colnames(mix)[xPos + 1])
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
163 lines(estimatedMix, col="red")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
164 legend("topleft",legend=c("Real Mixture","Estimated Composition"),lty=c(1,1),col=c("black","red"))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
165
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
166 ## Zoomed spectral window depending on user-selected zone(s)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
167 graphical.zone.length <- length(graphicalZonesBorders)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
168 if (graphical.zone.length != 0)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
169
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
170 # par(mfrow=c(2,1))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
171 for (g in 1:graphical.zone.length)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
172 {
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
173 print(g)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
174 plot(1:length((which(round(as.numeric(colnames(mix)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(mix)),2) == max(graphicalZonesBorders[[g]][2],0.5))[1])),
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
175 mix[(which(round(as.numeric(colnames(mix)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(mix)),2) == max(graphicalZonesBorders[[g]][2],0.5))[1])], type='l', xlab="", ylab="Intensity", main="", xaxt="n")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
176 lines(estimatedMix[(which(round(as.numeric(colnames(mix)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(mix)),2) == max(graphicalZonesBorders[[g]][2],0.5))[1])],col="red")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
177
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
178 xPos <- 1
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
179 nAxisPos <- 4
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
180 startP <- length(nAxisPos)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
181 endP <- length((which(round(as.numeric(colnames(mix)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(mix)),2) == max(graphicalZonesBorders[[g]][2],0.5))[1]))
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
182 GraphRange <- c(startP:endP)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
183 tempVal <- trunc(length(GraphRange)/nAxisPos)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
184 xPos <- c(0:nAxisPos) * tempVal
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
185 noms <- ppm.metabolites.estimation[xPos + which(ppm == round(graphicalZonesBorders[[g]][1],1))[1],1]
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
186 axis(1, at=xPos, labels=noms)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
187 }
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
188
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
189 invisible(dev.off())
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
190
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
191
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
192 ## Ending
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
193 ##---------------------
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
194 cat("\nEnd of 'NMR annotation' Galaxy module call: ", as.character(Sys.time()), sep="")
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
195 options(stringsAsFactors=strAsFacL)
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
196 rm(list=ls())
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
197 sink()
b55559a2854f planemo upload for repository https://github.com/workflow4metabolomics/nmr_annotation commit 1f3516e77a7c7a08ed16a66c913df456ba720553
lecorguille
parents:
diff changeset
198