view ggplot_point.xml @ 5:9cec81e1b90e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ggplot2 commit a2b0aa23d09e06fa6f81ce4f7987b144e91537d9
author iuc
date Fri, 29 Mar 2019 12:04:59 -0400
parents 52b8083a6159
children 87908c76ca8d
line wrap: on
line source

<tool id="ggplot2_point" name="Scatterplot w ggplot2" version="@VERSION@+galaxy1">
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements">
        <requirement type="package" version="1.2.1">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.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.points.size', alpha='$adv.points.alpha', colour='$adv.points.pointcolor')
        gg_line = geom_line(size='$adv.points.size', alpha='$adv.points.alpha', colour='$adv.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.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.points.size, alpha='$adv.points.alpha', gg_factor)
        gg_line = geom_line(size=$adv.points.size, alpha='$adv.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.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.points.size, alpha='$adv.points.alpha', colour='$adv.points.pointcolor')
        gg_line = geom_line(size=$adv.points.size, alpha='$adv.points.alpha', colour='$adv.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.color', size = '$adv.size', face = '$adv.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.color', size = '$adv.size', face = '$adv.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.color', size='$adv.size', face='$adv.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 == "points"
    gg_line = NULL
#elif $adv.type == "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" expanded="false">
            <param name="type" 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>
            <conditional name="points">
                <param name="pointoptions" type="select" label="Data point options">
                    <option value="default" selected="true">Default</option>
                    <option value="defined">User defined point options</option>
                </param>
                <when value="default">
                    <!--Do nothing here -->
                </when>
                <when value="defined">
                    <param name="size" type="float" value="1" label="relative size of points" />
                    <param name="alpha" type="float" value="1" label="Transparency of points (On a scale of 0-1; 0=transparent, 1=default)" />
                    <param name="pointcolor" type="select" label="Color of data points" >
                        <option value="black">Black (default)</option>
                        <option value="red">Red</option>
                        <option value="white">White</option>
                        <option value="blue">Blue</option>
                        <option value="orange">Orange</option>
                        <option value="yellow">Yellow</option>
                        <option value="green">Green</option>
                        <option value="purple">Purple</option>
                        <option value="magenta">Magenta</option>
                        <option value="cyan">Cyan</option>
                        <option value="grey">Grey</option>
                        <option value="gold">Gold</option>
                    </param>
                </when>
            </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>
    </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>