/tools/plotting/xy_plot.xml

https://bitbucket.org/h_morita_dbcls/galaxy-central · XML · 148 lines · 133 code · 15 blank · 0 comment · 0 complexity · 6fbb4e6025924a0c49efccc46d7a2f62 MD5 · raw file

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