annotate probmetab.r @ 0:e13ec2c3fabe draft

planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
author mmonsoor
date Mon, 04 Jul 2016 04:29:25 -0400
parents
children abcfa1648b66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
2 # probmetab.r version="1.0.0"
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
3 # Author: Misharl Monsoor ABIMS TEAM mmonsoor@sb-roscoff.fr
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
4
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
5
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
6 # ----- LOG -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
7 log_file=file("probmetab.log", open = "wt")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
8 sink(log_file)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
9 sink(log_file, type = "out")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
10
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
11 # ----- PACKAGE -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
12 cat("\tPACKAGE INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
13 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "igraph", "xcms","snow","CAMERA","batch","ProbMetab")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
14 for(p in pkgs) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
15 suppressWarnings( suppressPackageStartupMessages( stopifnot( library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))))
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
16 cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
17 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
18
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
19 source_local <- function(fname){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
20 argv <- commandArgs(trailingOnly = FALSE)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
21 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
22 source(paste(base_dir, fname, sep="/"))
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
23 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
24 cat("\n\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
25 # ----- ARGUMENTS -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
26 cat("\tARGUMENTS INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
27 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
28 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
29
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
30
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
31
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
32 # ----- PROCESSING INFILE -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
33 cat("\tINFILE PROCESSING INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
34
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
35 # ----- INFILE PROCESSING -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
36
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
37 if(listArguments[["mode_acquisition"]]=="one") {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
38 load(listArguments[["xa"]])
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
39
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
40 if (!is.null(listArguments[["zipfile"]])){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
41 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
42 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
43
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
44 #Unzip the chromatograms file for plotting EIC pour the HTML file
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
45 if(exists("zipfile"))
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
46 {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
47 if (zipfile!=""){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
48 directory=unzip(zipfile)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
49 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
50 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
51 if (!exists("xa")) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
52 xa=xsAnnotate_object
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
53 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
54 source_local("lib.r")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
55 if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
56
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
57 } else if(listArguments[["inputs_mode"]]=="two"){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
58 load(listArguments[["image_pos"]])
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
59
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
60 if (!is.null(listArguments[["zipfile"]])){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
61 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
62 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
63
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
64 #Unzip the chromatograms file for plotting EIC pour the HTML file
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
65 if(exists("zipfile")) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
66 if (zipfile!=""){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
67 directory=unzip(zipfile)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
68 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
69 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
70 if (!exists("xa")) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
71 xa=xsAnnotate_object
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
72 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
73 xaP=xa
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
74 source_local("lib.r")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
75 if (!exists("variableMetadata")) variableMetadataP= getVariableMetadata(xa)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
76 else variableMetadataP=variableMetadata
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
77
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
78
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
79 load(listArguments[["image_neg"]])
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
80
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
81 if (!is.null(listArguments[["zipfile"]])){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
82 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
83 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
84
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
85 #Unzip the chromatograms file for plotting EIC pour the HTML file
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
86 if(exists("zipfile")) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
87
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
88 if (zipfile!=""){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
89 directory=unzip(zipfile)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
90 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
91 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
92 if (!exists("xa")) {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
93 xa=xsAnnotate_object
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
94 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
95 xaN=xa
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
96 source_local("lib.r")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
97
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
98 if (!exists("variableMetadata")) variableMetadataN= getVariableMetadata(xa)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
99 else variableMetadataN=variableMetadata
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
100 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
101
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
102 #Import the different functions
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
103 source_local("lib.r")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
104 source_local("export.class.table-color-graph.R")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
105
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
106 # ----- PROCESSING INFO -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
107 cat("\tMAIN PROCESSING INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
108
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
109 if(listArguments[["mode_acquisition"]]=="one") {
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
110 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
111 } else if(listArguments[["inputs_mode"]]=="two"){
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
112 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
113 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
114 #delete the parameters to avoid the passage to the next tool in .RData image
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
115 #rm(listArguments)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
116 cat("\tDONE\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
117 #saving R data in .Rdata file to save the variables used in the present tool
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
118 #save.image(paste("probmetab","RData",sep="."))
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
119