annotate xcms_summary.r @ 2:234df22cd722 draft

planemo upload
author lecorguille
date Wed, 24 Feb 2016 12:30:37 -0500
parents 457a68338c2f
children f5d7654148bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
930478b22633 planemo upload
lecorguille
parents:
diff changeset
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
930478b22633 planemo upload
lecorguille
parents:
diff changeset
2 # version="0.1.0"
930478b22633 planemo upload
lecorguille
parents:
diff changeset
3 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr ABIMS TEAM
930478b22633 planemo upload
lecorguille
parents:
diff changeset
4
930478b22633 planemo upload
lecorguille
parents:
diff changeset
5
930478b22633 planemo upload
lecorguille
parents:
diff changeset
6
930478b22633 planemo upload
lecorguille
parents:
diff changeset
7 # ----- ARGUMENTS BLACKLIST -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
8 #xcms.r
930478b22633 planemo upload
lecorguille
parents:
diff changeset
9 argBlacklist=c("zipfile","xfunction","xsetRdataOutput","sampleMetadataOutput","ticspdf","bicspdf","rplotspdf")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
10 #CAMERA.r
930478b22633 planemo upload
lecorguille
parents:
diff changeset
11 argBlacklist=c(argBlacklist,"dataMatrixOutput","variableMetadataOutput","new_file_path")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
12
930478b22633 planemo upload
lecorguille
parents:
diff changeset
13 # ----- PACKAGE -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
14
930478b22633 planemo upload
lecorguille
parents:
diff changeset
15 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "tcltk","igraph", "xcms","snow","CAMERA","multtest","batch")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
16 for(pkg in pkgs) {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
17 suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
930478b22633 planemo upload
lecorguille
parents:
diff changeset
18 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
19
930478b22633 planemo upload
lecorguille
parents:
diff changeset
20
930478b22633 planemo upload
lecorguille
parents:
diff changeset
21 # ----- FUNCTION -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
22 writehtml = function(...) { cat(...,"\n", file=htmlOutput,append = TRUE,sep="") }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
23
930478b22633 planemo upload
lecorguille
parents:
diff changeset
24
930478b22633 planemo upload
lecorguille
parents:
diff changeset
25 # ----- ARGUMENTS -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
26
930478b22633 planemo upload
lecorguille
parents:
diff changeset
27 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
930478b22633 planemo upload
lecorguille
parents:
diff changeset
28
930478b22633 planemo upload
lecorguille
parents:
diff changeset
29
930478b22633 planemo upload
lecorguille
parents:
diff changeset
30 # ----- ARGUMENTS PROCESSING -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
31
930478b22633 planemo upload
lecorguille
parents:
diff changeset
32 #image is an .RData file necessary to use xset variable given by previous tools
930478b22633 planemo upload
lecorguille
parents:
diff changeset
33 load(listArguments[["image"]]);
930478b22633 planemo upload
lecorguille
parents:
diff changeset
34
930478b22633 planemo upload
lecorguille
parents:
diff changeset
35 htmlOutput = "summary.html"
930478b22633 planemo upload
lecorguille
parents:
diff changeset
36 if (!is.null(listArguments[["htmlOutput"]])) htmlOutput = listArguments[["htmlOutput"]];
930478b22633 planemo upload
lecorguille
parents:
diff changeset
37
930478b22633 planemo upload
lecorguille
parents:
diff changeset
38 user_email = NULL
930478b22633 planemo upload
lecorguille
parents:
diff changeset
39 if (!is.null(listArguments[["user_email"]])) user_email = listArguments[["user_email"]];
930478b22633 planemo upload
lecorguille
parents:
diff changeset
40
930478b22633 planemo upload
lecorguille
parents:
diff changeset
41 # if the RData come from CAMERA
930478b22633 planemo upload
lecorguille
parents:
diff changeset
42 if (!exists("xset") & exists("xa")) xset=xa@xcmsSet
930478b22633 planemo upload
lecorguille
parents:
diff changeset
43
930478b22633 planemo upload
lecorguille
parents:
diff changeset
44 # retrocompatability
1
457a68338c2f planemo upload
lecorguille
parents: 0
diff changeset
45 if (!exists("sampleNamesList")) sampleNamesList=list("sampleNamesMakeNames"=make.names(sampnames(xset)))
0
930478b22633 planemo upload
lecorguille
parents:
diff changeset
46
930478b22633 planemo upload
lecorguille
parents:
diff changeset
47 if (!exists("xset")) stop("You need at least a xset or a xa object.")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
48
930478b22633 planemo upload
lecorguille
parents:
diff changeset
49
930478b22633 planemo upload
lecorguille
parents:
diff changeset
50
930478b22633 planemo upload
lecorguille
parents:
diff changeset
51 # ----- MAIN PROCESSING INFO -----
930478b22633 planemo upload
lecorguille
parents:
diff changeset
52 writehtml("<!DOCTYPE html>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
53 writehtml("<HTML lang='en'>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
54
930478b22633 planemo upload
lecorguille
parents:
diff changeset
55 writehtml("<HEAD>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
56 writehtml("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
57
930478b22633 planemo upload
lecorguille
parents:
diff changeset
58 writehtml("<title>[W4M] XCMS analysis summary</title>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
59
930478b22633 planemo upload
lecorguille
parents:
diff changeset
60 writehtml("<style>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
61 writehtml("table, tr, td, th { border: 1px solid #000000; border-collapse:collapse; }")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
62 writehtml("td,th { padding: 5px; padding-right: 12px; }")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
63 writehtml("th { background: #898989; text-align:left;color: white;}")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
64 writehtml("h2 { color: #FFA212; }")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
65 writehtml("ul li { margin-bottom:10px; }")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
66 writehtml("</style>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
67 writehtml("</HEAD>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
68
930478b22633 planemo upload
lecorguille
parents:
diff changeset
69 writehtml("<BODY>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
70 writehtml("<div><h1>___ XCMS analysis summary using Workflow4Metabolomics ___</h1>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
71 # to pass the planemo shed_test
930478b22633 planemo upload
lecorguille
parents:
diff changeset
72 if (user_email != "test@bx.psu.edu") {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
73 if (!is.null(user_email)) writehtml("By: ",user_email," - ")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
74 writehtml("Date: ",format(Sys.time(), "%y%m%d-%H:%M:%S"))
930478b22633 planemo upload
lecorguille
parents:
diff changeset
75 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
76 writehtml("</div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
77
930478b22633 planemo upload
lecorguille
parents:
diff changeset
78 writehtml("<h2>Samples used:</h2>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
79 writehtml("<div><table>")
2
234df22cd722 planemo upload
lecorguille
parents: 1
diff changeset
80 if (all(sampnames(xset) == sampleNamesList$sampleNamesMakeNames)) {
0
930478b22633 planemo upload
lecorguille
parents:
diff changeset
81 sampleNameHeaderHtml = paste("<th>sample</th>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
82 sampleNameHtml = paste("<td>",sampnames(xset),"</td>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
83 } else {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
84 sampleNameHeaderHtml = paste("<th>sample</th><th>sample renamed</th>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
85 sampleNameHtml = paste("<td>",sampnames(xset),"</td><td>",sampleNamesList$sampleNamesMakeNames,"</td>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
86 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
87
930478b22633 planemo upload
lecorguille
parents:
diff changeset
88 if (!exists("md5sumList")) {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
89 md5sumHeaderHtml = ""
930478b22633 planemo upload
lecorguille
parents:
diff changeset
90 md5sumHtml = ""
930478b22633 planemo upload
lecorguille
parents:
diff changeset
91 md5sumLegend=""
2
234df22cd722 planemo upload
lecorguille
parents: 1
diff changeset
92 } else if (is.null(md5sumList$removalBadCharacters)) {
0
930478b22633 planemo upload
lecorguille
parents:
diff changeset
93 md5sumHeaderHtml = paste("<th>md5sum<sup>*</sup></th>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
94 md5sumHtml = paste("<td>",md5sumList$origin,"</td>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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."
930478b22633 planemo upload
lecorguille
parents:
diff changeset
96 } else {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
97 md5sumHeaderHtml = paste("<th>md5sum<sup>*</sup></th><th>md5sum<sup>**</sup> after bad characters removal</th>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
98 md5sumHtml = paste("<td>",md5sumList$origin,"</td><td>",md5sumList$origin,"</td>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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/>"
930478b22633 planemo upload
lecorguille
parents:
diff changeset
100 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
101
930478b22633 planemo upload
lecorguille
parents:
diff changeset
102 writehtml("<tr>",sampleNameHeaderHtml,"<th>filename</th>",md5sumHeaderHtml,"</tr>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
103 writehtml(paste("<tr>",sampleNameHtml,"<td>",xset@filepaths,"</td>",md5sumHtml,"</tr>"))
930478b22633 planemo upload
lecorguille
parents:
diff changeset
104
930478b22633 planemo upload
lecorguille
parents:
diff changeset
105 writehtml("</table>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
106 writehtml(md5sumLegend)
930478b22633 planemo upload
lecorguille
parents:
diff changeset
107 writehtml("</div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
108
930478b22633 planemo upload
lecorguille
parents:
diff changeset
109 writehtml("<h2>Function launched:</h2>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
110 writehtml("<div><table>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
111 writehtml("<tr><th>timestamp<sup>***</sup></th><th>function</th><th>argument</th><th>value</th></tr>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
112 for(tool in names(listOFlistArguments)) {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
113 listOFlistArgumentsDisplay=listOFlistArguments[[tool]][!(names(listOFlistArguments[[tool]]) %in% argBlacklist)]
930478b22633 planemo upload
lecorguille
parents:
diff changeset
114
930478b22633 planemo upload
lecorguille
parents:
diff changeset
115 timestamp = strsplit(tool,"_")[[1]][1]
930478b22633 planemo upload
lecorguille
parents:
diff changeset
116 xcmsFunction = strsplit(tool,"_")[[1]][2]
930478b22633 planemo upload
lecorguille
parents:
diff changeset
117 writehtml("<tr><td rowspan='",length(listOFlistArgumentsDisplay),"'>",timestamp,"</td><td rowspan='",length(listOFlistArgumentsDisplay),"'>",xcmsFunction,"</td>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
118 line_begin=""
930478b22633 planemo upload
lecorguille
parents:
diff changeset
119 for (arg in names(listOFlistArgumentsDisplay)) {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
120 writehtml(line_begin,"<td>",arg,"</td><td>",unlist(listOFlistArgumentsDisplay[arg][1]),"</td></tr>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
121 line_begin="<tr>"
930478b22633 planemo upload
lecorguille
parents:
diff changeset
122 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
123 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
124 writehtml("</table>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
125 writehtml("<br/><sup>***</sup>timestamp format: yymmdd-hh:mm:ss")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
126 writehtml("</div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
127
930478b22633 planemo upload
lecorguille
parents:
diff changeset
128 writehtml("<h2>Informations about the xcmsSet object:</h2>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
129
930478b22633 planemo upload
lecorguille
parents:
diff changeset
130 writehtml("<div><pre>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
131 log_file=file(htmlOutput, open = "at")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
132 sink(log_file)
930478b22633 planemo upload
lecorguille
parents:
diff changeset
133 sink(log_file, type = "output")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
134 xset
930478b22633 planemo upload
lecorguille
parents:
diff changeset
135 sink()
930478b22633 planemo upload
lecorguille
parents:
diff changeset
136 writehtml("</pre></div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
137
930478b22633 planemo upload
lecorguille
parents:
diff changeset
138 if (exists("xa")) {
930478b22633 planemo upload
lecorguille
parents:
diff changeset
139 writehtml("<h2>Informations about the CAMERA object:</h2>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
140
930478b22633 planemo upload
lecorguille
parents:
diff changeset
141 writehtml("<div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
142 writehtml("Number of pcgroup:",length(xa@pspectra))
930478b22633 planemo upload
lecorguille
parents:
diff changeset
143 writehtml("</div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
144 }
930478b22633 planemo upload
lecorguille
parents:
diff changeset
145
930478b22633 planemo upload
lecorguille
parents:
diff changeset
146 writehtml("<h2>Citations:</h2>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
147 writehtml("<div><ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
148 writehtml("<li>To cite the <b>XCMS</b> package in publications use:")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
149 writehtml("<ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
151 writehtml("<li>","Ralf Tautenhahn, Christoph Boettcher, Steffen Neumann: Highly sensitive feature detection for high resolution LC/MS BMC Bioinformatics, 9:504 (2008)","</li>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
153 writehtml("</ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
154 writehtml("</li>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
155
930478b22633 planemo upload
lecorguille
parents:
diff changeset
156 writehtml("<li>To cite the <b>CAMERA</b> package in publications use:")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
157 writehtml("<ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
159 writehtml("</ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
160 writehtml("</li>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
161
930478b22633 planemo upload
lecorguille
parents:
diff changeset
162 writehtml("<li>To cite the <b>Workflow4Metabolimics (W4M)</b> project in publications use:")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
163 writehtml("<ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
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>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
165 writehtml("</ul>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
166 writehtml("</li>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
167 writehtml("</ul></div>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
168
930478b22633 planemo upload
lecorguille
parents:
diff changeset
169 writehtml("</BODY>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
170
930478b22633 planemo upload
lecorguille
parents:
diff changeset
171 writehtml("</HTML>")
930478b22633 planemo upload
lecorguille
parents:
diff changeset
172