annotate probmetab.r @ 4:52b222a626b0 draft default tip

planemo upload commit 00684d80f032fee5bd1cb86e05a477fcdcb1c3fc
author lecorguille
date Fri, 07 Apr 2017 09:11:22 -0400
parents abcfa1648b66
children
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 -----
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
7 log_file=file("log.txt", open = "wt")
0
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) {
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
15 suppressWarnings( suppressPackageStartupMessages( stopifnot( library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))))
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
16 cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
0
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 }
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
24
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
25 options(bitmapType='cairo')
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
26
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
27 cat("\n\n")
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
28
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
29
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
30 # ----- ARGUMENTS -----
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
31 cat("\tARGUMENTS INFO\n")
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
32 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
33 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
34
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
35
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
36
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
37 # ----- PROCESSING INFILE -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
38 cat("\tINFILE PROCESSING INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
39
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
40 # ----- INFILE PROCESSING -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
41
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
42 if(listArguments[["mode_acquisition"]]=="one") {
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
43 load(listArguments[["image"]])
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
44 cat("\t\tXA OBJECT INFO\n")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
45 print(xa)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
46
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
47 source_local("lib.r")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
48 if (!exists("zipfile")) zipfile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
49 if (!exists("singlefile")) singlefile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
50 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
51 zipfile = rawFilePath$zipfile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
52 singlefile = rawFilePath$singlefile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
53 retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
54
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
55 if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
56
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
57 } else if(listArguments[["inputs_mode"]]=="two"){
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
58
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
59 # POSITIVE
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
60 load(listArguments[["image_pos"]])
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
61
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
62 if (!exists("xa")) xaP=xsAnnotate_object
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
63 else xaP=xa
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
64 cat("\t\tXA-POSITIVE OBJECT INFO\n")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
65 print(xaP)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
66
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
67 if (!exists("variableMetadata")) variableMetadataP = getVariableMetadata(xa)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
68 else variableMetadataP = variableMetadata
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
69
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
70 source_local("lib.r")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
71 if (!exists("zipfile")) zipfile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
72 if (!exists("singlefile")) singlefile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
73 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
74 zipfilePos = rawFilePath$zipfile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
75 singlefilePos = rawFilePath$singlefile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
76 retrieveRawfileInTheWorkingDirectory(singlefilePos, zipfilePos)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
77
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
78 # NEGATIVE
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
79 load(listArguments[["image_neg"]])
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
80
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
81 if (!exists("xa")) xaN=xsAnnotate_object
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
82 else xaN=xa
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
83 cat("\t\tXA-NEGATIVE OBJECT INFO\n")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
84 print(xaP)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
85
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
86 if (!exists("variableMetadata")) variableMetadataN = getVariableMetadata(xa)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
87 else variableMetadataN = variableMetadata
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
88
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
89 source_local("lib.r")
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
90 if (!exists("zipfile")) zipfile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
91 if (!exists("singlefile")) singlefile=NULL
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
92 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
93 zipfileNeg = rawFilePath$zipfile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
94 singlefileNeg = rawFilePath$singlefile
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
95 retrieveRawfileInTheWorkingDirectory(singlefileNeg, zipfileNeg)
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
96 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
97
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
98 #Import the different functions
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
99 source_local("lib.r")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
100 source_local("export.class.table-color-graph.R")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
101
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
102 # ----- PROCESSING INFO -----
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
103 cat("\tMAIN PROCESSING INFO\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
104
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
105 if(listArguments[["mode_acquisition"]]=="one") {
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
106 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
107 } else if(listArguments[["inputs_mode"]]=="two"){
3
abcfa1648b66 planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
lecorguille
parents: 0
diff changeset
108 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
0
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
109 }
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
110 #delete the parameters to avoid the passage to the next tool in .RData image
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
111 #rm(listArguments)
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
112 cat("\tDONE\n")
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
113 #saving R data in .Rdata file to save the variables used in the present tool
e13ec2c3fabe planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
mmonsoor
parents:
diff changeset
114 #save.image(paste("probmetab","RData",sep="."))