view seaborn.xml @ 0:293a939f28c8 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/seaborn commit 24dc6373560bd5e409fca84154634f5a528001c3
author iuc
date Wed, 14 May 2025 08:39:42 +0000
parents
children
line wrap: on
line source

<tool id="seaborn" name="seaborn" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0" license="MIT">
    <description>generate various plots using seaborn</description>

    <macros>
        <import>macros.xml</import>
    </macros>

    <expand macro="edam"/>
    <expand macro="requirements"/>
    <expand macro="creator" />

    <command detect_errors="exit_code"><![CDATA[
        python3 '${run_script}'
    ]]></command>

    <configfiles>
        <configfile name="run_script"><![CDATA[
index_col = False

@INIT@

plot = $plot

fig = plot(
    data,
    #if $xcol
    x = data.columns.values[$xcol - 1],
    #end if
    #if $ycol
    y = data.columns.values[$ycol - 1],
    #end if
    #if $hue
    hue = data.columns.values[$hue - 1],
    #end if
    #if $col
    col = data.columns.values[$col - 1],
    #end if
    #if $row
    row = data.columns.values[$row - 1],
    #end if
    #if $legend
    legend = $legend,
    #end if
    #if $kind
    kind = '$kind'
    #end if
)

#if $legend_pos
plt.legend(loc='$legend_pos')
#end if

plt.savefig(f"{output_file}", format=output_format, dpi=300)
        ]]></configfile>
    </configfiles>
    <inputs>
        <expand macro="inputs"/>
        <expand macro="transformation"/>

        <param name="plot" type="select" label="Plot to choose from seaborn" help="Select the type of plot you want to generate using seaborn. Each option corresponds to a specific seaborn plotting function.">
            <option value="sns.scatterplot">scatterplot</option>
            <option value="sns.displot">displot</option>
            <option value="sns.jointplot">jointplot</option>
            <option value="sns.barplot">barplot</option>
            <option value="sns.boxplot">boxplot</option>
            <option value="sns.violinplot">violinplot</option>
            <option value="sns.lmplot">lmplot</option>
            <option value="sns.histplot">histplot</option>
        </param>

        <conditional name="header">
            <param name="has_header" type="select" display="radio" label="Does your table have a header?" help="Specify whether the input data contains a header row. If yes, column names will be used for selection." refresh_on_change="true">
                <option value="yes" selected="true">yes</option>
                <option value="no">no</option>
            </param>
            <when value="yes">
                <expand macro="columns" header="true" />
            </when>
            <when value="no">
                <expand macro="columns" header="false" />
            </when>
        </conditional>

        <section name="advanced" title="Advanced Options">
            <param name="kind" type="select" label="Kind specification" optional="true" help="Specify the kind of plot to generate for multi-plot functions like `sns.relplot` or `sns.catplot`.">
                <option value="hist">hist</option>
                <option value="kde">kde</option>
                <option value="reg">reg</option>
                <option value="scatter">scatter</option>
                <option value="hex">hex</option>
                <option value="resid">resid</option>
                <option value="ecdf">ecdf</option>
            </param>
            <param name="legend" type="select" label="Legend" help="Specify the type of legend to display on the plot. Options include 'auto', 'brief', 'full', or None to disable the legend." optional="true">
                <option value="'auto'">auto</option>
                <option value="'brief'">brief</option>
                <option value="'full'">full</option>
                <option value="False">none</option>
                <sanitizer invalid_char="">
                    <valid initial="string.ascii_letters">
                        <add value="'" />
                    </valid>
                </sanitizer>
            </param>
            <param name="legend_pos" type="select" optional="true" label="Legend position" help="Choose the position of the legend on the plot. Options include various corners and sides of the plot.">
                <option value="center right">center right</option>
                <option value="center left">center left</option>
                <option value="upper right">upper right</option>
                <option value="upper left">upper left</option>
                <option value="lower right">lower right</option>
                <option value="lower left">lower left</option>
            </param>
        </section>
    </inputs>
    <outputs>
        <data name="output_file" format="png" label="${tool.name} ${plot} of ${on_string}" />
    </outputs>
    <tests>
        <!-- Test 1: Generate a scatterplot -->
        <test>
            <param name="input_data" value="mtcars.txt"/>
            <param name="plot" value="sns.scatterplot" />
            <conditional name="header">
                <param name="has_header" value="yes" />
                <param name="xcol" value="2" /> <!-- Column 2: mpg -->
                <param name="ycol" value="3" /> <!-- Column 3: cyl -->
            </conditional>
            <output name="output_file">
                <assert_contents>
                    <has_image_channels channels="4"/>
                    <has_image_height height="1440"/>
                    <has_image_width width="1920" />
                    <has_image_center_of_mass center_of_mass="960.65, 718.85" eps="0.1"/>
                </assert_contents>
            </output>
        </test>

        <!-- Test 2: Generate a barplot -->
        <test>
            <param name="input_data" value="mtcars.txt"/>
            <param name="plot" value="sns.barplot" />
            <conditional name="header">
                <param name="has_header" value="yes" />
                <param name="xcol" value="3" /> <!-- Column 3: cyl -->
                <param name="ycol" value="2" /> <!-- Column 2: mpg -->
            </conditional>
            <output name="output_file">
                <assert_contents>
                    <has_image_channels channels="4"/>
                    <has_image_height height="1440"/>
                    <has_image_width width="1920" />
                    <has_image_center_of_mass center_of_mass="971.48, 692.18" eps="0.2"/>
                </assert_contents>
            </output>
        </test>

        <!-- Test 3: Generate a boxplot with hue -->
        <test>
            <param name="input_data" value="mtcars.txt"/>
            <param name="plot" value="sns.boxplot" />
            <conditional name="header">
                <param name="has_header" value="yes" />
                <param name="xcol" value="3" /> <!-- Column 3: cyl -->
                <param name="ycol" value="2" /> <!-- Column 2: mpg -->
                <section name="advanced_input">
                    <param name="hue" value="4" /> <!-- Column 4: disp -->
                </section>
            </conditional>
            <output name="output_file">
                <assert_contents>
                    <has_image_channels channels="4"/>
                    <has_image_height height="1440"/>
                    <has_image_width width="1920" />
                    <has_image_center_of_mass center_of_mass="957.48, 720.14" eps="0.1"/>
                </assert_contents>
            </output>
        </test>

        <!-- Test 4: Generate a violinplot with advanced options -->
        <test>
            <param name="input_data" value="mtcars.txt"/>
            <param name="plot" value="sns.violinplot" />
            <conditional name="header">
                <param name="has_header" value="yes" />
                <param name="xcol" value="3" /> <!-- Column 3: cyl -->
                <param name="ycol" value="2" /> <!-- Column 2: mpg -->
            </conditional>
            <section name="advanced">
                <param name="legend" value="'brief'" />
                <param name="legend_pos" value="upper right" />
            </section>
            <output name="output_file">
                <assert_contents>
                    <has_image_channels channels="4"/>
                    <has_image_height height="1440"/>
                    <has_image_width width="1920" />
                    <has_image_center_of_mass center_of_mass="959.80, 716.27" eps="0.1"/>
                </assert_contents>
            </output>
        </test>

        <!-- Test 5: Generate a lmplot with hue -->
        <test>
            <param name="input_data" value="mtcars.txt"/>
            <param name="plot" value="sns.boxplot" />
            <conditional name="header">
                <param name="has_header" value="yes" />
                <param name="xcol" value="2" /> <!-- Column 2: mpg -->
                <param name="ycol" value="5" /> <!-- Column 5: hp -->
                <section name="advanced_input">
                    <param name="hue" value="3" /> <!-- Column 3: cyl -->
                </section>
            </conditional>
            <output name="output_file">
                <assert_contents>
                    <has_image_channels channels="4"/>
                    <has_image_height height="1440"/>
                    <has_image_width width="1920" />
                    <has_image_center_of_mass center_of_mass="958.93, 716.80" eps="0.1"/>
                </assert_contents>
            </output>
        </test>

    </tests>
    <help><![CDATA[
.. class:: infomark

**What it does**

This tool allows you to generate a variety of plots using the Seaborn library, a Python data visualization library based on Matplotlib. It supports multiple plot types, including scatter plots, bar plots, box plots, and more. The tool is designed to work with tabular data in formats such as TSV, CSV, TXT, or Parquet.

Seaborn provides a high-level interface for drawing attractive and informative statistical graphics. This tool integrates Seaborn's functionality into Galaxy, enabling users to create publication-quality plots without requiring programming knowledge.

**Usage**

1. **Input**: Provide a tabular data file in one of the supported formats (TSV, CSV, TXT, or Parquet).
2. **Plot Type**: Choose the type of plot you want to generate (e.g., scatterplot, barplot, boxplot).
3. **Advanced Options**: Customize the plot further by specifying parameters such as legend type, legend position, and data transformations.
4. **Output**: The tool generates a PNG image of the plot, which can be downloaded or used in further analyses.

**Example Input**

Here is an example of a simple input dataset:

+------------+------------+------------+
| Category   | Value1     | Value2     |
+============+============+============+
| A          | 10         | 20         |
+------------+------------+------------+
| B          | 15         | 25         |
+------------+------------+------------+
| C          | 20         | 30         |
+------------+------------+------------+

**Example Output**

If you select a scatterplot with `Value1` on the x-axis and `Value2` on the y-axis, the tool will generate a scatterplot visualizing the relationship between these two variables.

**Parameters**

- **Input Data Table**: Upload your data file in TSV, CSV, TXT, or Parquet format.
- **Plot Type**: Select the type of plot to generate (e.g., scatterplot, barplot, etc.).
- **Legend**: Specify the type of legend to display (e.g., auto, brief, full, or None).
- **Legend Position**: Choose the position of the legend on the plot (e.g., upper right, lower left, etc.).
- **Data Transformation**: Apply transformations such as log10 or log2 to numerical data.

**Links**

- For more information about Seaborn, visit the official documentation: https://seaborn.pydata.org/
- For detailed parameter descriptions, refer to the Galaxy tool documentation.

**Output**

The tool generates a PNG file containing the plot. The file can be downloaded or used as input for other tools in Galaxy.

    ]]></help>
    <expand macro="citation"/>
</tool>