view alpha_diversity.xml @ 9:bd518ee51da5 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ampvis2 commit 9fe04d29ea604a152144908dbd20c0754695a025
author iuc
date Sat, 16 Nov 2024 19:53:02 +0000
parents 77000428c613
children
line wrap: on
line source

<tool id="ampvis2_alpha_diversity" name="ampvis2 alpha diversity" version="@TOOL_VERSION@+galaxy1" profile="@PROFILE@" license="MIT">
    <description></description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="header"/>
    <command detect_errors="exit_code"><![CDATA[
        Rscript '$rscript'
    ]]></command>
    <configfiles>
        <configfile name="rscript"><![CDATA[
            #set m='"' + '", "'.join(str($measure).split(",")) + '"'
            library(ampvis2, quietly = TRUE)

            d <- readRDS("$data")
            table <- amp_alphadiv(d,
                measure = c($m),
                richness = $richness
                @RAREFY_TOKEN@,
            )
            plot <- amp_alphadiv(d,
                measure = c($m),
                richness = $richness
                @RAREFY_TOKEN@,
                plot = TRUE,
                plot_group_by = "$group_by",
                plot_scatter = $plot_scatter
            )
            write.table(table, file='$alphadiv', quote=FALSE, sep='\t', row.names=FALSE) 
            ggsave("$alphadiv_plot",
                    plot = plot,
                    device = "$output_options.out_format"
                    #if str($output_options.plot_width) != ''
                        , width = $output_options.plot_width
                    #end if
                    #if str($output_options.plot_height) != ''
                        , height = $output_options.plot_height
                    #end if
                )
        ]]></configfile>
    </configfiles>
    <inputs>
        <expand macro="rds_input_macro"/>
        <param argument="measure" type="select" multiple="true" optional="false" label="Alpha-diversity measure(s) to be included">
            <option value="observed" selected="true">observed</option>
            <option value="shannon" selected="true">shannon</option>
            <option value="simpson" selected="true">simpson</option>
            <option value="invsimpson" selected="true">invsimpson</option>
        </param>
        <param argument="richness" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Calculate sample richness estimates" help="Chao1 and ACE"/>
        <expand macro="rarefy_macro" help="before calculating alpha diversity and/or richnes"/>
        <param argument="group_by" type="text" label="Group by metadata field (for plotting)" help="Specify the metadata field to group the plot by"/>
        <param argument="plot_scatter" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Scatter plot instead of boxplot?" help="Select to generate a scatter plot instead of a boxplot"/>
        <expand macro="out_format_macro"/>
    </inputs>
    <outputs>
        <data name="alphadiv" format="tabular"/>
        <expand macro="out_macro" name="alphadiv_plot" label=": plot"/>
    </outputs>
    <tests>
        <test>
            <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/>
            <param name="group_by" value="Plant"/>
            <param name="plot_scatter" value="false"/>
            <output name="alphadiv">
                <assert_contents>
                    <has_line line="SampleID&#9;Plant&#9;Date&#9;Year&#9;Period&#9;Reads&#9;uniqueOTUs&#9;Shannon&#9;Simpson&#9;invSimpson"/>
                    <has_text text="16SAMP-536&#9;"/>
                    <has_text text="&#9;Aalborg West&#9;"/>
                    <has_n_lines n="68"/>
                    <has_n_columns n="10"/>
                </assert_contents>
            </output>
            <output name="alphadiv_plot" ftype="pdf">
                <assert_contents>
                    <has_size min="1"/>
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="data" value="AalborgWWTPs.rds" ftype="ampvis2"/> 
            <param name="measure" value="observed,shannon"/> 
            <param name="richness" value="true"/>
            <param name="rarefy" value="500"/>
            <param name="group_by" value="Plant"/>
            <param name="plot_scatter" value="true"/>
            <output name="alphadiv">
                <assert_contents>
                    <has_line line="SampleID&#9;Plant&#9;Date&#9;Year&#9;Period&#9;RawReads&#9;Reads&#9;uniqueOTUs&#9;Shannon&#9;Simpson&#9;invSimpson&#9;Chao1&#9;ACE"/>
                    <has_text text="16SAMP-536&#9;"/>
                    <has_text text="&#9;Aalborg West&#9;"/>
                    <has_n_lines n="68"/>
                    <has_n_columns n="13"/>
                    <has_text text="&#9;500&#9;"/>
                </assert_contents>
            </output>
            <output name="alphadiv_plot">
                <assert_contents>
                    <has_size min="1"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[

What it does
============

Calculate alpha-diversity indices for each sample and combines with the metadata.

The Galaxy tool calls the `amp_alpha_diversity
<https://kasperskytte.github.io/ampvis2/reference/amp_alphadiv.html>`_ function
of the ampvis2 package. 

Usage
=====

The alpha-diversity indices are calculated per sample using the vegan function `diversity <https://rdrr.io/pkg/vegan/man/diversity.html>`_,
where the read abundances are first rarefied using `rrarefy <https://rdrr.io/pkg/vegan/man/rarefy.html>`_ by the size of the rarefy argument.
Refer to the vegan documentation for details about the different indices and how they are
calculated.


Input
=====

@HELP_RDS_INPUT@

Output
======

A tabular dataset containing the chosen alpha-diversity measures per sample.

    ]]></help>
    <expand macro="citations">
        <citation type="doi">10.1371/journal.pcbi.1003531</citation>
    </expand>
</tool>