annotate NmrBucketing_wrapper.R @ 9:62c62e31fc80 draft

planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
author lecorguille
date Fri, 21 Apr 2017 08:53:40 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
2
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
3 ## 070115_NmrBucketing2galaxy_v1.R
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
4 ## Marie Tremblay-Franco
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
5 ## MetaboHUB: The French Infrastructure for Metabolomics and Fluxomics
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
6 ## www.metabohub.fr/en
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
7 ## marie.tremblay-franco@toulouse.inra.fr
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
8
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
9 runExampleL <- FALSE
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
10
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
11 if(runExampleL) {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
12 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
13 ## Example of arguments
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
14 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
15 argLs <- list(StudyDir = "Tlse_BPASourisCerveau",
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
16 upper = "10.0",
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
17 lower = "0.50",
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
18 bucket.width = "0.01",
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
19 exclusion = "TRUE",
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
20 exclusion.zone = list(c(6.5,4.5)),
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
21 graph="Overlay")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
22
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
23 argLs <- c(argLs,
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
24 list(dataMatrixOut = paste(directory,"_NmrBucketing_dataMatrix.tsv",sep=""),
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
25 sampleMetadataOut = paste(directory,"_NmrBucketing_sampleMetadata.tsv",sep=""),
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
26 variableMetadataOut = paste(directory,"_NmrBucketing_variableMetadata.tsv",sep=""),
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
27 graphOut = paste(directory,"_NmrBucketing_graph.pdf",sep=""),
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
28 logOut = paste(directory,"_NmrBucketing_log.txt",sep="")))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
29 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
30
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
31 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
32 ## Options
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
33 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
34 strAsFacL <- options()$stringsAsFactors
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
35 options(stringsAsFactors = FALSE)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
36
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
37
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
38 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
39 ## Libraries laoding
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
40 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
41 # For parseCommandArgs function
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
42 library(batch)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
43 # For cumtrapz function
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
44 library(pracma)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
45
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
46 # R script call
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
47 source_local <- function(fname)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
48 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
49 argv <- commandArgs(trailingOnly = FALSE)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
50 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
51 source(paste(base_dir, fname, sep="/"))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
52 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
53 #Import the different functions
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
54 source_local("NmrBucketing_script.R")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
55 source_local("DrawSpec.R")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
56
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
57 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
58 ## Errors ?????????????????????
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
59 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
60
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
61
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
62 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
63 ## Constants
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
64 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
65 topEnvC <- environment()
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
66 flagC <- "\n"
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
67
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
68
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
69 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
70 ## Script
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
71 ##------------------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
72 if(!runExampleL)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
73 argLs <- parseCommandArgs(evaluate=FALSE)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
74
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
75
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
76 ## Parameters Loading
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
77 ##-------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
78 # Inputs
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
79 if (!is.null(argLs[["zipfile"]])){
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
80 fileType="zip"
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
81 zipfile= argLs[["zipfile"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
82 directory=unzip(zipfile, list=F)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
83 directory=paste(getwd(),strsplit(directory[1],"/")[[1]][2],sep="/")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
84 } else if (!is.null(argLs[["tsvfile"]])){
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
85 fileType="tsv"
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
86 directory <- read.table(argLs[["tsvfile"]],check.names=FALSE,header=TRUE,sep="\t")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
87 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
88
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
89 leftBorder <- argLs[["left_border"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
90 rightBorder <- argLs[["right_border"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
91 bucketSize <- argLs[["bucket_width"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
92 exclusionZones <- argLs[["zone_exclusion_choices.choice"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
93
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
94 exclusionZonesBorders <- NULL
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
95 if (!is.null(argLs$zone_exclusion_left))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
96 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
97 for(i in which(names(argLs)=="zone_exclusion_left"))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
98 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
99 exclusionZonesBorders <- c(exclusionZonesBorders,list(c(argLs[[i]],argLs[[i+1]])))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
100 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
101 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
102
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
103 graphique <- argLs[["graphType"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
104
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
105 # Outputs
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
106 nomGraphe <- argLs[["graphOut"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
107 dataMatrixOut <- argLs[["dataMatrixOut"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
108 logFile <- argLs[["logOut"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
109 if (fileType=="zip")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
110 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
111 sampleMetadataOut <- argLs[["sampleOut"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
112 variableMetadataOut <- argLs[["variableOut"]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
113 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
114
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
115 ## Checking arguments
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
116 ##-------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
117 error.stock <- "\n"
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
118
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
119 if(length(error.stock) > 1)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
120 stop(error.stock)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
121
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
122
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
123 ## Computation
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
124 ##------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
125 outputs <- NmrBucketing(fileType=fileType, fileName=directory, leftBorder=leftBorder, rightBorder=rightBorder, bucketSize=bucketSize,
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
126 exclusionZones=exclusionZones, exclusionZonesBorders=exclusionZonesBorders, graph=graphique, nomFichier=nomGraphe,
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
127 savLog.txtC=logFile)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
128 data_bucket <- outputs[[1]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
129 data_sample <- outputs[[2]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
130 data_variable <- outputs[[3]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
131 ppm <- outputs[[4]]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
132 ppm <- round(ppm,2)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
133
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
134 ## Graphical outputs
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
135 ##------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
136 if (graphique != "None")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
137 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
138 excludedZone <- NULL
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
139 for (c in 1:length(exclusionZonesBorders))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
140 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
141 excludedZone <- c(excludedZone,exclusionZonesBorders[[c]])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
142 excludedZone <- sort(excludedZone)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
143 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
144 nbZones <- length(excludedZone)/2
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
145 n <- length(excludedZone)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
146
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
147 # Graphic Device opening
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
148 pdf(nomGraphe,onefile=TRUE)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
149
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
150 if (graphique == "Overlay")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
151 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
152 # Global spectral window
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
153 spectra <- data.frame(t(data_bucket))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
154 drawSpec(spectra,xlab="", ylab="Intensity", main="")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
155
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
156 ## Zoomed spectral window depending on exclusion zone(s)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
157 if (nbZones != 0)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
158 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
159 BInf <- excludedZone[n]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
160 if (round(BInf,1) == BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
161 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
162 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
163 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
164 spectra <- data.frame(t(data_bucket[1:(which(ppm == BInf)[[1]]),]))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
165 drawSpec(spectra,xlab="", ylab="Intensity", main="")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
166 n <- n - 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
167
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
168 while (n >= nbZones & nbZones > 1)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
169 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
170 BInf <- excludedZone[n-1]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
171 if (round(BInf,1) > BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
172 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
173 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
174 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
175 spectra <- data.frame(t(data_bucket[(which(ppm == excludedZone[n])[[1]]):(which(ppm == BInf)[[1]]),]))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
176 drawSpec(spectra,xlab="", ylab="Intensity", main="")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
177 n <- n - 2
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
178 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
179
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
180 BInf <- excludedZone[1]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
181 if (round(BInf,1) <= BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
182 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
183 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
184 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
185 spectra <- data.frame(t(data_bucket[(which(ppm == BInf)[[1]]):nrow(data_bucket),]))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
186 drawSpec(spectra,xlab="", ylab="Intensity", main="")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
187 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
188 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
189 else
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
190 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
191 for (i in 1:ncol(data_bucket))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
192 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
193 par(mfrow=c((nbZones+2),1))
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
194 n <- length(excludedZone)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
195 spectra <- t(data_bucket[,i])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
196 names(spectra) <- rownames(data_bucket)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
197 plot(1:length(spectra), spectra, type='l', xlab="", ylab="Intensity", main=colnames(data_bucket)[i], xaxt = "n")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
198 xPos <- 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
199 nAxisPos <- 4
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
200 startP <- length(nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
201 endP <- nrow(data_bucket)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
202 GraphRange <- c(startP:endP)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
203 tempVal = trunc(length(GraphRange)/nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
204 xPos = c(0:nAxisPos) * tempVal
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
205 axis(1, at = xPos, labels = rownames(data_bucket)[xPos + startP])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
206
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
207 ## Zoomed spectral window depending on exclusion zone(s)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
208 if (nbZones != 0)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
209 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
210 BInf <- excludedZone[n]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
211 if (round(BInf,1) == BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
212 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
213 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
214 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
215 spectra <- t(data_bucket[1:(which(ppm == BInf)[[1]]),i])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
216 names(spectra) <- rownames(data_bucket)[1:(which(ppm == BInf)[[1]])]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
217 plot(1:length(spectra), spectra, type='l',xlab="", ylab="Intensity", main="", xaxt = "n")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
218 xPos <- 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
219 nAxisPos <- 4
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
220 startP <- length(nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
221 endP <- length(spectra)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
222 GraphRange <- c(startP:endP)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
223 tempVal = trunc(length(GraphRange)/nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
224 xPos = c(0:nAxisPos) * tempVal
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
225 axis(1, at = xPos, labels = rownames(data_bucket)[xPos + startP])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
226 n <- n - 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
227
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
228 while (n >= nbZones & nbZones > 1)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
229 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
230 BInf <- excludedZone[n-1]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
231 if (round(BInf,1) > BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
232 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
233 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
234 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
235 spectra <- t(data_bucket[(which(ppm == excludedZone[n])[[1]]):(which(ppm == BInf)[[1]]),i])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
236 names(spectra) <- rownames(data_bucket)[(which(ppm == excludedZone[n])[[1]]):(which(ppm == BInf)[[1]])]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
237 plot(1:length(spectra), spectra, type='l',xlab="", ylab="Intensity", main="", xaxt = "n")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
238 xPos <- 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
239 nAxisPos <- 4
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
240 startP <- length(nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
241 endP <- length(spectra)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
242 GraphRange <- c(startP:endP)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
243 tempVal = trunc(length(GraphRange)/nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
244 xPos = c(0:nAxisPos) * tempVal
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
245 axis(1, at = xPos, labels = rownames(data_bucket)[xPos + startP])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
246 n <- n - 2
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
247 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
248
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
249 BInf <- excludedZone[1]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
250 if (round(BInf,1) <= BInf)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
251 {
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
252 BInf <- BInf+0.01
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
253 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
254 spectra <- t(data_bucket[(which(ppm == BInf)[[1]]):nrow(data_bucket),i])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
255 names(spectra) <- rownames(data_bucket)[(which(ppm == BInf)[[1]]):nrow(data_bucket)]
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
256 plot(1:length(spectra), spectra, type='l',xlab="", ylab="Intensity", main="", xaxt = "n")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
257 xPos <- 1
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
258 nAxisPos <- 4
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
259 startP <- length(nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
260 endP <- length(spectra)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
261 GraphRange <- c(startP:endP)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
262 tempVal = trunc(length(GraphRange)/nAxisPos)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
263 xPos = c(0:nAxisPos) * tempVal
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
264 axis(1, at = xPos, labels = rownames(data_bucket)[xPos + startP])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
265 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
266 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
267 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
268 dev.off()
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
269 }
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
270 ## Saving
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
271 ##-------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
272 # Data
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
273 data_bucket <- cbind(rownames(data_bucket),data_bucket)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
274 colnames(data_bucket) <- c("Bucket",colnames(data_bucket)[-1])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
275 write.table(data_bucket,file=argLs$dataMatrixOut,quote=FALSE,row.names=FALSE,sep="\t")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
276 # Sample
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
277 data_sample <- cbind(rownames(data_sample),data_sample)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
278 colnames(data_sample) <- c("Sample",colnames(data_sample)[-1])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
279 write.table(data_sample,file=argLs$sampleOut,quote=FALSE,row.names=FALSE,sep="\t")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
280 # Variable
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
281 data_variable <- cbind(rownames(data_variable),data_variable)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
282 colnames(data_variable) <- c("Bucket",colnames(data_variable)[-1])
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
283 write.table(data_variable,file=argLs$variableOut,quote=FALSE,row.names=FALSE,sep="\t")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
284
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
285
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
286 ## Ending
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
287 ##---------------------
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
288
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
289 cat("\nEnd of 'NMR bucketing' Galaxy module call: ", as.character(Sys.time()), sep = "")
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
290
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
291 ## sink(NULL)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
292
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
293 options(stringsAsFactors = strAsFacL)
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
294
62c62e31fc80 planemo upload for repository https://github.com/workflow4metabolomics/nmr_bucketing commit fc2be0f9fa66f830d592d74d14b47a63e761647b
lecorguille
parents:
diff changeset
295 rm(list = ls())