comparison CAMERA.r @ 13:1c30ff90f3ae draft

planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
author lecorguille
date Fri, 07 Apr 2017 07:42:18 -0400
parents 7da9252dd983
children a2c49996603e
comparison
equal deleted inserted replaced
12:9c037181588e 13:1c30ff90f3ae
9 setRepositories(graphics=F, ind=31) 9 setRepositories(graphics=F, ind=31)
10 10
11 #pkgs=c("xcms","batch") 11 #pkgs=c("xcms","batch")
12 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "xcms","snow","igraph","CAMERA","multtest","batch") 12 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "xcms","snow","igraph","CAMERA","multtest","batch")
13 for(p in pkgs) { 13 for(p in pkgs) {
14 suppressPackageStartupMessages(suppressWarnings(library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))) 14 suppressPackageStartupMessages(suppressWarnings(library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
15 cat(p,"\t",as.character(packageVersion(p)),"\n",sep="") 15 cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
16 } 16 }
17 source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } 17 source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }
18 18
19 cat("\n\n"); 19 cat("\n\n");
20 20
21 21
22 22
23 # ----- ARGUMENTS ----- 23 # ----- ARGUMENTS -----
24 cat("\tARGUMENTS INFO\n") 24 cat("\tARGUMENTS INFO\n")
32 # ----- PROCESSING INFILE ----- 32 # ----- PROCESSING INFILE -----
33 cat("\tINFILE PROCESSING INFO\n") 33 cat("\tINFILE PROCESSING INFO\n")
34 34
35 #image is an .RData file necessary to use xset variable given by previous tools 35 #image is an .RData file necessary to use xset variable given by previous tools
36 if (!is.null(listArguments[["image"]])){ 36 if (!is.null(listArguments[["image"]])){
37 load(listArguments[["image"]]); listArguments[["image"]]=NULL 37 load(listArguments[["image"]]); listArguments[["image"]]=NULL
38 } 38 }
39 39
40 if (listArguments[["xfunction"]] %in% c("combinexsAnnos")) { 40 if (listArguments[["xfunction"]] %in% c("combinexsAnnos")) {
41 load(listArguments[["image_pos"]]) 41 load(listArguments[["image_pos"]])
42 xaP=xa 42 xaP=xa
43 listOFlistArgumentsP=listOFlistArguments 43 listOFlistArgumentsP=listOFlistArguments
44 if (exists("xsAnnotate_object")) xaP=xsAnnotate_object 44 if (exists("xsAnnotate_object")) xaP=xsAnnotate_object
45
46 diffrepP=NULL
47 if (exists("diffrep")) diffrepP=diffrep
48 45
49 load(listArguments[["image_neg"]]) 46 diffrepP=NULL
50 xaN=xa 47 if (exists("diffrep")) diffrepP=diffrep
51 listOFlistArgumentsN=listOFlistArguments
52 if (exists("xsAnnotate_object")) xaN=xsAnnotate_object
53 48
54 diffrepN=NULL 49 load(listArguments[["image_neg"]])
55 if (exists("diffrep")) diffrepN=diffrep 50 xaN=xa
51 listOFlistArgumentsN=listOFlistArguments
52 if (exists("xsAnnotate_object")) xaN=xsAnnotate_object
53
54 diffrepN=NULL
55 if (exists("diffrep")) diffrepN=diffrep
56 } 56 }
57 57
58 58
59 cat("\n\n") 59 cat("\n\n")
60 60
71 thefunction = listArguments[["xfunction"]] 71 thefunction = listArguments[["xfunction"]]
72 listArguments[["xfunction"]]=NULL #delete from the list of arguments 72 listArguments[["xfunction"]]=NULL #delete from the list of arguments
73 73
74 xsetRdataOutput = paste(thefunction,"RData",sep=".") 74 xsetRdataOutput = paste(thefunction,"RData",sep=".")
75 if (!is.null(listArguments[["xsetRdataOutput"]])){ 75 if (!is.null(listArguments[["xsetRdataOutput"]])){
76 xsetRdataOutput = listArguments[["xsetRdataOutput"]]; listArguments[["xsetRdataOutput"]]=NULL 76 xsetRdataOutput = listArguments[["xsetRdataOutput"]]; listArguments[["xsetRdataOutput"]]=NULL
77 } 77 }
78 78
79 rplotspdf = "Rplots.pdf" 79 rplotspdf = "Rplots.pdf"
80 if (!is.null(listArguments[["rplotspdf"]])){ 80 if (!is.null(listArguments[["rplotspdf"]])){
81 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL 81 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL
82 } 82 }
83 83
84 dataMatrixOutput = "dataMatrix.tsv" 84 dataMatrixOutput = "dataMatrix.tsv"
85 if (!is.null(listArguments[["dataMatrixOutput"]])){ 85 if (!is.null(listArguments[["dataMatrixOutput"]])){
86 dataMatrixOutput = listArguments[["dataMatrixOutput"]]; listArguments[["dataMatrixOutput"]]=NULL 86 dataMatrixOutput = listArguments[["dataMatrixOutput"]]; listArguments[["dataMatrixOutput"]]=NULL
87 } 87 }
88 88
89 variableMetadataOutput = "variableMetadata.tsv" 89 variableMetadataOutput = "variableMetadata.tsv"
90 if (!is.null(listArguments[["variableMetadataOutput"]])){ 90 if (!is.null(listArguments[["variableMetadataOutput"]])){
91 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL 91 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL
92 }
93
94 if (!is.null(listArguments[["new_file_path"]])){
95 new_file_path = listArguments[["new_file_path"]]; listArguments[["new_file_path"]]=NULL
96 } 92 }
97 93
98 #Import the different functions 94 #Import the different functions
99 source_local("lib.r") 95 source_local("lib.r")
100 96
101 #necessary to unzip .zip file uploaded to Galaxy
102 #thanks to .zip file it's possible to upload many file as the same time conserving the tree hierarchy of directories
103
104
105 if (!is.null(listArguments[["zipfile"]])){
106 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
107 }
108
109 # We unzip automatically the chromatograms from the zip files. 97 # We unzip automatically the chromatograms from the zip files.
110 if (thefunction %in% c("annotatediff")) { 98 if (thefunction %in% c("annotatediff")) {
111 if(exists("zipfile") && (zipfile!="")) { 99 if (!exists("zipfile")) zipfile=NULL
112 if(!file.exists(zipfile)){ 100 if (!exists("singlefile")) singlefile=NULL
113 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!") 101 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
114 print(error_message) 102 zipfile = rawFilePath$zipfile
115 stop(error_message) 103 singlefile = rawFilePath$singlefile
116 } 104 listArguments = rawFilePath$listArguments
117 105 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
118 #unzip
119 suppressWarnings(unzip(zipfile, unzip="unzip"))
120
121 #get the directory name
122 filesInZip=unzip(zipfile, list=T);
123 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
124 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
125 directory = "."
126 if (length(directories) == 1) directory = directories
127
128 cat("files_root_directory\t",directory,"\n")
129 }
130 } 106 }
131
132 107
133 108
134 #addition of xset object to the list of arguments in the first position 109 #addition of xset object to the list of arguments in the first position
135 if (exists("xset") != 0){ 110 if (exists("xset") != 0){
136 listArguments=append(list(xset), listArguments) 111 listArguments=append(list(xset), listArguments)
137 } 112 }
138 113
139 cat("\n\n") 114 cat("\n\n")
140 115
141 116
147 #change the default display settings 122 #change the default display settings
148 pdf(file=rplotspdf, width=16, height=12) 123 pdf(file=rplotspdf, width=16, height=12)
149 124
150 125
151 if (thefunction %in% c("annotatediff")) { 126 if (thefunction %in% c("annotatediff")) {
152 results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput,dataMatrixOutput=dataMatrixOutput,new_file_path=new_file_path) 127 results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput,dataMatrixOutput=dataMatrixOutput)
153 xa=results_list[["xa"]] 128 xa=results_list[["xa"]]
154 diffrep=results_list[["diffrep"]] 129 diffrep=results_list[["diffrep"]]
155 variableMetadata=results_list[["variableMetadata"]] 130 variableMetadata=results_list[["variableMetadata"]]
156 131
157 cat("\n\n") 132 cat("\n\n")
158 cat("\tXSET OBJECT INFO\n") 133 cat("\tXSET OBJECT INFO\n")
159 print(xa) 134 print(xa)
160 } 135 }
161 136
162 if (thefunction %in% c("combinexsAnnos")) { 137 if (thefunction %in% c("combinexsAnnos")) {
163 cAnnot=combinexsAnnos_function(xaP=xaP,xaN=xaN,listOFlistArgumentsP=listOFlistArgumentsP,listOFlistArgumentsN=listOFlistArgumentsN,diffrepP=diffrepP,diffrepN=diffrepN,convert_param=listArguments[["convert_param"]],pos=listArguments[["pos"]],tol=listArguments[["tol"]],ruleset=listArguments[["ruleset"]],keep_meta=listArguments[["keep_meta"]],variableMetadataOutput=variableMetadataOutput) 138 cAnnot=combinexsAnnos_function(
139 xaP=xaP,xaN=xaN,
140 listOFlistArgumentsP=listOFlistArgumentsP,listOFlistArgumentsN=listOFlistArgumentsN,
141 diffrepP=diffrepP,diffrepN=diffrepN,
142 pos=listArguments[["pos"]],tol=listArguments[["tol"]],ruleset=listArguments[["ruleset"]],keep_meta=listArguments[["keep_meta"]],
143 convertRTMinute=listArguments[["convertRTMinute"]], numDigitsMZ=listArguments[["numDigitsMZ"]], numDigitsRT=listArguments[["numDigitsRT"]],
144 variableMetadataOutput=variableMetadataOutput
145 )
164 } 146 }
165 147
166 dev.off() 148 dev.off()
167 149
168 150
169 #saving R data in .Rdata file to save the variables used in the present tool 151 #saving R data in .Rdata file to save the variables used in the present tool
170 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFlistArguments","zipfile") 152 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFlistArguments","zipfile","singlefile")
171 save(list=objects2save[objects2save %in% ls()], file=xsetRdataOutput) 153 save(list=objects2save[objects2save %in% ls()], file=xsetRdataOutput)
172 154
173 cat("\n\n") 155 cat("\n\n")
174 156
175 cat("\tDONE\n") 157 cat("\tDONE\n")