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