comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:1bff6682e780
1 <tool id="ggplot2_point" name="Scatterplot w ggplot2" version="@VERSION@">
2 <macros>
3 <import>macros.xml</import>
4 </macros>
5 <expand macro="requirements"></expand>
6 <command detect_errors="exit_code"><![CDATA[
7 cat '$script' &&
8 Rscript '$script' &&
9 mv output_plot.pdf $output1
10 ]]></command>
11 <configfiles>
12 <configfile name="script"><![CDATA[
13
14 @R_INIT@
15
16 ## Import library
17 library("ggplot2")
18
19 @XY_SCALING@
20
21 ## Choose theme for plot
22 #if $theme == "bw"
23 gg_theme = theme_bw()
24 #else
25 gg_theme = NULL
26 #end if
27
28 gg_width = $with_output_dim
29 gg_height = $height_output_dim
30
31 input <- read.csv('$input1', sep='\t', header=TRUE)
32
33 ## renaming columns so ggplot can use them
34 names(input)[$xplot] <- "xcol"
35 names(input)[$yplot] <- "ycol"
36
37 ## choosing whether to plot data as multiple groups on one plot(factoring) OR multiple groups on different plots
38 #if $factor.factoring == "Multiple"
39 gg_facet = facet_wrap( ~ factor)
40 gg_factor = NULL
41 color_scale = NULL
42 #if $points.pointoptions == "Default"
43 gg_point = geom_point(size=1, alpha=1, gg_factor)
44 #else
45 gg_point = geom_point(size='$points.size', alpha='$points.alpha', colour='$points.pointcolor')
46 #end if
47
48 names(input)[$factor.factorcol] <- "factor"
49
50 #elif $factor.factoring == "Single"
51 gg_facet = NULL
52 gg_factor = aes(colour=factor(factor))
53
54 #if $points.pointoptions == "default"
55 gg_point = geom_point(size=1, alpha=1, gg_factor)
56 #else
57 gg_point = geom_point(size=$points.size, alpha='$points.alpha', gg_factor)
58 #end if
59
60 #if $colors == "Default"
61 color_scale = scale_colour_hue(direction='$factor.colororder')
62 #else
63 color_scale = scale_color_brewer(palette='$colors', direction='$factor.colororder')
64 #end if
65
66 names(input)[$factor.factorcol] <- "factor"
67 #else
68 gg_facet = NULL
69 gg_factor = NULL
70 color_scale = NULL
71
72 #if $points.pointoptions == "default"
73 gg_point = geom_point(size=1, alpha=1, gg_factor)
74 #else
75 gg_point = geom_point(size=$points.size, alpha='$points.alpha', colour='$points.pointcolor')
76 #end if
77 #end if
78
79 @TRANSFORM@
80
81 ##axis label custization
82 #if $axis_title_customization.axis_customization == "default"
83 gg_axistitle = theme(axis.title = element_text(color = NULL, size = NULL, face = NULL))
84 #else
85 gg_axistitle = theme(axis.title = element_text(color = '$color', size = '$size', face = '$face'))
86 #end if
87
88
89 ##axis text(tick) custization
90 #if $axis_text_customization.axis_customization == "default"
91 gg_axistext = theme(axis.text = element_text(color = NULL, size = NULL, face = NULL))
92 #else
93 gg_axistext = theme(axis.text = element_text(color = '$color', size = '$size', face = '$face'))
94 #end if
95
96 ##plot title custimization
97 #if $plot_title_customization.axis_customization == "default"
98 gg_plottitle = theme(plot.title = element_text(color = NULL, size = NULL, face = NULL))
99 #else
100 gg_plottitle = theme(plot.title = element_text(color='$color', size='$size', face='$face'))
101 #end if
102
103
104
105 ## grid line customization
106 #if $gridlinecust == "default"
107 gg_gridline = NULL
108 #elif $gridlinecust == "hidemajor"
109 gg_gridline = theme(panel.grid.major = element_blank())
110 #elif $gridlinecust == "hideminor"
111 gg_gridline = theme(panel.grid.minor = element_blank())
112 #elif $gridlinecust == "hideboth"
113 gg_gridline = theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank())
114 #end if
115
116 #this is the actual ggplot command to make the final plot(s)
117 ggplot(input, aes(xcol,ycol)) + gg_point + gg_facet+
118 gg_theme + gg_scalex + gg_scaley + color_scale + ggtitle('$title') + xlab('$xlab') + ylab('$ylab')+
119 gg_axistitle + gg_axistext + gg_plottitle + gg_gridline
120
121 ggsave(file='output_plot.pdf', width=gg_width, height=gg_height)
122 dev.off()
123 ]]></configfile>
124 </configfiles>
125 <inputs>
126 <param name="input1" type="data" format="tabular" label="Input in tabular format" />
127 <param name="xplot" type="integer" value="8" label="Column to plot on x-axis" />
128 <param name="yplot" type="integer" value="9" label="Column to plot on y-axis" />
129
130 <expand macro="title" />
131 <expand macro="xy_lab" />
132
133 <conditional name="points">
134 <param name="pointoptions" type="select" label="Advanced - data point options">
135 <option value="default" selected="True">Default</option>
136 <option value="defined">User defined point options</option>
137 </param>
138 <when value="default">
139 <!--Do nothing here -->
140 </when>
141 <when value="defined">
142 <param name="size" type="float" value="1" label="relative size of points" />
143 <param name="alpha" type="float" value="1" label="Transparency of points (On a scale of 0-1; 0=transparent, 1=default)" />
144 <param name="pointcolor" type="select" label="Color of data points" >
145 <option value="black">Black (default)</option>
146 <option value="red">Red</option>
147 <option value="white">White</option>
148 <option value="blue">Blue</option>
149 <option value="orange">Orange</option>
150 <option value="yellow">Yellow</option>
151 <option value="green">Green</option>
152 <option value="purple">Purple</option>
153 <option value="magenta">Magenta</option>
154 <option value="cyan">Cyan</option>
155 <option value="grey">Grey</option>
156 <option value="gold">Gold</option>
157 </param>
158 </when>
159 </conditional>
160 <conditional name="factor">
161 <param name="factoring" type="select" label="Advanced - plotting multiple groups" >
162 <option value="Default" selected="True">No thanks - just plot the data as one group</option>
163 <option value="Single">Plot multiple groups of data on one plot</option>
164 <option value="Multiple">Plot multiple groups of data on individual plots</option>
165 </param>
166 <when value="Default">
167 <!--Do nothing here -->
168 </when>
169 <when value="Single">
170 <param name="factorcol" type="integer" value="1" label="column differentiating the different groups" />
171 <expand macro="colors" />
172 <param name="colororder" type="select" label="Reverse color scheme" >
173 <option value="1">Default order of color scheme</option>
174 <option value="-1">Reverse the order of my color scheme</option>
175 </param>
176 </when>
177 <when value="Multiple">
178 <param name="factorcol" type="integer" value="1" label="column differentiating the different groups" />
179 </when>
180 </conditional>
181 <expand macro="transform" />
182
183 <expand macro="xy_scaling" />
184
185 <param name="theme" type="select" label="Advanced - backgound theme for plot">
186 <option value="bw">Black and white</option>
187 <option value="Default">Default (grey)</option>
188 </param>
189
190 <conditional name="axis_title_customization">
191 <expand macro="axis_customization" label="Advanced - axis title options" />
192 </conditional>
193 <conditional name="axis_text_customization">
194 <expand macro="axis_customization" label="Advanced - axis text options" />
195 </conditional>
196 <conditional name="plot_title_customization">
197 <expand macro="axis_customization" label="Advanced - Plot title options" />
198 </conditional>
199 <param name="gridlinecust" type="select" label="Advanced - grid lines">
200 <option value="default">Default grid lines</option>
201 <option value="hidemajor">Hide major grid lines</option>
202 <option value="hideminor">Hide minor grid lines</option>
203 <option value="hideboth">Hide major and minor grid lines</option>
204 </param>
205 <expand macro="dimensions" />
206 </inputs>
207 <outputs>
208 <!-- <data name="output1" format="png" from_work_dir="Rplot.png"/>
209 ToDo: It would be nice to have different output formats for all tools
210 -->
211 <data name="output1" format="pdf" from_work_dir="Rplot.pdf"/>
212 </outputs>
213 <tests>
214 <test>
215 <param name="input1" value="mtcars.txt" ftype="tabular" />
216 <output name="output1" file="ggplot_point_result1.pdf" compare="sim_size" />
217 </test>
218 </tests>
219 <help><![CDATA[
220 This tool will generate a scatterplot representing data from two groups/conditions.
221
222 The input data should be in tabular format and the user can determine which groups (columns) to plot.
223
224 Multiple groups can be plotted on the same or multiple plots by providing a column with a group identifier under "Advanced - plotting multiple groups".
225
226 Feel free to explore the (many) advanced options to customize your plot. Galaxy makes this type optimization easy for the user!
227
228 The ouput is a pdf file with your scatterplot. The dimensions of this file can be modified under "Advanced - output dimensions"
229
230 ]]></help>
231 <expand macro="citations"/>
232 </tool>