Skip to content
Martin Asser Hansen edited this page Oct 2, 2015 · 10 revisions

Biopiece: plot_histogram

Description

plot_histogram uses a specified key to plot a histogram where each column is the value of the key, and the height of the column indicates the number of records with this value. Plotting is done using GNUplot which allows for different types of output the default one being crufty ASCII graphics.

GNUplot must be installed for plot_histogram to work. Read more here:

http://www.gnuplot.info/

Usage

... | plot_histogram [options]

Options

[-?          | --help]               #  Print full usage description.
[-x          | --no_stream]          #  Do not emit records.
[-o <file>   | --data_out=<file>]    #  Write result to file.
[-k <string> | --key=<string>]       #  Key to use for plotting.
[-t <string> | --terminal=<string>]  #  Terminal for output: dumb|post|svg|png|x11|aqua  -  Default=dumb
[-T <string> | --title=<string>]     #  Set plot title  -  Default="Histogram".
[-X <string> | --xlabel=<string>]    #  Set x-axis label.
[-Y <string> | --ylabel=<string>]    #  Set y-axis label.
[-L          | --logscale_y]         #  Set y-axis to log scale.
[-s <sting>  | --sort=<string>]      #  Sort criteria for x-axis keys: num|alph   -  Default=alph
[-I <file!>  | --stream_in=<file!>]  #  Read input from stream file     -  Default=STDIN
[-O <file>   | --stream_out=<file>]  #  Write output to stream file     -  Default=STDOUT
[-v          | --verbose]            #  Verbose output.

Examples

To generate a ASCII graphics distrubution you merely need to pipe the stream through plot_histogram:

read_psl -i test.psl | plot_histogram -xk SCORE

                                     Histogram

  800 ++-------------------------------------------------------------------++
      |                           **                                        |
  700 ++                          **                                       ++
      |                           **                                        |
      |                           **                                        |
  600 ++                          **         **                            ++
      |                           **         **                             |
  500 ++                          **         **                            ++
      |                           **         **                             |
  400 ++     **                   **         **                            ++
      |      **  **               **         **                             |
      |      **  ** **            **         **                             |
  300 ++     **  ** **            **     **  **                            ++
      |      **  ** **            **     **  **                             |
  200 ++  ** **  ** **            **     **  **                            ++
      |   ** **  ** **            **     **  **                             |
      |   ** **  ** **  ** **     **  ** **  **                             |
  100 ++  ** **  ** **  ** **  ** **  ** **  **                            ++
      |   ** **  ** **  ** **  ** **  ** **  ** **                          |
    0 ++--**-**--**-**--**-**--**-**--**-**--**-**--**-**--**-**--**-**--**++
         20 21  22 23  24 25  26 27  28 29  30 31  32 33  34 35  36 37  38

Obviously the ASCII graphics is crufty and the x axis is messed up, but still you can get an idea of the distribution. However, if you want publication grade graphics you can change the terminal from dumb to postscript or SVG (Scalable Vector Graphics):

To generate a postscript image:

read_psl -i test.psl | plot_histogram -xk SCORE -t post -o histogram.ps

And the result will look like this:

If you choose -t svg instead of -t post the output will be in SVG which is neat since it can easily be modified using e.g. Inkscape to apply labels and such.

Read more about Inkscape here:

http://www.inkscape.org/

See also

read_psl

plot_lendist

Author

Martin Asser Hansen - Copyright (C) - All rights reserved.

mail@maasha.dk

August 2007

License

GNU General Public License version 2

http://www.gnu.org/copyleft/gpl.html

Help

plot_histogram is part of the Biopieces framework.

http://www.biopieces.org

Clone this wiki locally