view metaquantome_viz.xml @ 3:944b43462104 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/metaquantome commit cf8aec441ba6ef62071c3cf4ac840ebc5a710aa4"
author galaxyp
date Tue, 24 Nov 2020 15:08:30 +0000
parents 02da24eac445
children 1199751329b0
line wrap: on
line source

<tool id="metaquantome_viz" name="metaQuantome: visualize" version="@GVERSION@">
    <description>taxonomic analysis, functional analysis, and function-taxonomy analysis results</description>
    <macros>
        <import>macros.xml</import>
        <xml name="barcol">
          <param argument="--barcol" type="select" label="Color for the bar fill">
            <option value="1">Blue</option>
            <option value="2">Orange</option>
            <option value="3">Yellow</option>
            <option value="4">Red</option>
            <option value="5">Violet</option>
            <option value="6">Black</option>
              <help>
                These same colors are also used in the heatmap and PCA plot,
                so the colors can be tweaked to match. Note that these colors
                are coded as 1 through 6 in the command line tool.
              </help>
          </param>
        </xml>
        <xml name="common_bar_params">
          <param argument="--meancol" type="text" label="Mean intensity column name"
                  help="Mean intensity column name for desired experimental condition">
                  <validator type="empty_field"/>
          </param>
          <param argument="--nterms" type="integer"
            value="5" min="1" optional="true"
            label="Number of terms to display"
            help="leave blank for all terms"/>
        </xml>
        <xml name="common_volc_params">
          <param argument="--fc_name" type="text" label="Name of the fold change column in the stat dataframe">
                  <validator type="empty_field"/>
          </param>
          <param argument="--fc_corr_p" type="text" label="Name of the Corrected p-value column in the stat dataframe">
                  <validator type="empty_field"/>
          </param>
          <param argument="--textannot" type="text" optional="true" label="Name of the annotation column"
              help="Provides text annotatation for the plot.  Optional. If missing, no text will be plotted."/>
          <param argument="--flip_fc" type="boolean" truevalue="--flip_fc" falsevalue="" checked="false"
              label="Flip the fold change (i.e., multiply log fold change by -1)"/>
        </xml>
        <xml name="common_heatmap_params">
          <conditional name="heatmap">
            <param argument="--filter_to_sig" type="boolean" checked="false"
              label="Only plot significant term" help="Necessitates use of results from `test`"/>
            <when value="true">
              <param argument="--alpha" type="float"
              value="0.05" min="0.0" max="1.0"
              label="The q-value significance level"/>
              <param argument="--fc_corr_p" type="text" label="Name of the Corrected p-value column in the stat dataframe">
                <validator type="empty_field"/>
              </param>
            </when>
            <when value="false">
              <!-- do nothing -->
            </when>
          </conditional>
          <param argument="--feature_cluster_size" value="2" type="integer" label="For tabular output. Number of clusters 'k' to cut the feature dendrogram tree."/>
          <param argument="--sample_cluster_size"  value="2" type="integer" label="For tabular output. Number of clusters 'k' to cut the sample dendrogram tree."/>
        </xml>
        <xml name="pca_calcsep">
          <param argument="--calculate_sep" type="boolean" truevalue="--calculate_sep" falsevalue="" checked="false"
              label="Calculate separation between groups and include in title?"/>
        </xml>
        <xml name="target_onto">
          <param argument="--target_onto" type="select" optional="false"
            label="GO category to restrict to">
            <help>
              Only the values from this category
              of GO terms will be displayed.
            </help>
            <option value="bp">Biological Process</option>
            <option value="mf">Molecular Function</option>
            <option value="cc">Cellular Component</option>
          </param>
        </xml>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
	#import re
	#set $safename = re.sub('[^\w\-_\.]', '_', $infile.element_identifier)
	ln -s '$infile' '$safename'
        &&
        metaquantome viz
        --samps '$samps'
        --mode '$mode_args.mode'
        #if str($mode_args.mode) == 'f'
            --ontology='$mode_args.ontology'
        #end if
        --infile='$safename'
        --plottype='$mode_args.plot.plottype'
        #if $mode_args.plot.plottype == 'bar':
            #if str($mode_args.mode) == 't':
                --target_rank='$mode_args.plot.target_rank'
            #end if
            --meancol='$mode_args.plot.meancol'
            #if str($mode_args.plot.nterms) == '':
                --nterms='all'
            #else
                --nterms=$mode_args.plot.nterms
            #end if
            #if str($mode_args.mode) == 'f':
                --target_onto='$mode_args.plot.target_onto'
            #end if
            --barcol=$mode_args.plot.barcol
        #elif $mode_args.plot.plottype == 'volcano':
            --fc_name='$mode_args.plot.fc_name'
            --fc_corr_p='$mode_args.plot.fc_corr_p'
            #if $mode_args.plot.textannot:
                --textannot='$mode_args.plot.textannot'
            #end if
            $mode_args.plot.flip_fc
            #if $mode_args.mode == 'f':
              $mode_args.plot.gosplit
            #end if
        #elif $mode_args.plot.plottype == 'heatmap':
            #if $mode_args.plot.heatmap.filter_to_sig:
              --filter_to_sig
              --alpha=$mode_args.plot.heatmap.alpha
              --fc_corr_p='mode_args.plot.fc_corr_p'
            #end if
            #if $mode_args.plot.feature_cluster_size:
                --feature_cluster_size='$mode_args.plot.feature_cluster_size'
            #end if
            #if $mode_args.plot.sample_cluster_size:
                --sample_cluster_size='$mode_args.plot.sample_cluster_size'
            #end if
        #elif $mode_args.plot.plottype == 'pca':
            $mode_args.plot.calculate_sep
        #elif $mode_args.plot.plottype == 'ft_dist':
            --barcol='$mode_args.plot.barcol'
            --whichway='$mode_args.plot.margin.whichway'
            --meancol='$mode_args.plot.meancol'
            #if $mode_args.plot.margin.term.id_or_name == 'id':
                --id='$mode_args.plot.margin.term.id'
            #else:
                --name='$mode_args.plot.margin.term.name'
            #end if
            #if $mode_args.plot.margin.whichway == 't_dist':
                --target_rank='$mode_args.plot.margin.target_rank'
            #end if
            #if $mode_args.plot.margin.whichway == 'f_dist':
                --target_onto=$mode_args.plot.margin.target_onto
            #end if
        #end if
        #if $width:
            --width=$width
        #end if
        #if $height:
            --height=$height
        #end if
        --img='outfile.png'
        --tabfile='plotdata.tab' &&
        mkdir '${ wrapped_outfile.files_path }' &&
        cp outfile.png '${ wrapped_outfile.files_path }' &&
        echo "<!DOCTYPE html>
        <html>
          <body>
            <img src=\"outfile.png\" width=600>
            <br>
            <p>To download the image, right-click and choose \"Save image as...\"</p>
            <br>
            <p>
              If text is cut off or the plot is not displaying properly,
              the easiest fix is to increase the plot dimensions
            </p>
          </body>
        </html>" > wrapped_outfile.html
    && >&2 ls
    #if $mode_args.plot.plottype in ["heatmap"]
        && mv 'feature_cluster_${safename}.txt' '$heatmap_feature_cluster'
        && mv 'sample_cluster_${safename}.txt' '$heatmap_sample_cluster'
    #end if
    #if $mode_args.plot.plottype in ["pca"]
        && mv 'PC_data_${safename}.txt' '$pca_sample_cluster'
    #end if
      
    ]]></command>
    <inputs>
      <param argument="--infile" type="data"
        format="tabular" label="Tabular file from metaQuantome stats or metaQuantome filter" help=""/>
      <expand macro="SAMPS"/>
      <conditional name="mode_args">
        <param argument="--mode" type="select" label="Mode">
            <option value="f">Functional analysis</option>
            <option value="t">Taxonomic analysis</option>
            <option value="ft">Functional-taxonomic interaction analysis</option>
        </param>
        <when value="f">
          <param name="ontology" type="select" label="Ontology">
            <option value="go">Gene Ontology (GO terms)</option>
            <option value="ec">Enzyme Commission (EC) numbers</option>
            <option value="cog">Clusters of Orthologous Groups (COG categories)</option>
          </param>
          <conditional name="plot">
            <param argument="--plottype" type="select" label="Plot type">
              <option value="bar">Bar Chart (bar)</option>
              <option value="volcano">Volcano Plot (volcano)</option>
              <option value="heatmap">Heatmap (heatmap)</option>
              <option value="pca">Principal Components Analysis (pca)</option>
            </param>
            <when value="bar">
              <expand macro="common_bar_params"/>
              <expand macro="target_onto"/>
              <expand macro="barcol"/>
            </when>
            <when value="volcano">
              <expand macro="common_volc_params"/>
              <param argument="--gosplit" type="boolean" truevalue="--gosplit" falsevalue="" checked="false"
                  label="Make one plot for each of BiologicalProcess, CellularComponent, and MolecularFunction GO term categories."/>
            </when>
            <when value="heatmap">
              <expand macro="common_heatmap_params"/>
            </when>
            <when value="pca">
              <expand macro="pca_calcsep"/>
            </when>
          </conditional>
        </when>
        <when value="t">
          <conditional name="plot">
            <param argument="--plottype" type="select" label="Plot type">
              <option value="bar">Bar Chart (bar)</option>
              <option value="volcano">Volcano Plot (volcano)</option>
              <option value="heatmap">Heatmap (heatmap)</option>
              <option value="pca">Principal Components Analysis (pca)</option>
            </param>
            <when value="bar">
              <param argument="--target_rank" type="select"
                label="Taxonomic rank to restrict to in the plot"
                      help="possibilities are taken from the input dataset.">
                  <options from_dataset="infile">
                    <column name="value" index="2"/>
                    <filter type="unique_value" name="unique_taxon" column="2"/>
                    <!-- <filter type="remove_value" value="rank" column="2"/> -->
                  </options>
              </param>
              <expand macro="common_bar_params"/>
              <expand macro="barcol"/>
            </when>
            <when value="volcano">
              <expand macro="common_volc_params"/>
            </when>
            <when value="heatmap">
              <expand macro="common_heatmap_params"/>
            </when>
            <when value="pca">
              <expand macro="pca_calcsep"/>
            </when>
          </conditional>
        </when>
        <when value="ft">
          <conditional name="plot">
            <param argument="--plottype" type="select" label="Plot type">
              <option value="ft_dist" selected="true">Functional Taxonomic Distribution (ft_dist)</option>
            </param>
            <when value="ft_dist">
              <param argument="--meancol" type="text" label="Mean intensity column name"
                      help="Mean intensity column name for desired experimental condition">
                      <validator type="empty_field"/>
              </param>
              <conditional name="margin">
                <param argument="--whichway" type="select" label="which distribution">
                  <option value="f_dist">functional distribution for a taxon (f_dist)</option>
                  <option value="t_dist">taxonomic distribution for a function (t_dist)</option>
                </param>
                <when value="f_dist">
                  <conditional name="term">
                    <param name="id_or_name" type="select" label="">
                      <option value="id" selected="true">Taxon ID</option>
                      <option value="name">Taxon name</option>
                    </param>
                    <when value="id">
                        <param argument="--id" type="select" label="Taxon id">
                            <options from_dataset="infile">
                              <column name="value" index="3"/>
                              <filter type="unique_value" column="3"/>
                              <!-- <filter type="remove_value" value="tax_id"/> -->
                            </options>
                        </param>
                    </when>
                    <when value="name">
                      <param argument="--name" type="select" label="Taxon name">
                          <options from_dataset="infile">
                            <column name="value" index="4"/>
                            <filter type="unique_value" column="4"/>
                            <!-- <filter type="remove_value" value="taxon_name"/> -->
                          </options>
                      </param>
                    </when>
                  </conditional>
                  <expand macro="target_onto"/>
                </when>
                <when value="t_dist">
                  <conditional name="term">
                    <param name="id_or_name" type="select" label="">
                      <option value="id" selected="true">Functional term ID</option>
                      <option value="name">Functional term name</option>
                    </param>
                    <when value="id">
                        <param argument="--id" type="select" label="Functional term id">
                            <options from_dataset="infile">
                              <column name="value" index="0"/>
                              <filter type="unique_value" column="0"/>
                              <!-- <filter type="remove_value" value="go_id"/> -->
                            </options>
                        </param>
                    </when>
                    <when value="name">
                      <param argument="--name" type="select" label="Functional term name">
                          <options from_dataset="infile">
                            <column name="value" index="1"/>
                            <filter type="unique_value" column="1"/>
                            <!-- <filter type="remove_value" value="name"/> -->
                          </options>
                      </param>
                    </when>
                  </conditional>
                  <param argument="--target_rank" type="select"
                    label="Taxonomic rank to restrict to in the plot"
                    help="possibilities are taken from the input dataset.">
                    <options from_dataset="infile">
                      <column name="value" index="5"/>
                      <filter type="unique_value" name="unique_taxon" column="5"/>
                      <!-- <filter type="remove_value" value="rank" column="5"/> -->
                    </options>
                  </param>
                </when>
              </conditional>
              <expand macro="barcol"/>
            </when>
          </conditional>
        </when>
      </conditional>
      <param argument="--width" type="float" value="" optional="true" label="Image width in inches"/>
      <param argument="--height" type="float" value="" optional="true" label="Image height in inches"/>
    </inputs>
    <outputs>
      <data format="html" name="wrapped_outfile"
          label="${tool.name} on ${on_string} ${mode_args.plot.plottype}.html"
          from_work_dir="wrapped_outfile.html"/>
      <data format="tabular" name="plotdata"
        label="${tool.name} on ${on_string} ${mode_args.plot.plottype}: plot data"
        from_work_dir="plotdata.tab">
        <filter>mode_args['plot']['plottype'] in ["bar", "volcano"]</filter>
      </data>
      
      <data format="tabular" name="heatmap_feature_cluster"
        label="${tool.name} on ${on_string}: ${mode_args.plot.plottype} feature cluster data">
        <filter>mode_args['plot']['plottype'] in ["heatmap"]</filter>
      </data>
      <data format="tabular" name="heatmap_sample_cluster"
        label="${tool.name} on ${on_string}: ${mode_args.plot.plottype} sample cluster data">
        <filter>mode_args['plot']['plottype'] in ["heatmap"]</filter>
      </data>
      
      <data format="tabular" name="pca_sample_cluster"
        label="${tool.name} on ${on_string}: ${mode_args.plot.plottype} sample cluster data">
        <filter>mode_args['plot']['plottype'] in ["pca"]</filter>
      </data>
      
    </outputs>
    <tests>
        <test expect_num_outputs="2">
             <param name="infile" value="tax_filt_out.tab" ftype="tabular"/>
             <param name="mode" value="t" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="bar" />
             <param name="target_rank" value="genus" />
             <param name="meancol" value="NS_mean" />
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="2">
             <param name="infile" value="tax_test_out.tab" ftype="tabular"/>
             <param name="mode" value="t" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="volcano" />
             <param name="target_rank" value="genus" />
             <param name="fc_name" value="log2fc_NS_over_WS" />
             <param name="fc_corr_p" value="corrected_p_NS_over_WS"/>
             <param name="textannot" value="taxon_name" />
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="3">
             <param name="infile" value="tax_test_out.tab" ftype="tabular"/>
             <param name="mode" value="t" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="heatmap" />
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="2">
             <param name="infile" value="tax_test_out.tab" ftype="tabular"/>
             <param name="mode" value="t" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="pca" />
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="2">
             <param name="infile" value="func_full_test_out.tab" ftype="tabular"/>
             <param name="mode" value="f" />
             <param name="ontology" value="go" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="bar" />
             <param name="meancol" value="NS_mean" />
             <param name="target_onto" value="bp"/>
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="2">
             <param name="infile" value="func_full_test_out.tab" ftype="tabular"/>
             <param name="mode" value="f" />
             <param name="ontology" value="go"/>
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="volcano" />
             <param name="fc_name" value="log2fc_NS_over_WS" />
             <param name="fc_corr_p" value="corrected_p_NS_over_WS"/>
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="1">
             <param name="infile" value="tf_filt_out.tab" ftype="tabular"/>
             <param name="mode" value="ft" />
             <param name="samps" value="rudney_samples.tab" ftype="tabular"/>
             <param name="plottype" value="ft_dist" />
             <param name="meancol" value="NS_mean" />
             <param name="whichway" value="f_dist" />
             <param name="id_or_name" value="id" />
             <param name="id" value="1301" />
             <param name="target_onto" value="bp" />
             <output name="wrapped_outfile">
                <assert_contents>
                    <has_text text="To download the image" />
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
metaQuantome viz
===================

The *viz* module is the final step in the metaQuantome analysis workflow.
The available visualizations are:

- bar plot
- volcano plot
- heatmap
- PCA plot

Please consult the manuscript for full details on each of these plots.

Questions, Comments, Problems, Kudos
--------------------------------------

Please file any issues at https://github.com/galaxyproteomics/tools-galaxyp/issues.
    ]]></help>
    <expand macro="citations" />
</tool>