comparison xy_plot.xml @ 0:8cdada007b82 draft

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