comparison xcms_summary.r @ 0:930478b22633 draft

planemo upload
author lecorguille
date Mon, 22 Feb 2016 16:44:04 -0500
parents
children 457a68338c2f
comparison
equal deleted inserted replaced
-1:000000000000 0:930478b22633
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
2 # version="0.1.0"
3 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr ABIMS TEAM
4
5
6
7 # ----- ARGUMENTS BLACKLIST -----
8 #xcms.r
9 argBlacklist=c("zipfile","xfunction","xsetRdataOutput","sampleMetadataOutput","ticspdf","bicspdf","rplotspdf")
10 #CAMERA.r
11 argBlacklist=c(argBlacklist,"dataMatrixOutput","variableMetadataOutput","new_file_path")
12
13 # ----- PACKAGE -----
14
15 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "tcltk","igraph", "xcms","snow","CAMERA","multtest","batch")
16 for(pkg in pkgs) {
17 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
18 }
19
20
21 # ----- FUNCTION -----
22 writehtml = function(...) { cat(...,"\n", file=htmlOutput,append = TRUE,sep="") }
23
24
25 # ----- ARGUMENTS -----
26
27 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
28
29
30 # ----- ARGUMENTS PROCESSING -----
31
32 #image is an .RData file necessary to use xset variable given by previous tools
33 load(listArguments[["image"]]);
34
35 htmlOutput = "summary.html"
36 if (!is.null(listArguments[["htmlOutput"]])) htmlOutput = listArguments[["htmlOutput"]];
37
38 user_email = NULL
39 if (!is.null(listArguments[["user_email"]])) user_email = listArguments[["user_email"]];
40
41 # if the RData come from CAMERA
42 if (!exists("xset") & exists("xa")) xset=xa@xcmsSet
43
44 # retrocompatability
45 if (!exists("sampleNamesList")) sampleNamesList=List("sampleNamesMakeNames"=make.names(sampnames(xset)))
46
47 if (!exists("xset")) stop("You need at least a xset or a xa object.")
48
49
50
51 # ----- MAIN PROCESSING INFO -----
52 writehtml("<!DOCTYPE html>")
53 writehtml("<HTML lang='en'>")
54
55 writehtml("<HEAD>")
56 writehtml("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />")
57
58 writehtml("<title>[W4M] XCMS analysis summary</title>")
59
60 writehtml("<style>")
61 writehtml("table, tr, td, th { border: 1px solid #000000; border-collapse:collapse; }")
62 writehtml("td,th { padding: 5px; padding-right: 12px; }")
63 writehtml("th { background: #898989; text-align:left;color: white;}")
64 writehtml("h2 { color: #FFA212; }")
65 writehtml("ul li { margin-bottom:10px; }")
66 writehtml("</style>")
67 writehtml("</HEAD>")
68
69 writehtml("<BODY>")
70 writehtml("<div><h1>___ XCMS analysis summary using Workflow4Metabolomics ___</h1>")
71 # to pass the planemo shed_test
72 if (user_email != "test@bx.psu.edu") {
73 if (!is.null(user_email)) writehtml("By: ",user_email," - ")
74 writehtml("Date: ",format(Sys.time(), "%y%m%d-%H:%M:%S"))
75 }
76 writehtml("</div>")
77
78 writehtml("<h2>Samples used:</h2>")
79 writehtml("<div><table>")
80 if (all(sampnames(xset) != sampleNamesList$sampleNamesMakeNames)) {
81 sampleNameHeaderHtml = paste("<th>sample</th>")
82 sampleNameHtml = paste("<td>",sampnames(xset),"</td>")
83 } else {
84 sampleNameHeaderHtml = paste("<th>sample</th><th>sample renamed</th>")
85 sampleNameHtml = paste("<td>",sampnames(xset),"</td><td>",sampleNamesList$sampleNamesMakeNames,"</td>")
86 }
87
88 if (!exists("md5sumList")) {
89 md5sumHeaderHtml = ""
90 md5sumHtml = ""
91 md5sumLegend=""
92 } else if (!is.null(md5sumList$removalBadCharacters)) {
93 md5sumHeaderHtml = paste("<th>md5sum<sup>*</sup></th>")
94 md5sumHtml = paste("<td>",md5sumList$origin,"</td>")
95 md5sumLegend = "<br/><sup>*</sup>The program md5sum is designed to verify data integrity. So you can check if the data were uploaded correctly or if the data were chancged during the process."
96 } else {
97 md5sumHeaderHtml = paste("<th>md5sum<sup>*</sup></th><th>md5sum<sup>**</sup> after bad characters removal</th>")
98 md5sumHtml = paste("<td>",md5sumList$origin,"</td><td>",md5sumList$origin,"</td>")
99 md5sumLegend = "<br/><sup>*</sup>The program md5sum is designed to verify data integrity. So you can check if the data were uploaded correctly or if the data were chancged during the process.<br/><sup>**</sup>Because some bad characters (eg: accent) were removed from your original file, the checksum have changed too.<br/>"
100 }
101
102 writehtml("<tr>",sampleNameHeaderHtml,"<th>filename</th>",md5sumHeaderHtml,"</tr>")
103 writehtml(paste("<tr>",sampleNameHtml,"<td>",xset@filepaths,"</td>",md5sumHtml,"</tr>"))
104
105 writehtml("</table>")
106 writehtml(md5sumLegend)
107 writehtml("</div>")
108
109 writehtml("<h2>Function launched:</h2>")
110 writehtml("<div><table>")
111 writehtml("<tr><th>timestamp<sup>***</sup></th><th>function</th><th>argument</th><th>value</th></tr>")
112 for(tool in names(listOFlistArguments)) {
113 listOFlistArgumentsDisplay=listOFlistArguments[[tool]][!(names(listOFlistArguments[[tool]]) %in% argBlacklist)]
114
115 timestamp = strsplit(tool,"_")[[1]][1]
116 xcmsFunction = strsplit(tool,"_")[[1]][2]
117 writehtml("<tr><td rowspan='",length(listOFlistArgumentsDisplay),"'>",timestamp,"</td><td rowspan='",length(listOFlistArgumentsDisplay),"'>",xcmsFunction,"</td>")
118 line_begin=""
119 for (arg in names(listOFlistArgumentsDisplay)) {
120 writehtml(line_begin,"<td>",arg,"</td><td>",unlist(listOFlistArgumentsDisplay[arg][1]),"</td></tr>")
121 line_begin="<tr>"
122 }
123 }
124 writehtml("</table>")
125 writehtml("<br/><sup>***</sup>timestamp format: yymmdd-hh:mm:ss")
126 writehtml("</div>")
127
128 writehtml("<h2>Informations about the xcmsSet object:</h2>")
129
130 writehtml("<div><pre>")
131 log_file=file(htmlOutput, open = "at")
132 sink(log_file)
133 sink(log_file, type = "output")
134 xset
135 sink()
136 writehtml("</pre></div>")
137
138 if (exists("xa")) {
139 writehtml("<h2>Informations about the CAMERA object:</h2>")
140
141 writehtml("<div>")
142 writehtml("Number of pcgroup:",length(xa@pspectra))
143 writehtml("</div>")
144 }
145
146 writehtml("<h2>Citations:</h2>")
147 writehtml("<div><ul>")
148 writehtml("<li>To cite the <b>XCMS</b> package in publications use:")
149 writehtml("<ul>")
150 writehtml("<li>","Smith, C.A. and Want, E.J. and O'Maille, G. and Abagyan,R. and Siuzdak, G.XCMS: Processing mass spectrometry data for metabolite profiling using nonlinear peak alignment, matching and identification, Analytical Chemistry, 78:779-787 (2006)","</li>")
151 writehtml("<li>","Ralf Tautenhahn, Christoph Boettcher, Steffen Neumann: Highly sensitive feature detection for high resolution LC/MS BMC Bioinformatics, 9:504 (2008)","</li>")
152 writehtml("<li>","H. Paul Benton, Elizabeth J. Want and Timothy M. D. Ebbels Correction of mass calibration gaps in liquid chromatography-mass spectrometry metabolomics data Bioinformatics, 26:2488 (2010)","</li>")
153 writehtml("</ul>")
154 writehtml("</li>")
155
156 writehtml("<li>To cite the <b>CAMERA</b> package in publications use:")
157 writehtml("<ul>")
158 writehtml("<li>","Kuhl, C., Tautenhahn, R., Boettcher, C., Larson, T. R. and Neumann,S. CAMERA: an integrated strategy for compound spectra extraction and annotation of liquid chromatography/mass spectrometry data sets. Analytical Chemistry, 84:283-289 (2012)","</li>")
159 writehtml("</ul>")
160 writehtml("</li>")
161
162 writehtml("<li>To cite the <b>Workflow4Metabolimics (W4M)</b> project in publications use:")
163 writehtml("<ul>")
164 writehtml("<li>","Franck Giacomoni, Gildas Le Corguillé, Misharl Monsoor, Marion Landi, Pierre Pericard, Mélanie Pétéra, Christophe Duperier, Marie Tremblay-Franco, Jean-François Martin, Daniel Jacob, Sophie Goulitquer, Etienne A. Thévenot and Christophe Caron (2014). Workflow4Metabolomics: A collaborative research infrastructure for computational metabolomics. Bioinformatics doi:10.1093/bioinformatics/btu813","</li>")
165 writehtml("</ul>")
166 writehtml("</li>")
167 writehtml("</ul></div>")
168
169 writehtml("</BODY>")
170
171 writehtml("</HTML>")
172