0
|
1 <tool id="XY_Plot_1_multiformat" name="Plotting tool" version="1.0.1">
|
|
2 <description>for multiple series and graph types and multiple output types</description>
|
|
3 <requirements>
|
|
4 <requirement type="package" version="3.2.1">R</requirement>
|
|
5 <requirement type="package" version="2.11.1">fontconfig</requirement>
|
|
6 </requirements>
|
|
7 <command interpreter="bash">r_wrapper.sh $script_file</command>
|
|
8
|
|
9 <inputs>
|
|
10 <param name="main" type="text" value="" label="Plot Title"/>
|
|
11 <param name="xlab" type="text" value="" label="Label for x axis"/>
|
|
12 <param name="ylab" type="text" value="" label="Label for y axis"/>
|
|
13 <param name="ftype" type="select" label="File Type">
|
|
14 <option value="pdf">PDF</option>
|
|
15 <option value="png">PNG</option>
|
|
16 <option value="jpeg">JPEG</option>
|
|
17 <option value="bmp">BMP</option>
|
|
18 <option value="tiff">TIFF</option>
|
|
19 </param>
|
|
20 <repeat name="series" title="Series">
|
|
21 <param name="input" type="data" format="tabular" label="Dataset"/>
|
|
22 <param name="xcol" type="data_column" data_ref="input" label="Column for x axis"/>
|
|
23 <param name="ycol" type="data_column" data_ref="input" label="Column for y axis"/>
|
|
24 <conditional name="series_type">
|
|
25 <param name="type" type="select" label="Series Type">
|
|
26 <option value="line" selected="true">Line</option>
|
|
27 <option value="points">Points</option>
|
|
28 </param>
|
|
29 <when value="line">
|
|
30 <param name="lty" type="select" label="Line Type">
|
|
31 <option value="1">Solid</option>
|
|
32 <option value="2">Dashed</option>
|
|
33 <option value="3">Dotted</option>
|
|
34 </param>
|
|
35 <param name="col" type="select" label="Line Color">
|
|
36 <option value="1">Black</option>
|
|
37 <option value="2">Red</option>
|
|
38 <option value="3">Green</option>
|
|
39 <option value="4">Blue</option>
|
|
40 <option value="5">Cyan</option>
|
|
41 <option value="6">Magenta</option>
|
|
42 <option value="7">Yellow</option>
|
|
43 <option value="8">Gray</option>
|
|
44 </param>
|
|
45 <param name="lwd" type="float" label="Line Width" value="1.0"/>
|
|
46 </when>
|
|
47 <when value="points">
|
|
48 <param name="pch" type="select" label="Point Type">
|
|
49 <option value="1">Circle (hollow)</option>
|
|
50 <option value="2">Triangle (hollow)</option>
|
|
51 <option value="3">Cross</option>
|
|
52 <option value="4">Diamond (hollow)</option>
|
|
53 <option value="15">Square (filled)</option>
|
|
54 <option value="16">Circle (filled)</option>
|
|
55 <option value="17">Triangle (filled)</option>
|
|
56 </param>
|
|
57 <param name="col" type="select" label="Point Color">
|
|
58 <option value="1">Black</option>
|
|
59 <option value="2">Red</option>
|
|
60 <option value="3">Green</option>
|
|
61 <option value="4">Blue</option>
|
|
62 <option value="5">Cyan</option>
|
|
63 <option value="6">Magenta</option>
|
|
64 <option value="7">Yellow</option>
|
|
65 <option value="8">Gray</option>
|
|
66 </param>
|
|
67 <param name="cex" type="float" label="Point Scale" value="1.0"/>
|
|
68 </when>
|
|
69 </conditional>
|
|
70 </repeat>
|
|
71 </inputs>
|
|
72
|
|
73 <configfiles>
|
|
74 <configfile name="script_file">
|
|
75 ## Setup R error handling to go to stderr
|
|
76 options( show.error.messages=F,
|
|
77 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
|
|
78 ## Determine range of all series in the plot
|
|
79 xrange = c( NULL, NULL )
|
|
80 yrange = c( NULL, NULL )
|
|
81 #for $i, $s in enumerate( $series )
|
|
82 s${i} = read.table( "${s.input.file_name}" )
|
|
83 x${i} = s${i}[,${s.xcol}]
|
|
84 y${i} = s${i}[,${s.ycol}]
|
|
85 xrange = range( x${i}, xrange )
|
|
86 yrange = range( y${i}, yrange )
|
|
87 #end for
|
|
88 ## Open output PDF file
|
|
89 #if $ftype.value == "pdf"
|
|
90 pdf("outfile.pdf")
|
|
91 #else
|
|
92 "${ftype}"( "outfile.${ftype}" , type="cairo")
|
|
93 #end if
|
|
94 ## Dummy plot for axis / labels
|
|
95 plot( NULL, type="n", xlim=xrange, ylim=yrange, main="${main}", xlab="${xlab}", ylab="${ylab}" )
|
|
96 ## Plot each series
|
|
97 #for $i, $s in enumerate( $series )
|
|
98 #if $s.series_type['type'] == "line"
|
|
99 lines( x${i}, y${i}, lty=${s.series_type.lty}, lwd=${s.series_type.lwd}, col=${s.series_type.col} )
|
|
100 #elif $s.series_type.type == "points"
|
|
101 points( x${i}, y${i}, pch=${s.series_type.pch}, cex=${s.series_type.cex}, col=${s.series_type.col} )
|
|
102 #end if
|
|
103 #end for
|
|
104 ## Close the PDF file
|
|
105 devname = dev.off()
|
|
106 </configfile>
|
|
107 </configfiles>
|
|
108
|
|
109 <outputs>
|
|
110 <data format="pdf" name="out_file1" from_work_dir="outfile.pdf" >
|
|
111 <filter>(ftype == 'pdf') </filter>
|
|
112 </data>
|
|
113 <data format="png" name="out_file2" from_work_dir="outfile.png">
|
|
114 <filter>(ftype == 'png') </filter>
|
|
115 </data>
|
|
116 <data format="jpg" name="out_file3" from_work_dir="outfile.jpeg">
|
|
117 <filter>(ftype == 'jpeg') </filter>
|
|
118 </data>
|
|
119 <data format="bmp" name="out_file4" from_work_dir="outfile.bmp">
|
|
120 <filter>(ftype == 'bmp') </filter>
|
|
121 </data>
|
|
122 <data format="tiff" name="out_file5" from_work_dir="outfile.tiff">
|
|
123 <filter>(ftype == 'tiff') </filter>
|
|
124 </data>
|
|
125 </outputs>
|
|
126
|
|
127 <tests>
|
|
128 <test>
|
|
129 <param name="main" value="Example XY Plot PDF"/>
|
|
130 <param name="xlab" value="Column 1"/>
|
|
131 <param name="ylab" value="Column 2"/>
|
|
132 <param name="ftype" value="pdf"/>
|
|
133 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
134 <param name="xcol" value="1"/>
|
|
135 <param name="ycol" value="2"/>
|
|
136 <param name="type" value="line"/>
|
|
137 <param name="lty" value="2"/>
|
|
138 <param name="col" value="2"/>
|
|
139 <param name="lwd" value="1.0"/>
|
|
140 <output name="out_file1" file="XY_Plot_1_multi_out.pdf" format="pdf" />
|
|
141 </test>
|
|
142 <test>
|
|
143 <param name="main" value="Example XY Plot PNG"/>
|
|
144 <param name="xlab" value="Column 1"/>
|
|
145 <param name="ylab" value="Column 2"/>
|
|
146 <param name="ftype" value="png"/>
|
|
147 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
148 <param name="xcol" value="1"/>
|
|
149 <param name="ycol" value="2"/>
|
|
150 <param name="type" value="line"/>
|
|
151 <param name="lty" value="2"/>
|
|
152 <param name="col" value="2"/>
|
|
153 <param name="lwd" value="1.0"/>
|
|
154 <output name="out_file2" md5="c2762c725f80fe4419e35768cac5d11b" />
|
|
155 </test>
|
|
156 <test>
|
|
157 <param name="main" value="Example XY Plot JPEG"/>
|
|
158 <param name="xlab" value="Column 1"/>
|
|
159 <param name="ylab" value="Column 2"/>
|
|
160 <param name="ftype" value="jpeg"/>
|
|
161 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
162 <param name="xcol" value="1"/>
|
|
163 <param name="ycol" value="2"/>
|
|
164 <param name="type" value="line"/>
|
|
165 <param name="lty" value="2"/>
|
|
166 <param name="col" value="2"/>
|
|
167 <param name="lwd" value="1.0"/>
|
|
168 <output name="out_file3" md5="5c89f4e87bb5f2a809877b471f9c2d69" />
|
|
169 </test>
|
|
170 <test>
|
|
171 <param name="main" value="Example XY Plot BMP"/>
|
|
172 <param name="xlab" value="Column 1"/>
|
|
173 <param name="ylab" value="Column 2"/>
|
|
174 <param name="ftype" value="bmp"/>
|
|
175 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
176 <param name="xcol" value="1"/>
|
|
177 <param name="ycol" value="2"/>
|
|
178 <param name="type" value="line"/>
|
|
179 <param name="lty" value="2"/>
|
|
180 <param name="col" value="2"/>
|
|
181 <param name="lwd" value="1.0"/>
|
|
182 <output name="out_file4" md5="74ea4b29bd7de44c1b6377c6c26671e7"/>
|
|
183 </test>
|
|
184 <test>
|
|
185 <param name="main" value="Example XY Plot TIFF"/>
|
|
186 <param name="xlab" value="Column 1"/>
|
|
187 <param name="ylab" value="Column 2"/>
|
|
188 <param name="ftype" value="tiff"/>
|
|
189 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
190 <param name="xcol" value="1"/>
|
|
191 <param name="ycol" value="2"/>
|
|
192 <param name="type" value="line"/>
|
|
193 <param name="lty" value="2"/>
|
|
194 <param name="col" value="2"/>
|
|
195 <param name="lwd" value="1.0"/>
|
|
196 <output name="out_file5" md5="7ebf7d201ad9cdf0fc6995639749ae7d"/>
|
|
197 </test>
|
|
198 </tests>
|
|
199 <help>
|
|
200 .. class:: infomark
|
|
201
|
|
202 This tool allows you to plot values contained in columns of a dataset against each other and also allows you to have different series corresponding to the same or different datasets in one plot.
|
|
203
|
|
204 -----
|
|
205
|
|
206 .. class:: warningmark
|
|
207
|
|
208 This tool throws an error if the columns selected for plotting are absent or are not numeric and also if the lengths of these columns differ.
|
|
209
|
|
210 -----
|
|
211
|
|
212 **Example**
|
|
213
|
|
214 Input file::
|
|
215
|
|
216 1 68 4.1
|
|
217 2 71 4.6
|
|
218 3 62 3.8
|
|
219 4 75 4.4
|
|
220 5 58 3.2
|
|
221 6 60 3.1
|
|
222 7 67 3.8
|
|
223 8 68 4.1
|
|
224 9 71 4.3
|
|
225 10 69 3.7
|
|
226
|
|
227 Create a two series XY plot on the above data:
|
|
228
|
|
229 - Series 1: Red Dashed-Line plot between columns 1 and 2
|
|
230 - Series 2: Blue Circular-Point plot between columns 3 and 2
|
|
231
|
|
232 .. image:: xy_example.jpg
|
|
233 </help>
|
|
234 </tool>
|