annotate xcms_summary.r @ 7:ed8d80fc927c draft

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