comparison ggplot_point.xml @ 2:9a482995958c draft

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