comparison galaxy/wrappers/VolcanoPlotTool.xml @ 0:c9a38c1eadf1 draft

"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
author vandelj
date Fri, 26 Jun 2020 09:45:41 -0400
parents
children 75505421bcf3
comparison
equal deleted inserted replaced
-1:000000000000 0:c9a38c1eadf1
1 <tool name="GIANT-Plot volcanos" id="giant_volcano_plot" version="0.3.3">
2 <description>Plot volcano from tabular file</description>
3 <requirements>
4 <requirement type="package" version="1.7.1">r-r.methodss3</requirement>
5 <requirement type="package" version="2.36.1">bioconductor-biomart</requirement>
6 <requirement type="package" version="3.0.0">r-ggplot2</requirement>
7 <requirement type="package" version="4.8.0">r-plotly</requirement>
8 <requirement type="package" version="1.3.1">r-stringr</requirement>
9 </requirements>
10 <code file="../../src/General_functions.py"/>
11 <stdio>
12 <regex match="Execution halted"
13 source="both"
14 level="fatal"
15 description="Execution halted, please contact tool developer or administrators." />
16 <regex match="Error in"
17 source="both"
18 level="fatal"
19 description="An error occured during R execution, please contact tool developer." />
20 <exit_code range="15" level="fatal" description="Error during input file formatting step, see log file for more information." />
21 <exit_code range="10" level="fatal" description="Missing file during html report, see log file for more information." />
22 <exit_code range="1:9" level="fatal" description="Error in R execution, see log file for more information." />
23 </stdio>
24 <command> <![CDATA[
25 #import imp
26 #set $runIdentifier=str($outputData).rsplit("/")[-1].rsplit(".")[0]
27 #set $general_functions=$imp.load_source('General_functions', $__tool_directory__+'/../../src/General_functions.py')
28 #set $ret_code=$general_functions.selectSubSetTable($inputSection['inputData'].file_name,$inputSection['headerNumber'].value,[0],$volcanoSection['volcanoList'],$__new_file_path__+'/'+$__user_id__+'_'+$runIdentifier+'_statisticsFormated.csv',$log.file_name)
29
30 if [ $ret_code != 0 ]; then
31 printf "[ERROR]Error during formated statistics file generation\n" >> $log;
32 exit $ret_code;
33 fi;
34
35 mv ${__new_file_path__}/${__user_id__}_${runIdentifier}_statisticsFormated.csv ./statisticsFormated.csv;
36
37 #for $i, $s in enumerate( $volcanoSection.volcanoList )
38 #if $s.volcanoName!='':
39 printf "\$(($i+1))\t${s.volcanoName}\n" >> ./correspondanceVolcanoNames.csv;
40 #else:
41 printf "\$(($i+1))\t\$(($i+1))_${s.pvalColumn}\n" >> ./correspondanceVolcanoNames.csv;
42 #end if
43 #end for
44
45
46 Rscript '$__tool_directory__/../../src/VolcanoPlotsScript.R' -i 'statisticsFormated.csv' -l '$log' -o '$outputData' -f 'pdf'
47 #for $i, $s in enumerate( $volcanoSection.volcanoList )
48 -n '${s.volcanoName}'
49 -p '${s.pvalColumn}'
50 -c '${s.fcColumn}'
51 -m '${s.fdrColumn}'
52 #end for
53 -d '$plotSection.fcKind'
54 -s $plotSection.FDRthreshold
55 -e $plotSection.FCthreshold
56 #if $plotSection.geneInformation.addGeneInfo:
57 -x '$plotSection.geneInformation.organismID'
58 -y '$plotSection.geneInformation.infoInRowType'
59 #end if
60 ;
61 ret_code=\$?;
62 if [ \$ret_code != 0 ]; then
63 exit \$ret_code;
64 else
65 bash $scriptTransfer;
66 ret_code=\$?;
67 if [ \$ret_code != 0 ]; then
68 exit \$ret_code;
69 fi
70 fi;
71
72 printf "[INFO]End of tool script" >> $log;
73 ]]>
74 </command>
75
76
77 <configfiles>
78 <configfile name="scriptTableToHtml">
79 <![CDATA[
80 printf "<!DOCTYPE html>
81 <html>
82 <head>
83 <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">
84 <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css\">
85 <script type=\"text/javascript\" language=\"javascript\" src=\"https://code.jquery.com/jquery-1.12.4.js\">
86 </script>
87 <script type=\"text/javascript\" language=\"javascript\" src=\"https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js\">
88 </script>
89 <script type=\"text/javascript\" class=\"init\">
90 \\$(document).ready(function() {
91 \\$(\'\#example\').DataTable( {
92 \"columnDefs\": [ {
93 \"visible\": false,
94 \"targets\": -1
95 } ]
96 } );
97 } );
98 </script>
99 </head>
100 <body style=\"background-color:white;\">
101 <table id=\"example\" class=\"display\" cellspacing=\"0\">
102 " > ${html_file.extra_files_path}/output.html
103
104 printf "<colgroup>\n" >> ${html_file.extra_files_path}/output.html
105 printf "<col span=\"2\" style=\"background-color:rgb(224,235,235)\">\n" >> ${html_file.extra_files_path}/output.html
106 awk 'BEGIN{odd=1;FS="\t"} NR==1{for(i=3;i<=NF;i=i+4){if(odd==1){odd=0;printf "<col span=\"4\" style=\"background-color:rgb(224,238,255)\">\n"}else{odd=1;printf "<col span=\"4\" style=\"background-color:rgb(255,221,224)\">\n"}}}' $outputData >> ${html_file.extra_files_path}/output.html
107 printf "</colgroup>\n" >> ${html_file.extra_files_path}/output.html
108
109
110 printf "<thead>\n<tr>\n" >> ${html_file.extra_files_path}/output.html
111 printf "<th rowspan=\"2\">Gene</th>\n" >> ${html_file.extra_files_path}/output.html
112 printf "<th rowspan=\"2\">Info</th>\n" >> ${html_file.extra_files_path}/output.html
113 awk 'BEGIN{FS="\t"} NR==1{for(i=3;i<=NF;i=i+4)printf "<th colspan=\"4\">"\$i"</th>\n"}' $outputData >> ${html_file.extra_files_path}/output.html
114 printf "<th></th>\n" >> ${html_file.extra_files_path}/output.html
115 printf "</tr>\n<tr>\n" >> ${html_file.extra_files_path}/output.html
116 awk 'BEGIN{FS="\t"} NR==2{for(i=3;i<=NF;i++)printf "<th>"\$i"</th>\n"}' $outputData >> ${html_file.extra_files_path}/output.html
117 printf "<th></th>\n" >> ${html_file.extra_files_path}/output.html
118 printf "</tr>\n</thead>\n" >> ${html_file.extra_files_path}/output.html
119
120 printf "<tfoot>\n<tr>\n" >> ${html_file.extra_files_path}/output.html
121 awk 'BEGIN{FS="\t"} NR==2{for(i=1;i<=NF;i++)printf "<th>"\$i"</th>\n"}' $outputData >> ${html_file.extra_files_path}/output.html
122 printf "<th></th>\n" >> ${html_file.extra_files_path}/output.html
123 printf "</tr>\n</tfoot>\n">> ${html_file.extra_files_path}/output.html
124
125 printf "<tbody>\n" >> ${html_file.extra_files_path}/output.html
126 awk 'BEGIN{FS="\t"} NR>2{printf "<tr>\n";for(i=1;i<=NF;i++){printf "<th>"\$i"</th>\n"};printf "<th></th>\n";printf "</tr>\n"}' $outputData >> ${html_file.extra_files_path}/output.html
127 printf "</tbody>\n" >> ${html_file.extra_files_path}/output.html
128
129 printf "</table>
130 </body>
131 </html>" >> ${html_file.extra_files_path}/output.html
132
133 ]]>
134 </configfile>
135
136 <configfile name="scriptTransfer">
137 <![CDATA[
138
139
140 ##for output table
141
142 mkdir -p $html_file.extra_files_path
143
144 ##create HTML file for limma output table
145 source $scriptTableToHtml
146
147 ##check output.html is here
148 if ! [ -e ${html_file.extra_files_path}/output.html ]; then
149 printf "[ERROR]output.html is missing" >> $log;
150 exit 10
151 fi
152
153 ##create header of main HTML file
154 printf "<!DOCTYPE html>\n<html>\n<body>" > $html_file
155
156 ##first add reference of the output table
157 printf "<h3>Statistics (p.val, adjusted p.val, FC, log2FC)</h3>\n" >> $html_file
158 printf "<a href=\"output.html\">Access to statistics</a>\n" >> $html_file
159
160
161
162 printf "<h3>Volcanos</h3>\n" >> $html_file
163
164 ##create folders in media
165 counter=1
166 for volcano in \$(ls ./plotLyDir/Volcanos_*html)
167 do
168 volcanoShort=\${volcano%\.*}
169 volcanoShort=\${volcanoShort\#\#*/}
170
171 conditionName=\${volcano%\.*}
172 conditionName=\${conditionName\#\#*Volcanos_}
173
174 ##modify HTML to point to plotLy folder
175 sed -i "s/\${volcanoShort}_files/PlotLy_Volcano_scripts/g" \$volcano
176
177 ##copy HTML files in both folders
178 cp \$volcano ${html_file.extra_files_path}/Volcano_\$conditionName.html
179
180 ##get user name of Volcano
181 echo \$conditionName > ./temporaryConditionName
182 conditionFormatedName=\$(awk 'BEGIN{FS="\t"} ARGIND==1{dico[\$1]=\$2} ARGIND==2{print dico[\$1]}' ./correspondanceVolcanoNames.csv ./temporaryConditionName)
183
184 ##add HTML link
185 printf "<p>\n<a href=\"Volcano_\$conditionName.html\">Volcano \$conditionFormatedName</a>\n</p>\n" >> $html_file
186
187 if [ \$counter = 1 ]; then
188
189 #if $plotSection.imagePlotlyFormat=="svg":
190 ##before copying scripts folder modify them to replace png snapshot with svg (not proud of solution but seems to work)
191 cd ./plotLyDir/\${volcanoShort}_files/plotly-main-*/
192 awk '{gsub("\"png\"","\"svg\"",\$0);print \$0}' ./plotly-latest.min.js > ./plotly-latest.minTemp.js
193 awk '{gsub("Download plot as a png","Download plot as a svg",\$0);print \$0}' ./plotly-latest.minTemp.js > ./plotly-latest.min.js
194 rm ./plotly-latest.minTemp.js
195 cd ../../../
196 #end if
197
198 ##now copy only scripts folder for the first volcano and rename
199 cp -r ./plotLyDir/\${volcanoShort}_files $html_file.extra_files_path
200 mv ${html_file.extra_files_path}/\${volcanoShort}_files ${html_file.extra_files_path}/PlotLy_Volcano_scripts
201 fi
202
203 ((counter++))
204 done
205
206 if [ \$counter = 1 ]; then
207 printf "[ERROR]Volcano plots are missing" >> $log;
208 exit 10
209 fi
210
211
212
213 ##create footer of HTML file
214 printf "</body>\n</html>" >> $html_file
215 ]]>
216 </configfile>
217 </configfiles>
218
219
220
221 <inputs>
222 <section name="inputSection" title="Input files" expanded="True">
223 <param type="text" name="title" value="Volcano_toPersonalize" label="Title for output"/>
224
225 <param type="data" name="inputData" format="tabular" label="Differential results file" optional="false" multiple="false" refresh_on_change="true"/>
226
227 <param name="headerNumber" type="select" label="Select number of header lines in file" refresh_on_change="true">
228 <option value="0">0</option>
229 <option value="1">1</option>
230 <option value="2" selected="true">2</option>
231 <option value="3">3</option>
232 <option value="4">4</option>
233 <option value="5">5</option>
234 </param>
235 </section>
236
237 <section name="volcanoSection" title="Volcano definition" expanded="True">
238
239
240 <repeat name="volcanoList" title="Volcano">
241
242 <param type="text" name="volcanoName" value="" label="Volcano name"/>
243
244 <param name="pvalColumn" type="select" label="Select column containing p-val statistics" refresh_on_change="true" optional="false" multiple="false" dynamic_options="get_column_names_mergeNumber(inputSection['inputData'].file_name,inputSection['headerNumber'],[0])" help="Do not select ajusted p-val here"/>
245
246 <param name="fdrColumn" type="select" label="Select column containing adjusted p-val statistics (if available)" refresh_on_change="true" optional="true" multiple="false" dynamic_options="get_column_names_mergeNumber(inputSection['inputData'].file_name,inputSection['headerNumber'],[0])" help="If adjusted p-val are available, otherwise it will be computed from p-values."/>
247
248 <param name="fcColumn" type="select" label="Select column containing log2(FoldChange) values" refresh_on_change="true" optional="false" multiple="false" dynamic_options="get_column_names_mergeNumber(inputSection['inputData'].file_name,inputSection['headerNumber'],[0])" help="If only FC are available as input, please select FC column and check options below." />
249
250 </repeat>
251
252 </section>
253
254
255 <section name="plotSection" title="Output section" expanded="True">
256
257 <param name="fcKind" type="select" display="radio" label="Select FC values kind selected as input column" help="Info:log2(FC) will be displayed in volcano plots">
258 <option value="log2FC" selected="true">log2(FC)</option>
259 <option value="FC">FC</option>
260 </param>
261
262 <param name="FDRthreshold" type="float" value="0.05" label="Output adjusted p-val threshold" >
263 <validator type="in_range" min="0" max="1" message="Threshold should be between 0 and 1"/>
264 </param>
265
266 <param name="FCthreshold" type="float" value="2" label="Output Fold Change threshold (both 'log2(threshold)' and 'log2(1/threshold)' values will be used)" >
267 <validator type="in_range" min="1" exclude_min="false" message="Threshold should be greater or equal to 1"/>
268 </param>
269
270 <conditional name="geneInformation">
271 <param name="addGeneInfo" type="boolean" label="Add gene/probe information" checked="false"/>
272 <when value="true">
273 <param name="organismID" label="Organism" type="select">
274 <options from_data_table="LimmaTool" >
275 <column name="name" index="1"/>
276 <column name="value" index="0"/>
277 <filter type="unique_value" column="0"/>
278 </options>
279 </param>
280 <param name="infoInRowType" label="Nature of row names" type="select">
281 <options from_data_table="LimmaTool" >
282 <column name="name" index="3"/>
283 <column name="value" index="2"/>
284 <filter type="param_value" ref="organismID" column="0"/>
285 </options>
286 </param>
287 </when>
288 <when value="false">
289 </when>
290 </conditional>
291
292 <param type="select" name="imagePlotlyFormat" display="radio" label="Html snapshot format">
293 <option value="png">PNG format</option>
294 <option value="svg">SVG format</option>
295 </param>
296 </section>
297
298 </inputs>
299
300
301
302 <outputs>
303 <data format="tabular" name="outputData" label="${inputSection.title}_statistics"/>
304
305 <data format="html" name="html_file" label="${inputSection.title}_HTML.html"/>
306 <!--
307 <collection name="outputHistogramsList" label="${inputSection.title}_HistogramsList" type="list">
308 <discover_datasets pattern="(?P&lt;designation&gt;Histograms[0-9]+)\.(?P&lt;ext&gt;[^\._]+)?" directory="plotDir" visible="false"/>
309 <filter>plotSection['histogramToPlot']</filter>
310 </collection>
311
312 <collection name="outputVolcanosList" label="${inputSection.title}_VolcanosList" type="list">
313 <discover_datasets pattern="(?P&lt;designation&gt;Volcanos\_.*)\.(?P&lt;ext&gt;[^\._]+)?" directory="plotDir" visible="false"/>
314 <filter>plotSection['volcanoToPlot']</filter>
315 </collection>
316
317 <data name="fRatioOutput" format="png" label="${inputSection.title}_F-ratio">
318 <change_format>
319 <when input="plotSection['imageFormat']" value="pdf" format="pdf" />
320 </change_format>
321 </data>
322 -->
323 <data format="txt" name="log" label="${inputSection.title}_Log" />
324 </outputs>
325
326
327
328 <tests>
329 <test maxseconds="3600">
330 <param name="wfile" value="wiggle.wig" />
331 <param name="bfile" value="bedfile.bed" />
332 <param name="span" value="3000" />
333 <param name="pfres" value="50" />
334 <param name="lowersize" value="1000" />
335 <param name="middlesize" value="2000" />
336 <param name="uppersize" value="3000" />
337 <param name="lowerbisize" value="2500" />
338 <param name="upperbisize" value="5000" />
339 <param name="reldist" value="3000" />
340 <param name="genome" value="hg18" />
341 <param name="imagetype" value="PDF" />
342 <param name="enable" value="no" />
343 <output name="outputData" file="ceas_1/ceas_1.pdf" />
344 </test>
345 </tests>
346 <help>
347 <![CDATA[
348 **What it does ?**
349
350 This tool plot volcanos from previous differential expression analysis results containing at least Fold Change and p-val statistics for all measured genes.
351
352 -----
353
354 **Parameters**
355
356 \- **Input files**
357
358 - **Title** to personalize output file names (avoiding special characters).
359
360 - **Differential expression analysis results** with at least contrast statistics (p-val and FC or log2(FC)) as columns and genes as rows. GIANT-Differential Expression Analysis with LIMMA tool output can be used as a model.
361
362 ::
363
364 LIMMA comparison WT*Treat WT*Treat WT*Treat WT*Treat WT*Treat
365 Gene Info p-val FDR.p-val FC log2(FC) t-stat
366 ARSD na 0.0057 0.41 0.8389 -0.2534 -5.175
367 TTTY10 na 1.6e-07 0.0074 0.6403 -0.6432 -6.122
368 MIR548AL na 0.072 0.2914 1.711 0.775 10.43
369
370 - **Header lines number** to skip in the differential results file, i.e lines containing column content descripion.
371
372
373 \- **Volcano definition** (add as many volcanos as needed)
374
375 - **Volcano name** for better ouput identification (avoiding special characters).
376
377 - **Select p-val statistics column** containing p-value statistics for all genes in the coresponding contrast, FDR correction will be automatically applied on these p-values if adjusted p-values column is not selected in the following option.
378
379 - **Select adjusted p-val column** (optional) if adjusted p-values have been allready computed and are available in the input file. If not, FDR correction will be applied on available p-value statistics.
380
381 - **Select log2(FoldChange) or FoldChange column** corresponding to the same contrast as previously selected (adjusted)p-value columns.
382
383
384 \- **Output section**
385
386 - **FC information available as input** : select if FoldChange columns selected during volcanos definition are allready log2 transformed.
387
388 - **Output adjusted/FDR p-val threshold** : only genes with adjusted p-val <= this threshold (in at least one of requested volcanos) will be in result tab.
389
390 - **Output Fold Change threshold** : only genes with absolute FC >= this threshold (in at least one of requested volcanos) will be in result tab (both 'log2(threshold)' and 'log2(1/threshold)' values will be used).
391
392 - **Add gene/probe information** : if yes, add description of genes to the result tab.
393
394 - **Html snapshot format** : format of plot images taken from interactive view
395
396 -----
397
398 **Outputs**
399
400 - **tabular file** containing statistics used for volcano plots, represented as a tab delimited matrix where each colum contains statistics for each gene (in rows).
401
402 - **HTML file** to access interactive version of volcanos through PlotLy html pages and tabulated volcano statistics.
403
404 - **LOG file** for job log. If you see errors, please attached this in the bug report
405
406 ]]> </help>
407
408
409 <citations>
410 <citation type="bibtex">@misc{vandel_jimmy_2018_1477870, author = {Vandel, J. and Gheeraert, C. and Eeckhoute, J. and Staels, B. and Lefebvre, P. and Dubois-Chevalier, J.}, title = {GIANT: Galaxy-based Interactive tools for ANalaysis of Transcriptomic data}, month = nov, year = 2018, doi = {10.5281/zenodo.1477870}, url = {https://doi.org/10.5281/zenodo.1477870}
411 }</citation>
412
413 <citation type="bibtex">@online{plotly, author = {Plotly Technologies Inc.}, title = {Collaborative data science}, publisher = {Plotly Technologies Inc.}, address = {Montreal, QC}, year = {2015}, url = {https://plot.ly}
414 }</citation>
415 </citations>
416
417 </tool>