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