/
xy_plot.xml
186 lines (174 loc) · 7.38 KB
/
xy_plot.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<tool id="XY_Plot_1" name="Plotting tool" version="1.0.2">
<description>for multiple series and graph types</description>
<requirements>
<requirement type="package" version="3.4.2">r-base</requirement>
</requirements>
<command>Rscript $script_file</command>
<configfiles>
<configfile name="script_file">
## Setup R error handling to go to stderr
options( show.error.messages=F,
error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
## Determine range of all series in the plot
xrange = c( NULL, NULL )
yrange = c( NULL, NULL )
#for $i, $s in enumerate( $series )
s${i} = read.table( "${s.input.file_name}", h=${s.header} )
x${i} = s${i}[,${s.xcol}]
yrange = 0
#for $column in str($s.ycol).split(','):
y${i}${column} = s${i}[,${column}]
yrange = range(y${i}${column}, yrange, na.rm=TRUE )
#end for
xrange = range( x${i}, xrange, na.rm=TRUE )
#end for
## Open output PDF file
#if $outftype.value == "pdf"
pdf("outfile.pdf")
#else
"${outftype}"( "outfile.${outftype}" , type="cairo")
#end if
## Dummy plot for axis / labels
plot( NULL, type="n", xlim=xrange, ylim=yrange, main="${main}", xlab="${xlab}", ylab="${ylab}" )
## Plot each series
#for $i, $s in enumerate( $series )
#if $s.series_type['type'] == "line"
#for $column in str($s.ycol).split(','):
lines( x${i}, y${i}${column}, lty=${s.series_type.lty}, lwd=${s.series_type.lwd}, col=${s.series_type.col} )
#end for
#elif $s.series_type.type == "points"
#for $column in str($s.ycol).split(','):
points( x${i}, y${i}${column}, pch=${s.series_type.pch}, cex=${s.series_type.cex}, col=${s.series_type.col} )
#end for
#end if
#end for
## Close the PDF file
devname = dev.off()
</configfile>
</configfiles>
<inputs>
<param name="main" type="text" value="" label="Plot Title"/>
<param name="xlab" type="text" value="" label="Label for x axis"/>
<param name="ylab" type="text" value="" label="Label for y axis"/>
<param name="outftype" type="select" label="Output File Type">
<option value="pdf">PDF</option>
<option value="png">PNG</option>
</param>
<repeat name="series" title="Series">
<param name="input" type="data" format="tabular" label="Dataset"/>
<param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Header in first line?"/>
<param name="xcol" type="data_column" data_ref="input" label="Column for x axis"/>
<param name="ycol" type="data_column" data_ref="input" multiple="true" label="Column for y axis"/>
<conditional name="series_type">
<param name="type" type="select" label="Series Type">
<option value="line" selected="true">Line</option>
<option value="points">Points</option>
</param>
<when value="line">
<param name="lty" type="select" label="Line Type">
<option value="1">Solid</option>
<option value="2">Dashed</option>
<option value="3">Dotted</option>
</param>
<param name="col" type="select" label="Line Color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Blue</option>
<option value="5">Cyan</option>
<option value="6">Magenta</option>
<option value="7">Yellow</option>
<option value="8">Gray</option>
</param>
<param name="lwd" type="float" label="Line Width" value="1.0"/>
</when>
<when value="points">
<param name="pch" type="select" label="Point Type">
<option value="1">Circle (hollow)</option>
<option value="2">Triangle (hollow)</option>
<option value="3">Cross</option>
<option value="4">Diamond (hollow)</option>
<option value="15">Square (filled)</option>
<option value="16">Circle (filled)</option>
<option value="17">Triangle (filled)</option>
</param>
<param name="col" type="select" label="Point Color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Blue</option>
<option value="5">Cyan</option>
<option value="6">Magenta</option>
<option value="7">Yellow</option>
<option value="8">Gray</option>
</param>
<param name="cex" type="float" label="Point Scale" value="1.0"/>
</when>
</conditional>
</repeat>
</inputs>
<outputs>
<data format="pdf" name="out_file_pdf" from_work_dir="outfile.pdf" >
<filter>(outftype == 'pdf')</filter>
</data>
<data format="png" name="out_file_png" from_work_dir="outfile.png">
<filter>(outftype == 'png')</filter>
</data>
</outputs>
<tests>
<test>
<param name="main" value="Example XY Plot"/>
<param name="xlab" value="Column 1"/>
<param name="ylab" value="Column 2"/>
<param name="outftype" value="pdf"/>
<param name="input" value="2.tabular" ftype="tabular"/>
<param name="xcol" value="1"/>
<param name="ycol" value="2"/>
<param name="type" value="line"/>
<param name="lty" value="2"/>
<param name="col" value="2"/>
<param name="lwd" value="1.0"/>
<output name="out_file_pdf" file="XY_Plot_1_out.pdf" ftype="pdf" compare="sim_size" />
</test>
<test><!-- test with file with header line, NA values, multiple ycols and PNG output -->
<param name="main" value="Example XY Plot PNG"/>
<param name="xlab" value="xlab"/>
<param name="ylab" value="ylab"/>
<param name="outftype" value="png"/>
<param name="series_0|input" value="testinput2.tsv" ftype="tabular"/>
<param name="series_0|header" value="TRUE"/>
<param name="series_0|xcol" value="1"/>
<param name="series_0|ycol" value="2,3"/>
<param name="series_0|type" value="points"/>
<param name="series_0|pch" value="1"/>
<param name="series_0|col" value="2"/>
<param name="series_0|cex" value="1.0"/>
<output name="out_file_png" ftype="png" file="testoutput.png" compare="sim_size" />
</test>
</tests>
<help>
.. class:: infomark
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.
-----
.. class:: warningmark
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.
-----
**Example**
Input file::
1 68 4.1
2 71 4.6
3 62 3.8
4 75 4.4
5 58 3.2
6 60 3.1
7 67 3.8
8 68 4.1
9 71 4.3
10 69 3.7
Create a two series XY plot on the above data:
- Series 1: Red Dashed-Line plot between columns 1 and 2
- Series 2: Blue Circular-Point plot between columns 3 and 2
.. image:: xy_example.jpg
</help>
<citations/>
</tool>