diff xy_plot.xml @ 0:d43075b3e107 draft default tip

Uploaded
author saskia-hiltemann
date Fri, 30 Oct 2015 10:46:49 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xy_plot.xml	Fri Oct 30 10:46:49 2015 -0400
@@ -0,0 +1,234 @@
+<tool id="XY_Plot_1_multiformat" name="Plotting tool" version="1.0.1">
+  <description>for multiple series and graph types and multiple output types</description>
+  <requirements>
+    <requirement type="package" version="3.2.1">R</requirement>
+    <requirement type="package" version="2.11.1">fontconfig</requirement>
+   </requirements>
+  <command interpreter="bash">r_wrapper.sh $script_file</command>
+
+  <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="ftype" type="select" label="File Type">
+            <option value="pdf">PDF</option>
+            <option value="png">PNG</option>
+            <option value="jpeg">JPEG</option>
+            <option value="bmp">BMP</option>
+            <option value="tiff">TIFF</option>
+          </param>
+    <repeat name="series" title="Series">
+      <param name="input" type="data" format="tabular" label="Dataset"/>
+      <param name="xcol" type="data_column" data_ref="input" label="Column for x axis"/>
+      <param name="ycol" type="data_column" data_ref="input" 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>
+
+  <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}" )
+        x${i} = s${i}[,${s.xcol}]
+        y${i} = s${i}[,${s.ycol}]
+        xrange = range( x${i}, xrange )
+        yrange = range( y${i}, yrange )
+      #end for
+      ## Open output PDF file
+      #if $ftype.value == "pdf"
+        pdf("outfile.pdf")
+      #else
+        "${ftype}"( "outfile.${ftype}" , 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"
+          lines( x${i}, y${i}, lty=${s.series_type.lty}, lwd=${s.series_type.lwd}, col=${s.series_type.col} )
+        #elif $s.series_type.type == "points"
+          points( x${i}, y${i}, pch=${s.series_type.pch}, cex=${s.series_type.cex}, col=${s.series_type.col} )
+        #end if
+      #end for    
+      ## Close the PDF file
+      devname = dev.off()
+    </configfile>
+  </configfiles>
+
+  <outputs>
+    <data format="pdf" name="out_file1" from_work_dir="outfile.pdf" >
+        <filter>(ftype == 'pdf') </filter>
+    </data>
+    <data format="png" name="out_file2" from_work_dir="outfile.png">
+        <filter>(ftype == 'png') </filter>
+    </data>    
+    <data format="jpg" name="out_file3" from_work_dir="outfile.jpeg">
+        <filter>(ftype == 'jpeg') </filter>
+    </data>
+    <data format="bmp" name="out_file4" from_work_dir="outfile.bmp">
+        <filter>(ftype == 'bmp') </filter>
+    </data>
+    <data format="tiff" name="out_file5" from_work_dir="outfile.tiff">
+        <filter>(ftype == 'tiff') </filter>
+    </data>
+  </outputs>
+
+    <tests>
+        <test>
+            <param name="main" value="Example XY Plot PDF"/>
+            <param name="xlab" value="Column 1"/>
+            <param name="ylab" value="Column 2"/>
+            <param name="ftype" 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_file1" file="XY_Plot_1_multi_out.pdf" format="pdf" />
+        </test>
+        <test>
+            <param name="main" value="Example XY Plot PNG"/>
+            <param name="xlab" value="Column 1"/>
+            <param name="ylab" value="Column 2"/>
+            <param name="ftype" value="png"/>
+            <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_file2"  md5="c2762c725f80fe4419e35768cac5d11b" />
+        </test>
+        <test>
+            <param name="main" value="Example XY Plot JPEG"/>
+            <param name="xlab" value="Column 1"/>
+            <param name="ylab" value="Column 2"/>
+            <param name="ftype" value="jpeg"/>
+            <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_file3"  md5="5c89f4e87bb5f2a809877b471f9c2d69" />
+        </test>
+        <test>
+            <param name="main" value="Example XY Plot BMP"/>
+            <param name="xlab" value="Column 1"/>
+            <param name="ylab" value="Column 2"/>
+            <param name="ftype" value="bmp"/>
+            <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_file4" md5="74ea4b29bd7de44c1b6377c6c26671e7"/>
+        </test>
+        <test>
+            <param name="main" value="Example XY Plot TIFF"/>
+            <param name="xlab" value="Column 1"/>
+            <param name="ylab" value="Column 2"/>
+            <param name="ftype" value="tiff"/>
+            <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_file5" md5="7ebf7d201ad9cdf0fc6995639749ae7d"/>
+        </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>
+</tool>