diff ggplot_point.xml @ 0:1bff6682e780 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ggplot2 commit 6e466ce83e2e5c0dd0ba30356d0488cf74574b8f
author iuc
date Tue, 22 Aug 2017 06:42:21 -0400
parents
children 9a482995958c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ggplot_point.xml	Tue Aug 22 06:42:21 2017 -0400
@@ -0,0 +1,232 @@
+<tool id="ggplot2_point" name="Scatterplot w ggplot2" version="@VERSION@">
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="requirements"></expand>
+    <command detect_errors="exit_code"><![CDATA[
+cat '$script' &&
+Rscript '$script' &&
+mv output_plot.pdf $output1
+    ]]></command>
+    <configfiles>
+        <configfile name="script"><![CDATA[
+
+@R_INIT@
+
+## Import library
+library("ggplot2")
+
+@XY_SCALING@
+
+## Choose theme for plot
+#if $theme == "bw"
+    gg_theme = theme_bw()
+#else
+    gg_theme = NULL
+#end if
+
+gg_width = $with_output_dim
+gg_height = $height_output_dim
+
+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 $factor.factoring == "Multiple"
+     gg_facet = facet_wrap( ~ factor)
+     gg_factor = NULL
+     color_scale = NULL
+     #if $points.pointoptions == "Default"
+        gg_point = geom_point(size=1, alpha=1, gg_factor)
+     #else
+        gg_point = geom_point(size='$points.size', alpha='$points.alpha', colour='$points.pointcolor')
+     #end if
+
+    names(input)[$factor.factorcol] <- "factor"
+
+#elif $factor.factoring == "Single"
+    gg_facet = NULL
+    gg_factor = aes(colour=factor(factor))
+
+        #if $points.pointoptions == "default"
+            gg_point = geom_point(size=1, alpha=1, gg_factor)
+        #else
+            gg_point = geom_point(size=$points.size, alpha='$points.alpha', gg_factor)
+        #end if
+
+      #if $colors == "Default"
+          color_scale = scale_colour_hue(direction='$factor.colororder')
+      #else
+          color_scale = scale_color_brewer(palette='$colors', direction='$factor.colororder')
+      #end if
+
+    names(input)[$factor.factorcol] <- "factor"
+#else
+      gg_facet = NULL
+      gg_factor = NULL
+      color_scale = NULL
+
+        #if $points.pointoptions == "default"
+            gg_point = geom_point(size=1, alpha=1, gg_factor)
+        #else
+            gg_point = geom_point(size=$points.size, alpha='$points.alpha', colour='$points.pointcolor')
+        #end if
+#end if
+
+@TRANSFORM@
+
+##axis label custization
+#if $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 = '$color', size = '$size', face = '$face'))
+#end if
+
+
+##axis text(tick) custization
+#if $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 = '$color', size = '$size', face = '$face'))
+#end if
+
+##plot title custimization
+#if $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='$color', size='$size', face='$face'))
+#end if
+
+
+
+## grid line customization
+#if $gridlinecust == "default"
+    gg_gridline = NULL
+#elif $gridlinecust == "hidemajor"
+    gg_gridline = theme(panel.grid.major = element_blank())
+#elif $gridlinecust == "hideminor"
+    gg_gridline = theme(panel.grid.minor = element_blank())
+#elif $gridlinecust == "hideboth"
+    gg_gridline = theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank())
+#end if
+
+#this is the actual ggplot command to make the final plot(s)
+ggplot(input, aes(xcol,ycol)) + gg_point + gg_facet+
+gg_theme + gg_scalex + gg_scaley + color_scale + ggtitle('$title') + xlab('$xlab') + ylab('$ylab')+
+gg_axistitle + gg_axistext + gg_plottitle + gg_gridline
+
+ggsave(file='output_plot.pdf', width=gg_width, height=gg_height)
+dev.off()
+        ]]></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" />
+
+        <conditional name="points">
+            <param name="pointoptions" type="select" label="Advanced - 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="Advanced - 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>
+        <expand macro="transform" />
+
+        <expand macro="xy_scaling" />
+
+        <param name="theme" type="select" label="Advanced - backgound theme for plot">
+          <option value="bw">Black and white</option>
+          <option value="Default">Default (grey)</option>
+        </param>
+
+        <conditional name="axis_title_customization">
+            <expand macro="axis_customization" label="Advanced - axis title options" />
+        </conditional>
+        <conditional name="axis_text_customization">
+            <expand macro="axis_customization" label="Advanced - axis text options" />
+        </conditional>
+        <conditional name="plot_title_customization">
+            <expand macro="axis_customization" label="Advanced - Plot title options" />
+        </conditional>
+        <param name="gridlinecust" type="select" label="Advanced - 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="dimensions" />
+    </inputs>
+    <outputs>
+        <!-- <data name="output1" format="png" from_work_dir="Rplot.png"/>
+            ToDo: It would be nice to have different output formats for all tools
+        -->
+        <data name="output1" format="pdf" from_work_dir="Rplot.pdf"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input1" value="mtcars.txt" ftype="tabular" />
+            <output name="output1" 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>