view ggplot_point.xml @ 9:1acf88921176 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ggplot2 commit 4b44f8f834de15fd34e2fdc5e4aed282069f73af"
author iuc
date Tue, 23 Nov 2021 07:58:14 +0000
parents e3a675da7fd0
children 299307abd804
line wrap: on
line source

<tool id="ggplot2_point" name="Scatterplot with ggplot2" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.01">
    <expand macro="bio_tools"/>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements">
        <requirement type="package" version="2.0.0">r-svglite</requirement>
    </expand>
    <command detect_errors="exit_code"><![CDATA[
cat '$script' &&
Rscript '$script'
    ]]></command>
    <configfiles>
        <configfile name="script"><![CDATA[
@R_INIT@

## Import library
library(ggplot2)

@XY_SCALING@

@THEME@

@LEGEND@

input <- read.csv('$input1', sep='\t', header=TRUE)

## renaming columns so ggplot can use them
names(input)[$xplot] <- "xcol"
names(input)[$yplot] <- "ycol"

## choosing whether to plot data as multiple groups on one plot(factoring) OR multiple groups on different plots
#if $adv.factor.factoring == "Multiple"
     gg_facet = facet_wrap( ~ factor)
     gg_factor = NULL
     color_scale = NULL
     #if $adv.type_conditional.points.pointoptions == "default"
        gg_point = geom_point(size=1, alpha=1, gg_factor)
        gg_line = geom_line(size=1, alpha=1, gg_factor)
     #else
        gg_point = geom_point(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, colour='$adv.type_conditional.points.pointcolor')
        gg_line = geom_line(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, colour='$adv.type_conditional.points.pointcolor')
     #end if

    names(input)[$adv.factor.factorcol] <- "factor"

#elif $adv.factor.factoring == "Single"
    gg_facet = NULL
    gg_factor = aes(colour=factor(factor))

    #if $adv.type_conditional.points.pointoptions == "default"
        gg_point = geom_point(size=1, alpha=1, gg_factor)
        gg_line = geom_line(size=1, alpha=1, gg_factor)
    #else
        gg_point = geom_point(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, gg_factor)
        gg_line = geom_line(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, gg_factor)
    #end if

    #if $adv.factor.colororder == 1
        color_scale = scale_colour_hue(direction='$adv.factor.colororder')
    #else
        color_scale = scale_color_brewer(palette='$adv.factor.colors', direction='$adv.factor.colororder')
    #end if

    names(input)[$adv.factor.factorcol] <- "factor"
#else
    gg_facet = NULL
    gg_factor = NULL
    color_scale = NULL

    #if $adv.type_conditional.points.pointoptions == "default"
        gg_point = geom_point(size=1, alpha=1, gg_factor)
        gg_line = geom_line(size=1, alpha=1, gg_factor)
    #else
        gg_point = geom_point(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, colour='$adv.type_conditional.points.pointcolor')
        gg_line = geom_line(size=$adv.type_conditional.points.size, alpha=$adv.type_conditional.points.alpha, colour='$adv.type_conditional.points.pointcolor')
    #end if
#end if

@TRANSFORM@

##axis label custization
#if $adv.axis_title_customization.axis_customization == "default"
    gg_axistitle = theme(axis.title = element_text(color = NULL, size = NULL, face = NULL))
#else
    gg_axistitle = theme(axis.title = element_text(color = '$adv.axis_text_customization.color', size = $adv.axis_text_customization.size, face = '$adv.axis_text_customization.face'))
#end if

##axis text(tick) custization
#if $adv.axis_text_customization.axis_customization == "default"
    gg_axistext = theme(axis.text = element_text(color = NULL, size = NULL, face = NULL))
#else
    gg_axistext = theme(axis.text = element_text(color = '$adv.axis_text_customization.color', size = $adv.axis_text_customization.size, face = '$adv.axis_text_customization.face'))
#end if

##plot title custimization
#if $adv.plot_title_customization.axis_customization == "default"
    gg_plottitle = theme(plot.title = element_text(color = NULL, size = NULL, face = NULL))
#else
    gg_plottitle = theme(plot.title = element_text(color='$adv.axis_text_customization.color', size=$adv.axis_text_customization.size, face='$adv.axis_text_customization.face'))
#end if

## grid line customization
#if $adv.gridlinecust == "default"
    gg_gridline = NULL
#elif $adv.gridlinecust == "hidemajor"
    gg_gridline = theme(panel.grid.major = element_blank())
#elif $adv.gridlinecust == "hideminor"
    gg_gridline = theme(panel.grid.minor = element_blank())
#elif $adv.gridlinecust == "hideboth"
    gg_gridline = theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank())
#end if

## choose between graph types (points/lines/both)
#if $adv.type_conditional.type_options == "points"
    gg_line = NULL
#elif $adv.type_conditional.type_options == "lines"
    gg_point = NULL
#end if

#this is the actual ggplot command to make the final plot(s)
plot_out <- ggplot(input, aes(xcol, ycol)) + gg_point + gg_line + gg_facet +
    gg_theme + gg_scalex + gg_scaley + color_scale + gg_legend + ggtitle('$title') + xlab('$xlab') + ylab('$ylab')+
    gg_axistitle + gg_axistext + gg_plottitle + gg_gridline

@SAVE_OUTPUT@
        ]]></configfile>
    </configfiles>
    <inputs>
        <param name="input1" type="data" format="tabular" label="Input in tabular format" />
        <param name="xplot" type="integer" value="8" label="Column to plot on x-axis" />
        <param name="yplot" type="integer" value="9" label="Column to plot on y-axis" />

        <expand macro="title" />
        <expand macro="xy_lab" />
        <section name="adv" title="Advanced options">
            <conditional name="type_conditional">
                <param name="type_options" type="select" label="Type of plot" >
                        <option value="points">Points only (default)</option>
                        <option value="lines">Lines only </option>
                        <option value="pointslines">Points and Lines</option>
                </param>
                <when value ="points">
                    <expand macro="points_options"/>
                </when>
                <when value="pointslines">
                    <expand macro="points_options"/>
                </when>
                <when value="lines"/>
            </conditional>
            <conditional name="factor">
                <param name="factoring" type="select" label="Plotting multiple groups" >
                    <option value="Default" selected="true">No thanks - just plot the data as one group</option>
                    <option value="Single">Plot multiple groups of data on one plot</option>
                    <option value="Multiple">Plot multiple groups of data on individual plots</option>
                </param>
                <when value="Default">
                    <!--Do nothing here -->
                </when>
                <when value="Single">
                    <param name="factorcol" type="integer" value="1" label="column differentiating the different groups" />
                    <expand macro="colors" />
                    <param name="colororder" type="select" label="Reverse color scheme" >
                        <option value="1">Default order of color scheme</option>
                        <option value="-1">Reverse the order of my color scheme</option>
                    </param>
                </when>
                <when value="Multiple">
                    <param name="factorcol" type="integer" value="1" label="column differentiating the different groups" />
                </when>
            </conditional>
            <conditional name="axis_title_customization">
                <expand macro="axis_customization" label="Axis title options" />
            </conditional>
            <conditional name="axis_text_customization">
                <expand macro="axis_customization" label="Axis text options" />
            </conditional>
            <conditional name="plot_title_customization">
                <expand macro="axis_customization" label="Plot title options" />
            </conditional>
            <param name="gridlinecust" type="select" label="Grid lines">
                <option value="default">Default grid lines</option>
                <option value="hidemajor">Hide major grid lines</option>
                <option value="hideminor">Hide minor grid lines</option>
                <option value="hideboth">Hide major and minor grid lines</option>
            </param>
            <expand macro="transform" />
            <expand macro="xy_scaling" />
            <expand macro="theme" />
            <expand macro="legend" />
        </section>
        <section name="out" title="Output Options" expanded="true">
            <expand macro="dimensions" />
        </section>
    </inputs>
    <outputs>
        <expand macro="additional_output" />
    </outputs>
    <tests>
        <test>
            <param name="input1" value="mtcars.txt" ftype="tabular" />
            <param name="additional_output_format" value="pdf" />
            <output name="output2" file="ggplot_point_result1.pdf" compare="sim_size" />
        </test>
        <!-- Test text options-->
        <test>
            <param name="input1" value="mtcars.txt" ftype="tabular" />
            <section name="adv">
                <conditional name="type_conditional">
                    <param name="type_options" value="points"/>
                    <conditional name="points">
                        <param name="pointoptions" value="default"/>
                    </conditional>
                </conditional>
                <conditional name="axis_text_customization">
                    <param name="axis_customization" value="defined"/>
                    <param name="color" value="red"/>
                </conditional>
            </section>
            <param name="additional_output_format" value="pdf" />
            <output name="output2" file="ggplot_point_result2.pdf" compare="sim_size" />
        </test>
    </tests>
    <help><![CDATA[
This tool will generate a scatterplot representing data from two groups/conditions.

The input data should be in tabular format and the user can determine which groups (columns) to plot.

Multiple groups can be plotted on the same or multiple plots by providing a column with a group identifier under "advanced - plotting multiple groups".

Feel free to explore the (many) advanced options to customize your plot. Galaxy makes this type optimization easy for the user!

The ouput is a pdf file with your scatterplot. The dimensions of this file can be modified under "advanced - output dimensions"
    ]]></help>
    <expand macro="citations"/>
</tool>