view phyloseq_plot_bar.xml @ 7:e9442bd54200 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit fa72d860839082a926004d8a97a03a3e27701333
author iuc
date Fri, 04 Apr 2025 10:16:02 +0000
parents 8a9c340debc8
children
line wrap: on
line source

<tool id="phyloseq_plot_bar" name="Phyloseq: Bar Chart" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
  <description>Generate bar charts from a phyloseq object</description>
  <macros>
    <import>macros.xml</import>
  </macros>
  <expand macro="bio_tools"/>
  <expand macro="requirements"/>
  <command detect_errors="exit_code"><![CDATA[
Rscript '${__tool_directory__}/phyloseq_plot_bar.R'
--input '$input'
--x '$x'
--fill '$fill'
--facet '$facet'
--topX '$topX'
'$keepOthers'
'$keepNonAssigned'
'$normalize'
'$normalize_x'
'$nolines'
--width '$width'
--height '$height'
--device '$device'
--output '$output'
  ]]></command>
  <inputs>
    <expand macro="phyloseq_input"/>
    <param name="x" type="text" optional="true" label="X-axis variable" help="Variable for the x-axis (Metadata columns). If not specified, the Samples are taken." />
    <param name="fill" type="text" label="Fill variable" help="Variable to color the bars (e.g., Genus, Species). Use 'ASV' as argument to show each OTU/ASV." />
    <param name="facet" type="text" optional="true" label="Facet by variable" help="Variable to facet the chart by (e.g., SampleType)." />
    <param name="topX" value="10" type="integer" optional="true" label="Top X" help="Only show the ranks with the top X abundance." />
    <param name="keepOthers" type="boolean" truevalue="--keepOthers" falsevalue="" label="Keep 'Others'" help="Keep OTUs which are not in top X as 'Others'." />
    <param name="keepNonAssigned" type="boolean" truevalue="--keepNonAssigned" falsevalue="" label="Keep 'Not Assigned'" help="Keep OTUs that are not assigned at this rank and label as 'Not Assigned'." />
    <param name="normalize" type="boolean" truevalue="--normalize" falsevalue="" label="Normalize" help="Normalize abundances to sum to 100%. Normalization is performed before Top X selection." />
    <param name="normalize_x" type="boolean" truevalue="--normalize_x" falsevalue="" label="Normalize x" help="Normalize abundances of the x group to sum to 100%. Normalization is performed before Top X selection. Ignores facetting!" />
    <param name="nolines" type="boolean" truevalue="--nolines" falsevalue="" label="Remove Separation Lines" help="Do not add OTU separation lines in the bars." />
    <param name="width" type="float" value="10" optional="true" label="Plot Width" help="Width of the output plot in inches." />
    <param name="height" type="float" value="8" optional="true" label="Plot Height" help="Height of the output plot in inches." />
    <param name="device" type="select" value="pdf" label="Output Device" help="File format to use for the output file. ">
      <option value="pdf">PDF</option>
      <option value="png">PNG</option>
      <option value="jpg">JEG</option>
      <option value="tiff">TIFF</option>
    </param>
  </inputs>
  <outputs>
    <data name="output" format="pdf" label="Bar Chart (${device})">
      <change_format>
        <when input="device" format="pdf" value="pdf"/>
        <when input="device" format="png" value="png"/>
        <when input="device" format="jpg" value="jpg"/>
        <when input="device" format="tiff" value="tiff"/>
      </change_format>
    </data>
  </outputs>

  <tests>
    <!-- Test 1: Basic functionality with x and fill variables -->
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="x" value="Property"/>
      <param name="fill" value="Phylum"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_01.png" ftype="png" compare="image_diff"/>
    </test>

    <!-- Test 2: TopX filtering and normalization -->
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="x" value="Property"/>
      <param name="fill" value="Genus"/>
      <param name="facet" value="Number"/>
      <param name="topX" value="10"/>
      <param name="normalize" value="true"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_02.png" ftype="png" compare="image_diff"/>
    </test>


    <!-- Test 3: without OTU lines, Others and non assigned --> 
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="x" value="Sample"/>
      <param name="fill" value="Genus"/>
      <param name="facet" value=""/>
      <param name="topX" value="10"/>
      <param name="normalize" value="false"/>
      <param name="keepOthers" value="true"/>
      <param name="keepNonAssigned" value="false"/>
      <param name="nolines" value="true"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_03.png" ftype="png" compare="image_diff"/>
    </test>

    <!-- Test 4: with normalization, Others and non assigned --> 
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="x" value="Sample"/>
      <param name="fill" value="Genus"/>
      <param name="facet" value=""/>
      <param name="topX" value="10"/>
      <param name="normalize" value="true"/>
      <param name="keepOthers" value="true"/>
      <param name="keepNonAssigned" value="true"/>
      <param name="nolines" value="false"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_04.png" ftype="png" compare="image_diff"/>
    </test>

    <!-- Test 5: with normalization, Others and non assigned, normalization x --> 
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="x" value="Property"/>
      <param name="fill" value="Genus"/>
      <param name="facet" value=""/>
      <param name="topX" value="10"/>
      <param name="normalize" value="true"/>
      <param name="keepOthers" value="true"/>
      <param name="keepNonAssigned" value="true"/>
      <param name="normalize_x" value="true"/>
      <param name="nolines" value="false"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_05.png" ftype="png" compare="image_diff"/>
    </test>

    <!-- Test 6: Minimal -->
    <test>
      <param name="input" value="output.phyloseq" ftype="phyloseq"/>
      <param name="device" value="png"/>
      <output name="output" file="expected_output_06.png" ftype="png" compare="image_diff"/>
    </test>

  </tests>

<help>
<![CDATA[
**Description**

This tool generates bar charts from a phyloseq object using the 'plot_bar' function in R.
It allows filtering, normalization, and customization of plots for visualizing microbial community composition.

**Inputs**

- **Input**: A phyloseq object in RDS format.

- **X-axis variable**: The variable to use for the x-axis (Metadata columns).

- **Fill variable**: (Optional) The variable to use for the bar fill colors (e.g., Genus, Species).

- **Facet by variable**: (Optional) A variable to facet the bar chart (e.g., SampleType).

- **Top X**: Display only the top X most abundant taxa.

- **Keep 'Others'**: Group non-top taxa as 'Others'.

- **Keep 'Not Assigned'**: Retain unassigned taxa labeled as 'Not Assigned'.

- **Normalize**: Normalize abundances to sum to 100%.

- **Remove Separation Lines**: Do not add OTU separation lines in the bars.

- **Width and Height**: Dimensions of the plot in inches (default: 10x8).

- **Device**: Output format (e.g., pdf, png, jpg, tiff).

**Outputs**

- A file containing the bar chart in the specified format.

**Usage Notes**

Ensure that the input file is a valid phyloseq object in RDS format.

**Examples**

- *Basic Bar Plot with Others and Not Assigned and with separation lines*

  .. image:: $PATH_TO_IMAGES/standard_plot.png  
     :width: 515  
     :height: 395  

- *Faceted Plot*

  .. image:: $PATH_TO_IMAGES/facet_plot.png  
     :width: 515  
     :height: 395  

- *ASV as fill input and removed separation lines*

  .. image:: $PATH_TO_IMAGES/asv_fill_plot.png  
     :width: 515  
     :height: 395  
]]>
</help>

  <expand macro="citations"/>
</tool>