Mercurial > repos > iuc > ampvis2_ordinate
comparison ordinate.xml @ 0:f84ec808bee3 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:16:44 +0000 |
parents | |
children | 8569e8d8b712 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f84ec808bee3 |
---|---|
1 <tool id="ampvis2_ordinate" name="ampvis2 ordination plot" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT"> | |
2 <description></description> | |
3 <macros> | |
4 <import>macros.xml</import> | |
5 <xml name="distmeasure_macro"> | |
6 <param argument="distmeasure" type="select" label="Distance measure"> | |
7 <option value="wunifrac">Weighted UniFrac. Requires a rooted phylogenetic tree.</option> | |
8 <option value="unifrac">Unweighted UniFrac. Requires a phylogenetic tree.</option> | |
9 <option value="jsd">Jensen-Shannon Divergence</option> | |
10 <option value="manhattan">manhattan</option> | |
11 <option value="euclidean">euclidean</option> | |
12 <option value="canberra">canberra</option> | |
13 <option value="bray" selected="true">bray</option> | |
14 <option value="kulczynski">kulczynski</option> | |
15 <option value="jaccard">jaccard</option> | |
16 <option value="gower">gower</option> | |
17 <option value="altGower">altGower</option> | |
18 <option value="morisita">morisita</option> | |
19 <option value="horn">horn</option> | |
20 <option value="mountford">mountford</option> | |
21 <option value="raup">raup</option> | |
22 <option value="binomial">binomial</option> | |
23 <option value="chao">chao</option> | |
24 <option value="cao">cao</option> | |
25 <option value="mahalanobis">mahalanobis</option> | |
26 </param> | |
27 </xml> | |
28 <!-- default is most often hellinger, but for N/MMDS none is suggested --> | |
29 <xml name="transform_macro"> | |
30 <param argument="transform" type="select" label="Transforms the abundances before ordination" help="See details in decostand. Using the hellinger transformation is a good choice when performing PCA/RDA as it will produce a more ecologically meaningful result (read about the double-zero problem in Numerical Ecology). When the Hellinger transformation is used with CA/CCA it will help reducing the impact of low abundant species. When performing nMDS or PCoA (aka mMDS) it is not recommended to also use data transformation as this will obscure the chosen distance measure."> | |
31 <option value="none">No transformation</option> | |
32 <option value="total">divide by margin total (total)</option> | |
33 <option value="max">divide by margin maximum (max)</option> | |
34 <option value="freq">divide by margin total and multiply by the number of non-zero items, so that the average of non-zero entries is one (freq)</option> | |
35 <option value="normalize">make margin sum of squares equal to one (normalize)</option> | |
36 <option value="range">standardize values into range 0:1. If all values are constant, they will be transformed to 0. (range)</option> | |
37 <option value="standardize">scale x to zero mean and unit variance (standardize)</option> | |
38 <option value="pa">to presence/absence scale 0/1: absence/presence (pa)</option> | |
39 <option value="chi.square">divide by row sums and square root of column sums, and adjust for square root of matrix total (chi.square)</option> | |
40 <option value="hellinger">square root of method = "total" (hellinger)</option> | |
41 <option value="log">logarithmic transformation (log)</option> | |
42 <option value="sqrt">square root (sqrt)</option> | |
43 </param> | |
44 </xml> | |
45 <xml name="transform_macro_hellinger"> | |
46 <expand macro="transform_macro"> | |
47 <option value="hellinger" selected="true">square root of method = "total" (hellinger)</option> | |
48 </expand> | |
49 </xml> | |
50 <xml name="constrain_macro"> | |
51 <expand macro="metadata_select_discrete" argument="constrain" optional="false" multiple="true" label="Constrain analysis by" help="Variable(s) in the metadata for constrained analyses. Multiple variables can be provided, but keep in mind that the more variables selected the more the result will be similar to unconstrained analysis."/> | |
52 </xml> | |
53 </macros> | |
54 <expand macro="header"/> | |
55 <command detect_errors="exit_code"><![CDATA[ | |
56 Rscript '$rscript' | |
57 ]]></command> | |
58 <configfiles> | |
59 <configfile name="rscript"><![CDATA[ | |
60 #if $type_cond.type in ['RDA', 'CCA'] and $type_cond.constrain | |
61 #set constrain_list='c("' + '", "'.join(str($type_cond.constrain).split(",")) + '")' | |
62 #else | |
63 #set constrain_list='NULL' | |
64 #end if | |
65 library(ampvis2, quietly = TRUE) | |
66 data <- readRDS("$data") | |
67 details <- amp_ordinate( | |
68 data, | |
69 filter_species = $filter_species, | |
70 type = "$type_cond.type", | |
71 #if $type_cond.type in ['MMDS', 'NMDS'] | |
72 distmeasure = "$type_cond.distmeasure", | |
73 #end if | |
74 transform = "$type_cond.transform", | |
75 #if $type_cond.type in ['RDA', 'CCA'] | |
76 constrain = $constrain_list, | |
77 #end if | |
78 ## x_axis = 1, | |
79 ## y_axis = 2, | |
80 print_caption = $print_caption, | |
81 #if $sample_color_by | |
82 sample_color_by = "$sample_color_by", | |
83 #end if | |
84 ## sample_color_order = NULL, | |
85 #if $sample_shape_by | |
86 sample_shape_by = "$sample_shape_by", | |
87 #end if | |
88 #if $sample_colorframe | |
89 sample_colorframe = "$sample_colorframe", | |
90 #end if | |
91 #if $sample_colorframe_label | |
92 sample_colorframe_label = "$sample_colorframe_label", | |
93 #end if | |
94 ## sample_colorframe_label_size = 3, | |
95 #if $sample_label_by | |
96 sample_label_by = "$sample_label_by", | |
97 #end if | |
98 ## sample_label_size = 4, | |
99 ## sample_label_segment_color = "black", | |
100 ## sample_point_size = 2, | |
101 #if $sample_trajectory | |
102 sample_trajectory = "$sample_trajectory", | |
103 #if $sample_trajectory_group | |
104 sample_trajectory_group = "$sample_trajectory_group", | |
105 #end if | |
106 #end if | |
107 ## sample_plotly = NULL, | |
108 #if $species_plot_cond.species_plot == "TRUE" | |
109 species_plot = $species_plot_cond.species_plot, | |
110 species_nlabels = $species_plot_cond.species_nlabels, | |
111 species_label_taxonomy = "$species_plot_cond.species_label_taxonomy", | |
112 ## species_label_size = 3, | |
113 ## species_label_color = "grey10", | |
114 ## species_rescale = FALSE, | |
115 ## species_point_size = 2, | |
116 ## species_shape = 20, | |
117 ## species_plotly = FALSE, | |
118 #end if | |
119 #if $envfit_factor | |
120 envfit_factor = "$envfit_factor", | |
121 #end if | |
122 #if $envfit_numeric | |
123 envfit_numeric = "$envfit_numeric", | |
124 #end if | |
125 envfit_signif_level = $envfit_signif_level, | |
126 ## envfit_textsize = 3, | |
127 ## envfit_textcolor = "darkred", | |
128 ## envfit_numeric_arrows_scale = 1, | |
129 ## envfit_arrowcolor = "darkred", | |
130 ## envfit_show = TRUE, | |
131 repel_labels = $repel_labels, | |
132 opacity = $opacity, | |
133 tax_empty = "$tax_empty", | |
134 detailed_output = TRUE, | |
135 ## num_threads = 1L, | |
136 ) | |
137 plot <- details\$plot | |
138 @OUTPUT_TOKEN@ | |
139 ggsave("$screeplot", print(details\$screeplot), device="$output_options.out_format") | |
140 ## TODO output more from model | |
141 ## $model | |
142 ## $dsites | |
143 ## $dspecies | |
144 ## $evf_factor_model | |
145 ## $evf_numeric_modei | |
146 ## #else | |
147 ## write.table(raw, file = "$plot_raw", sep = "\t") | |
148 ## #end if | |
149 ]]></configfile> | |
150 </configfiles> | |
151 <inputs> | |
152 <expand macro="rds_metadata_input_macro"/> | |
153 <param argument="filter_species" type="float" value="0.1" min="0" optional="true" label="Abundance threshold" help="Remove low abundant OTU's across all samples below this threshold in percent. Setting this to 0 may drastically increase computation time."/> | |
154 <conditional name="type_cond"> | |
155 <param argument="type" type="select" label="Ordination method" help="Note that PCoA is not performed by the vegan package, but the pcoa function from the APE package."> | |
156 <option value="PCA">(PCA) Principal Components Analysis</option> | |
157 <option value="RDA">(RDA) Redundancy Analysis (considered the constrained version of PCA)</option> | |
158 <option value="CA">(CC) Correspondence Analysis</option> | |
159 <option value="CCA">(CCA) Canonical Correspondence Analysis (considered the constrained version of CA)</option> | |
160 <option value="DCA">(DCA) Detrended Correspondence Analysis</option> | |
161 <option value="NMDS">(NMDS) non-metric Multidimensional Scaling</option> | |
162 <option value="MMDS">(MMDS) metric Multidimensional Scaling a.k.a Principal Coordinates Analysis (not to be confused with PCA)</option> | |
163 </param> | |
164 <when value="PCA"> | |
165 <expand macro="transform_macro_hellinger"/> | |
166 </when> | |
167 <when value="RDA"> | |
168 <expand macro="transform_macro_hellinger"/> | |
169 <expand macro="constrain_macro"/> | |
170 </when> | |
171 <when value="CA"> | |
172 <expand macro="transform_macro_hellinger"/> | |
173 </when> | |
174 <when value="CCA"> | |
175 <expand macro="transform_macro_hellinger"/> | |
176 <expand macro="constrain_macro"/> | |
177 </when> | |
178 <when value="DCA"> | |
179 <expand macro="transform_macro_hellinger"/> | |
180 </when> | |
181 <when value="NMDS"> | |
182 <expand macro="distmeasure_macro"/> | |
183 <expand macro="transform_macro"> | |
184 <option value="none" selected="true">No transformation</option> | |
185 </expand> | |
186 </when> | |
187 <when value="MMDS"> | |
188 <expand macro="distmeasure_macro"/> | |
189 <expand macro="transform_macro"> | |
190 <option value="none" selected="true">No transformation</option> | |
191 </expand> | |
192 </when> | |
193 </conditional> | |
194 <param argument="print_caption" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Auto-generate a figure caption" help="Based on the used arguments. The caption includes a description of how the result has been generated as well as references for the methods used."/> | |
195 <expand macro="metadata_select" argument="sample_color_by" label="Color sample points by"/> | |
196 <expand macro="metadata_select_discrete" argument="sample_shape_by" label="Shape sample points by"/> | |
197 <expand macro="metadata_select_discrete" argument="sample_colorframe" label="Frame the sample points with a polygon by" help="Split by the variable defined by sample_color_by"/> | |
198 <expand macro="metadata_select" argument="sample_colorframe_label" label="Label Frame by"/> | |
199 <expand macro="metadata_select" argument="sample_label_by" label="Label sample points by"/> | |
200 <expand macro="metadata_select" argument="sample_trajectory" label="Make a trajectory between sample points by"/> | |
201 <expand macro="metadata_select" argument="sample_trajectory_group" label="Make a trajectory between sample points by the sample_trajectory argument, but within individual groups."/> | |
202 | |
203 <conditional name="species_plot_cond"> | |
204 <param argument="species_plot" type="select" label="Plot species points"> | |
205 <option value="TRUE">Yes</option> | |
206 <option value="FALSE" selected="true">No</option> | |
207 </param> | |
208 <when value="TRUE"> | |
209 <param argument="species_nlabels" type="integer" value="10" min="1" label="Number of the most extreme species labels to plot" help="Ordered by the sum of the numerical values of the x,y coordinates. Only makes sense with PCA/RDA)."/> | |
210 <expand macro="taxlevel_macro" argument="species_label_taxonomy" label="Taxonomic level by which to label the species points"> | |
211 <option value="Genus" selected="true">Genus</option> | |
212 </expand> | |
213 <param argument="species_label_size" type="integer" value="3" min="1" label="Size of the species text labels"/> | |
214 </when> | |
215 <when value="FALSE"/> | |
216 </conditional> | |
217 | |
218 <expand macro="metadata_select_discrete" argument="envfit_factor" label="Categorical variables to fit onto the ordination plot"/> | |
219 <expand macro="metadata_select_numeric" argument="envfit_numeric" label="Numerical variables to fit arrows onto the ordination plot." help="The lengths of the arrows are scaled by significance. "/> | |
220 <param argument="envfit_signif_level" type="float" value="0.005" min="0" max="1" label="Significance threshold" help="For displaying the fitting results"/> | |
221 | |
222 <param argument="repel_labels" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Repel all labels" help="To prevent cluttering of the plot"/> | |
223 <param argument="opacity" type="float" value="0.8" min="0" max="1" label="Opacity of plotted points and colorframe" help="0: invisible, 1: opaque."/> | |
224 <expand macro="tax_empty_macro"/> | |
225 <expand macro="out_format_macro"/> | |
226 <param name="output_screeplot" type="boolean" checked="false" label="Output screeplot" help="plot of variances against the number of the principal component"/> | |
227 </inputs> | |
228 <outputs> | |
229 <expand macro="out_macro"/> | |
230 <expand macro="out_macro" name="screeplot" label=": screeplot"> | |
231 <filter>output_screeplot</filter> | |
232 </expand> | |
233 </outputs> | |
234 <tests> | |
235 <!-- defaults (PCA) --> | |
236 <test expect_num_outputs="2"> | |
237 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
238 <param name="output_screeplot" value="true"/> | |
239 <output name="plot" value="AalborgWWTPs-ordinate.pdf" ftype="pdf"/> | |
240 <output name="screeplot" value="AalborgWWTPs-ordinate-screeplot.pdf" ftype="pdf"/> | |
241 </test> | |
242 <!-- RDA + caption --> | |
243 <test expect_num_outputs="1"> | |
244 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
245 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
246 <conditional name="type_cond"> | |
247 <param name="type" value="RDA"/> | |
248 <param name="distmeasure" value="manhattan"/> | |
249 <param name="transform" value="chi.square"/> | |
250 <param name="constrain" value="Plant"/> | |
251 </conditional> | |
252 <output name="plot" value="AalborgWWTPs-ordinate-rda.pdf" ftype="pdf"/> | |
253 </test> | |
254 <!-- MMDS + unfirac (which requires a tree) --> | |
255 <test expect_num_outputs="1"> | |
256 <param name="data" value="AalborgWWTPs-complete.rds" ftype="ampvis2"/> | |
257 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
258 <conditional name="type_cond"> | |
259 <param name="type" value="MMDS"/> | |
260 <param name="distmeasure" value="unifrac"/> | |
261 </conditional> | |
262 <output name="plot" value="AalborgWWTPs-ordinate-nmds.pdf" ftype="pdf"/> | |
263 </test> | |
264 <!-- color, shape and colorframe --> | |
265 <test expect_num_outputs="1"> | |
266 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
267 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
268 <param name="sample_color_by" value="Year"/> | |
269 <param name="sample_shape_by" value="Plant"/> | |
270 <param name="sample_colorframe" value="Year"/> | |
271 <param name="sample_colorframe_label" value="Year"/> | |
272 <output name="plot" value="AalborgWWTPs-ordinate-color-shape-frame.pdf" ftype="pdf"/> | |
273 </test> | |
274 <!-- label, trajectory --> | |
275 <test expect_num_outputs="1"> | |
276 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
277 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
278 <param name="sample_label_by" value="Plant"/> | |
279 <param name="sample_trajectory" value="Year"/> | |
280 <output name="plot" value="AalborgWWTPs-ordinate-label-traj.pdf" ftype="pdf"/> | |
281 </test> | |
282 <!-- trajectory group --> | |
283 <test expect_num_outputs="1"> | |
284 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
285 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
286 <param name="sample_trajectory_group" value="Plant"/> | |
287 <output name="plot" value="AalborgWWTPs-ordinate-label-traj-group.pdf" ftype="pdf"/> | |
288 </test> | |
289 <!-- species plot --> | |
290 <test expect_num_outputs="1"> | |
291 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
292 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
293 <conditional name="species_plot_cond"> | |
294 <param name="species_plot" value="TRUE"/> | |
295 <param name="species_nlabels" value="2"/> | |
296 <param name="species_label_taxonomy" value="Family"/> | |
297 <param name="species_label_size" value="4"/> | |
298 </conditional> | |
299 <output name="plot" value="AalborgWWTPs-ordinate-species.pdf" ftype="pdf"/> | |
300 </test> | |
301 <!-- envfit factor--> | |
302 <test expect_num_outputs="1"> | |
303 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
304 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
305 <param name="envfit_factor" value="Plant"/> | |
306 <output name="plot" value="AalborgWWTPs-ordinate-envfit-factor.pdf" ftype="pdf"/> | |
307 </test> | |
308 <!-- envfit numeric--> | |
309 <test expect_num_outputs="1"> | |
310 <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> | |
311 <param name="metadata_list" value="AalborgWWTPs-metadata.list"/> | |
312 <param name="envfit_numeric" value="Year"/> | |
313 <output name="plot" value="AalborgWWTPs-ordinate-envfit-num.pdf" ftype="pdf"/> | |
314 </test> | |
315 </tests> | |
316 <help><![CDATA[ | |
317 What it does | |
318 ============ | |
319 | |
320 Generate ordination plots suited for analysis and comparison of microbial communities. | |
321 | |
322 The Galaxy tool calls the `amp_ordinate | |
323 <https://madsalbertsen.github.io/ampvis2/reference/amp_ordinate.html>`_ function | |
324 of the ampvis2 package, which is a wrapper around the vegan package to generate | |
325 ggplot2 ordination plots. | |
326 | |
327 Details | |
328 ======= | |
329 | |
330 The ``amp_ordinate`` function is primarily based on two packages: | |
331 | |
332 1. ``vegan`` package, which performs the actual ordination, and | |
333 2. the ggplot2-package to generate the plot. | |
334 | |
335 The function generates an ordination plot by the following process: | |
336 | |
337 - Various input argument checks and error messages | |
338 - OTU-table filtering, where low abundant OTU's across all samples are removed (if not **Abundance threshold** (``filter_species``) is set to 0) | |
339 - Data transformation (if not **Transforms the abundances before ordination** (``transform``) is set to "no transformation"). | |
340 See details in `decostand <https://rdrr.io/cran/vegan/man/decostand.html>`_ | |
341 - Calculate distance matrix based on the chosen distmeasure if the chosen ordination method is PCoA/nMDS/DCA. | |
342 See details in `vegdist <https://rdrr.io/cran/vegan/man/vegdist.html>`_ | |
343 - Perform the actual ordination and calculate the axis scores for both samples and species/OTU's | |
344 - Visualise the result with ggplot2 or plotly in various ways defined by the user | |
345 | |
346 When the chosen ordination method is an eigenanalysis-based method then the | |
347 relative contribution (eigenvalue) of each axis to the total inertia in the data | |
348 (sum of all eigenvalues, including those of the constrained space) is indicated | |
349 in percent at the axis titles. When one of the constrained ordination methods | |
350 (RDA and CCA) is used then a second value is furthermore shown which then | |
351 indicates the relative contribution of the particular axis to the total | |
352 constrained space only. | |
353 | |
354 Input | |
355 ===== | |
356 | |
357 @HELP_RDS_INPUT@ | |
358 | |
359 @HELP_METADATA_LIST_INPUT@ | |
360 | |
361 Output | |
362 ====== | |
363 | |
364 An ordination plot in the chosen output format. | |
365 ]]></help> | |
366 <expand macro="citations"/> | |
367 </tool> |