0
|
1 <tool id="XY_Plot_1" name="Plotting tool" version="1.0.1">
|
|
2 <description>for multiple series and graph types</description>
|
|
3 <requirements>
|
|
4 <requirement type="package" version="2.11.0">R</requirement>
|
|
5 </requirements>
|
|
6 <command interpreter="bash">r_wrapper.sh $script_file</command>
|
|
7
|
|
8 <inputs>
|
|
9 <param name="main" type="text" value="" size="30" label="Plot Title"/>
|
|
10 <param name="xlab" type="text" value="" size="30" label="Label for x axis"/>
|
|
11 <param name="ylab" type="text" value="" size="30" label="Label for y axis"/>
|
|
12 <repeat name="series" title="Series">
|
|
13 <param name="input" type="data" format="tabular" label="Dataset"/>
|
|
14 <param name="xcol" type="data_column" data_ref="input" label="Column for x axis"/>
|
|
15 <param name="ycol" type="data_column" data_ref="input" label="Column for y axis"/>
|
|
16 <conditional name="series_type">
|
|
17 <param name="type" type="select" label="Series Type">
|
|
18 <option value="line" selected="true">Line</option>
|
|
19 <option value="points">Points</option>
|
|
20 </param>
|
|
21 <when value="line">
|
|
22 <param name="lty" type="select" label="Line Type">
|
|
23 <option value="1">Solid</option>
|
|
24 <option value="2">Dashed</option>
|
|
25 <option value="3">Dotted</option>
|
|
26 </param>
|
|
27 <param name="col" type="select" label="Line Color">
|
|
28 <option value="1">Black</option>
|
|
29 <option value="2">Red</option>
|
|
30 <option value="3">Green</option>
|
|
31 <option value="4">Blue</option>
|
|
32 <option value="5">Cyan</option>
|
|
33 <option value="6">Magenta</option>
|
|
34 <option value="7">Yellow</option>
|
|
35 <option value="8">Gray</option>
|
|
36 </param>
|
|
37 <param name="lwd" type="float" label="Line Width" value="1.0"/>
|
|
38 </when>
|
|
39 <when value="points">
|
|
40 <param name="pch" type="select" label="Point Type">
|
|
41 <option value="1">Circle (hollow)</option>
|
|
42 <option value="2">Triangle (hollow)</option>
|
|
43 <option value="3">Cross</option>
|
|
44 <option value="4">Diamond (hollow)</option>
|
|
45 <option value="15">Square (filled)</option>
|
|
46 <option value="16">Circle (filled)</option>
|
|
47 <option value="17">Triangle (filled)</option>
|
|
48 </param>
|
|
49 <param name="col" type="select" label="Point Color">
|
|
50 <option value="1">Black</option>
|
|
51 <option value="2">Red</option>
|
|
52 <option value="3">Green</option>
|
|
53 <option value="4">Blue</option>
|
|
54 <option value="5">Cyan</option>
|
|
55 <option value="6">Magenta</option>
|
|
56 <option value="7">Yellow</option>
|
|
57 <option value="8">Gray</option>
|
|
58 </param>
|
|
59 <param name="cex" type="float" label="Point Scale" value="1.0"/>
|
|
60 </when>
|
|
61 </conditional>
|
|
62 </repeat>
|
|
63 </inputs>
|
|
64
|
|
65 <configfiles>
|
|
66 <configfile name="script_file">
|
|
67 ## Setup R error handling to go to stderr
|
|
68 options( show.error.messages=F,
|
|
69 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
|
|
70 ## Determine range of all series in the plot
|
|
71 xrange = c( NULL, NULL )
|
|
72 yrange = c( NULL, NULL )
|
|
73 #for $i, $s in enumerate( $series )
|
|
74 s${i} = read.table( "${s.input.file_name}" )
|
|
75 x${i} = s${i}[,${s.xcol}]
|
|
76 y${i} = s${i}[,${s.ycol}]
|
|
77 xrange = range( x${i}, xrange )
|
|
78 yrange = range( y${i}, yrange )
|
|
79 #end for
|
|
80 ## Open output PDF file
|
|
81 pdf( "${out_file1}" )
|
|
82 ## Dummy plot for axis / labels
|
|
83 plot( NULL, type="n", xlim=xrange, ylim=yrange, main="${main}", xlab="${xlab}", ylab="${ylab}" )
|
|
84 ## Plot each series
|
|
85 #for $i, $s in enumerate( $series )
|
|
86 #if $s.series_type['type'] == "line"
|
|
87 lines( x${i}, y${i}, lty=${s.series_type.lty}, lwd=${s.series_type.lwd}, col=${s.series_type.col} )
|
|
88 #elif $s.series_type.type == "points"
|
|
89 points( x${i}, y${i}, pch=${s.series_type.pch}, cex=${s.series_type.cex}, col=${s.series_type.col} )
|
|
90 #end if
|
|
91 #end for
|
|
92 ## Close the PDF file
|
|
93 devname = dev.off()
|
|
94 </configfile>
|
|
95 </configfiles>
|
|
96
|
|
97 <outputs>
|
|
98 <data format="pdf" name="out_file1" />
|
|
99 </outputs>
|
|
100
|
|
101 <tests>
|
|
102 <test>
|
|
103 <param name="main" value="Example XY Plot"/>
|
|
104 <param name="xlab" value="Column 1"/>
|
|
105 <param name="ylab" value="Column 2"/>
|
|
106 <param name="input" value="2.tabular" ftype="tabular"/>
|
|
107 <param name="xcol" value="1"/>
|
|
108 <param name="ycol" value="2"/>
|
|
109 <param name="type" value="line"/>
|
|
110 <param name="lty" value="2"/>
|
|
111 <param name="col" value="2"/>
|
|
112 <param name="lwd" value="1.0"/>
|
|
113 <output name="out_file1" file="XY_Plot_1_out.pdf"/>
|
|
114 </test>
|
|
115 </tests>
|
|
116 <help>
|
|
117 .. class:: infomark
|
|
118
|
|
119 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.
|
|
120
|
|
121 -----
|
|
122
|
|
123 .. class:: warningmark
|
|
124
|
|
125 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.
|
|
126
|
|
127 -----
|
|
128
|
|
129 **Example**
|
|
130
|
|
131 Input file::
|
|
132
|
|
133 1 68 4.1
|
|
134 2 71 4.6
|
|
135 3 62 3.8
|
|
136 4 75 4.4
|
|
137 5 58 3.2
|
|
138 6 60 3.1
|
|
139 7 67 3.8
|
|
140 8 68 4.1
|
|
141 9 71 4.3
|
|
142 10 69 3.7
|
|
143
|
|
144 Create a two series XY plot on the above data:
|
|
145
|
|
146 - Series 1: Red Dashed-Line plot between columns 1 and 2
|
|
147 - Series 2: Blue Circular-Point plot between columns 3 and 2
|
|
148
|
|
149 .. image:: ${static_path}/images/xy_example.jpg
|
|
150 </help>
|
|
151 </tool>
|