comparison heatmap.xml @ 0:e53885a980fe draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ampvis2 commit 7c0ecbffdb5e993f5af7e3b52c424c2761fb91d3"
author iuc
date Mon, 04 Apr 2022 10:21:36 +0000
parents
children 1adde216bdce
comparison
equal deleted inserted replaced
-1:000000000000 0:e53885a980fe
1 <tool id="ampvis2_heatmap" name="ampvis2 heatmap" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT">
2 <description></description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="header"/>
7 <command detect_errors="exit_code"><![CDATA[
8 Rscript '$rscript'
9 ]]></command>
10 <configfiles>
11 <configfile name="rscript"><![CDATA[
12 #if $tax_add
13 #set ta='c("' + '", "'.join(str($tax_add).split(",")) + '")'
14 #else
15 #set ta='NULL'
16 #end if
17 library(ampvis2, quietly = TRUE)
18 d <- readRDS("$data")
19 #if $output_options.out_format == "tabular"
20 raw <-
21 #else
22 plot <-
23 #end if
24 amp_heatmap(
25 d
26 ,
27 #if $group_by
28 group_by = "$group_by",
29 #end if
30 #if $facet_by
31 facet_by = "$facet_by",
32 #end if
33 normalise = $normalise,
34 tax_aggregate = "$tax_aggregate",
35 tax_add = $ta,
36 @TAX_SHOW@
37 showRemainingTaxa = $showRemainingTaxa,
38 ## tax_class = NULL,
39 tax_empty = "$tax_empty",
40 ## TODO giving the order of the columns is difficult but "cluster" would be nice I guess
41 ## order_x_by = NULL,
42 ## order_y_by = NULL,
43 plot_values = $plot_values_cond.plot_values,
44 #if $plot_values_cond.plot_values == "TRUE"
45 plot_values_size = $plot_values_cond.plot_values_size,
46 #end if
47 ## plot_legendbreaks = NULL,
48 plot_colorscale = "$plot_colorscale",
49 plot_na = $plot_na,
50 measure = "$measure",
51 #if str($min_abundance) != ''
52 min_abundance = $min_abundance,
53 #end if
54 #if str($max_abundance) != ''
55 max_abundance = $max_abundance,
56 #end if
57 #if $sort_by_cond.sort_by_sel != 'no'
58 sort_by = "$sort_by_cond.sort_by",
59 #end if
60 ## TODO https://github.com/MadsAlbertsen/ampvis2/issues/130
61 ## #if $normalise_by_cond.normalise_by_sel != "no"
62 ## normalise_by = "$normalise_by_cond.normalise_by",
63 ## #end if
64 #if $scale_by
65 scale_by = "$scale_by",
66 #end if
67 ## color_vector = NULL
68 ## round = 1,
69 #if $output_options.out_format == "tabular"
70 textmap = TRUE,
71 #else
72 textmap = FALSE,
73 #end if
74 #if $plot_functions_cond.plot_functions_sel != "no"
75 plot_functions = TRUE,
76 #if $plot_functions_cond.plot_functions_sel == "file"
77 function_data = read.table("$plot_functions_cond.function_data", header = TRUE, sep = "\t"),
78 #end if
79 #set foo='c("' + '", "'.join(str($plot_functions_cond.functions).split(",")) + '")'
80 functions = $foo,
81 #end if
82 rel_widths = c(0.75, 0.25)
83 )
84 #if $output_options.out_format != "tabular"
85 @OUTPUT_TOKEN@
86 #else
87 write.table(raw, file = "$plot_raw", sep = "\t")
88 #end if
89 ]]></configfile>
90 </configfiles>
91 <inputs>
92 <expand macro="rds_metadata_input_macro"/>
93 <expand macro="metadata_select_discrete" argument="group_by" label="Group samples" help="By a categorical variable in the metadata"/>
94 <expand macro="metadata_select_discrete" argument="facet_by" label="Facet the samples" help="By a categorical variable in the metadata."/>
95 <expand macro="normalise_macro" checked="true"/>
96 <expand macro="taxlevel_macro" argument="tax_aggregate" label="The taxonomic level to aggregate the OTUs">
97 <option value="Phylum" selected="true">Phylum</option>
98 </expand>
99 <expand macro="taxlevel_macro" argument="tax_add" multiple="true" optional="true" label="Additional taxonomic level(s) to display"/>
100 <expand macro="tax_show_macro" value="10"/>
101 <param argument="showRemainingTaxa" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Display sum of remaining taxa" help="Add an additional row at the bottom displaying the sum of all remaining taxa that are not part of the top tax_show most abundant taxa."/>
102 <expand macro="tax_empty_macro"/>
103 <conditional name="plot_values_cond">
104 <param argument="plot_values" type="select" label="Plot the values on the heatmap">
105 <option value="TRUE">Yes</option>
106 <option value="FALSE">No</option>
107 </param>
108 <when value="TRUE">
109 <param name="plot_values_size" type="integer" value="4" label="Size of the plotted values"/>
110 </when>
111 <when value="FALSE"/>
112 </conditional>
113 <param argument="plot_colorscale" type="select" label="Type of scale used for coloring abundances">
114 <option value="sqrt">Square root (sqrt)</option>
115 <option value="log10" selected="true">Log (log10)</option>
116 </param>
117 <param argument="plot_na" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Color missing values with the lowest color in the scale"/>
118 <param argument="measure" type="select" label="Value to show across the groups">
119 <option value="mean">Mean</option>
120 <option value="max">Maximum</option>
121 <option value="median">Median</option>
122 </param>
123 <param argument="min_abundance" type="float" value="0.1" min="0" optional="true" label="Maximum abundance" help="All values below this value are given the same color."/>
124 <param argument="max_abundance" type="float" value="" min="0" optional="true" label="Maximum abundance" help="All values above this value are given the same color." />
125
126 <conditional name="sort_by_cond">
127 <param name="sort_by_sel" type="select" label="Sort heatmap by most abundant taxa">
128 <option value="no">No</option>
129 <option value="group">in a group of samples</option>
130 <option value="sample">in a specific sample</option>
131 </param>
132 <when value="no"/>
133 <when value="group">
134 <param argument="sort_by" type="select" optional="true" label="Group to sort by">
135 <options from_dataset="metadata_list">
136 <column name="name" index="1"/>
137 <column name="value" index="1"/>
138 <filter type="param_value" column="0" ref="group_by"/>
139 <filter type="unique_value" column="1"/>
140 </options>
141 </param>
142 </when>
143 <when value="sample">
144 <param argument="sort_by" type="select" optional="true" label="Sample to sort by">
145 <options from_dataset="metadata_list">
146 <column name="name" index="1"/>
147 <column name="value" index="1"/>
148 <filter type="static_value" value="TRUE" column="2"/> <!-- filter samples -->
149 <filter type="unique_value" column="1"/>
150 </options>
151 </param>
152 </when>
153 </conditional>
154 <!-- TODO https://github.com/MadsAlbertsen/ampvis2/issues/130 -->
155 <!-- <expand macro="metadata_sample_select" argument="normalise_by" label="Normalize counts by a variable or a specific sample"/> -->
156 <expand macro="metadata_select_discrete" argument="scale_by" label="Scale the abundances by a variable in the metadata"/>
157
158 <conditional name="plot_functions_cond">
159 <param name="plot_functions_sel" type="select" label="Show functional information about the Genus-level OTUs" help="Produces a 2-column grid plot, showing known functional information about the Genus-level OTUs next to the heatmap. When using this feature, make sure that either tax_aggregate or tax_add is set to Genus and that Genus is the lowest level in either.">
160 <option value="no">No</option>
161 <option value="midasfieldguide">Use data from midasfieldguide.org</option>
162 <option value="file">Use data from a dataset in the history</option>
163 </param>
164 <when value="no"/>
165 <when value="file">
166 <!-- neeed tsv here since tabular does not fill the column_names
167 metadata and therefore the data_meta filter in the functions
168 select would not work-->
169 <param argument="function_data" type="data" format="tsv" label="Tabular dataset with functional information at Genus level" help="See help"/>
170 <param argument="functions" type="select" multiple="true" label="Function(s) to include">
171 <options>
172 <filter type="data_meta" ref="function_data" key="column_names"/>
173 <filter type="remove_value" value="Genus"/>
174 </options>
175 </param>
176 </when>
177 <when value="midasfieldguide">
178 <param name="functions" type="select" multiple="true" label="Function(s) to include">
179 <option value="MiDAS" selected="true">MiDAS</option>
180 <option value="Filamentous" selected="true">Filamentous</option>
181 <option value="AOB" selected="true">AOB</option>
182 <option value="NOB" selected="true">PAO</option>
183 <option value="GAO" selected="true">GAO</option>
184 </param>
185 </when>
186 </conditional>
187 <expand macro="out_format_macro">
188 <option value="tabular">Table</option>
189 </expand>
190 </inputs>
191 <outputs>
192 <expand macro="out_macro">
193 <filter>output_options["out_format"] != "tabular"</filter>
194 </expand>
195 <data name="plot_raw" format="tabular">
196 <filter>output_options["out_format"] == "tabular"</filter>
197 </data>
198 </outputs>
199 <tests>
200 <!-- defaults -->
201 <test expect_num_outputs="1">
202 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
203 <output name="plot" value="AalborgWWTPs-heatmap.pdf" ftype="pdf"/>
204 </test>
205 <!-- group and facet-->
206 <test expect_num_outputs="1">
207 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
208 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
209 <param name="group_by" value="Plant"/>
210 <param name="facet_by" value="Year"/>
211 <output name="plot_raw" value="AalborgWWTPs-heatmap-group-facet.pdf" ftype="pdf"/>
212 </test>
213 <!-- group and facet and test raw output -->
214 <test expect_num_outputs="1">
215 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
216 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
217 <param name="group_by" value="Plant"/>
218 <param name="facet_by" value="Year"/>
219 <param name="out_format" value="tabular"/>
220 <output name="plot_raw" value="AalborgWWTPs-heatmap-group-facet.tsv" ftype="tabular"/>
221 </test>
222 <!-- normalise -->
223 <test expect_num_outputs="1">
224 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
225 <param name="normalise" value="true"/>
226 <output name="plot" value="AalborgWWTPs-heatmap-normalise.pdf" ftype="pdf"/>
227 </test>
228 <!-- normalise by a specific sample -->
229 <!-- TODO https://github.com/MadsAlbertsen/ampvis2/issues/130 -->
230 <!-- <test expect_num_outputs="1">
231 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
232 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
233 <param name="normalise" value="true"/>
234 <conditional name="normalise_by_cond">
235 <param name="normalise_by_sel" value="sample"/>
236 <param name="normalise_by" value="16SAMP-747"/>
237 </conditional>
238 <output name="plot" value="AalborgWWTPs-heatmap-normalise_by_sample.pdf" ftype="pdf"/>
239 </test> -->
240 <!-- normalise by a metadata variable -->
241 <!-- TODO https://github.com/MadsAlbertsen/ampvis2/issues/130 -->
242 <!-- <test expect_num_outputs="1">
243 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
244 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
245 <param name="group_by" value="Plant"/>
246 <conditional name="normalise_by_cond">
247 <param name="normalise_by_sel" value="variable"/>
248 <param name="normalise_by" value="Plant"/>
249 </conditional>
250 <output name="plot" value="AalborgWWTPs-heatmap-normalise_by_variable.pdf" ftype="pdf"/>
251 </test> -->
252 <!-- tax options -->
253 <test expect_num_outputs="1">
254 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
255 <param name="tax_aggregate" value="Order"/>
256 <param name="tax_add" value="Class"/>
257 <param name="tax_show" value="5"/>
258 <param name="showRemainingTaxa" value="true"/>
259 <output name="plot" value="AalborgWWTPs-heatmap-tax.pdf" ftype="pdf"/>
260 </test>
261 <!-- sort by a specific sample -->
262 <test expect_num_outputs="1">
263 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
264 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
265 <conditional name="sort_by_cond">
266 <param name="sort_by_sel" value="sample"/>
267 <param name="sort_by" value="16SAMP-747"/>
268 </conditional>
269 <output name="plot" value="AalborgWWTPs-heatmap-sort_by_sample.pdf" ftype="pdf"/>
270 </test>
271 <!-- sort by a group of samples -->
272 <test expect_num_outputs="1">
273 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
274 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/>
275 <param name="group_by" value="Period"/>
276 <conditional name="sort_by_cond">
277 <param name="sort_by_sel" value="group"/>
278 <param name="sort_by" value="Winter"/>
279 </conditional>
280 <output name="plot" value="AalborgWWTPs-heatmap-sort_by_group.pdf" ftype="pdf"/>
281 </test>
282 <test expect_num_outputs="1">
283 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
284 <param name="tax_aggregate" value="Genus"/>
285 <conditional name="plot_functions_cond">
286 <param name="plot_functions_sel" value="midasfieldguide"/>
287 <param name="functions" value="MiDAS,Filamentous,AOB,NOB,GAO"/>
288 </conditional>
289 <output name="plot" value="AalborgWWTPs-heatmap-plot_foo_midas.pdf" ftype="pdf"/>
290 </test>
291 <test expect_num_outputs="1">
292 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
293 <param name="tax_aggregate" value="Genus"/>
294 <conditional name="plot_functions_cond">
295 <param name="plot_functions_sel" value="file"/>
296 <param name="function_data" value="AalborgWWTPs-functions.tsv" ftype="tsv"/>
297 <param name="functions" value="Foo,Bar"/>
298 </conditional>
299 <output name="plot" value="AalborgWWTPs-heatmap-plot_foo_file.pdf" ftype="pdf"/>
300 </test>
301
302 </tests>
303 <help><![CDATA[
304 What it does
305 ============
306
307 Generates a heatmap of amplicon data by using sample metadata to aggregate
308 samples and taxonomy to aggregate OTUs.
309
310 The Galaxy tool calls the `amp_heatmap
311 <https://madsalbertsen.github.io/ampvis2/reference/amp_heatmap.html>`_ function
312 of the ampvis2 package.
313
314 @HELP_RELATIVE_ABUNDANCES@
315
316 Input
317 =====
318
319 @HELP_RDS_INPUT@
320
321 @HELP_METADATA_LIST_INPUT@
322
323 Funtional data at genus level can be added to the plot. By default the
324 information is taken from `midasfieldguide <https://midasfieldguide.org/>`_ but
325 it can also be given by a dataset (parameter function_data):
326
327 - The first column must be the Genus names and
328 - any other column(s) can be any property or metabolic function of the individual Genera.
329
330 Output
331 ======
332
333 Heatmap in the chosen output format.
334 If table output is chosen the data presented in the heatmap is written into a tabular dataset.
335 ]]></help>
336 <expand macro="citations"/>
337 </tool>