Module: Bio::Graphics

Defined in:
lib/bio/graphics/panel.rb

Overview

DESCRIPTION

The Bio::Graphics set of objects allow for creating simple images that display features on a linear map. A picture consists of:

  • one panel: container of all tracks

  • one or more tracks: container of the features. Multiple tracks can exist in the same graphic to allow for differential visualization of different feature types (e.g. genes as blue rectangles and polymorphisms as red triangles)

  • one or more features in each track: these are the actual features that you want to display (e.g. ‘gene 1’, ‘SNP 123445’)

  • a ruler on top of the panel: is added automatically

Schematically:

panel
  +-> track 1
  |     +-> feature 1
  |     +-> feature 2
  |     +-> feature 3
  +-> track 2
  |     +-> feature 4
  |     +-> feature 5
  +-> ruler

USAGE

# Create a panel for something with a length of 653. This could be a
# sequence of 653 bp, but also a genetic map of 653 cM.
g = Bio::Graphics::Panel.new(653)

# Add the first track (e.g. 'genes')
track1 = g.add_track('genes')

# And put features in that track
track1.add_feature('gene1','250..375')
track1.add_feature('gene2','54..124')
track1.add_feature('gene3','100..500')

# Add a second track (e.g. 'polymorphisms')
track2 = g.add_track('polymorphisms', false, [1,0,0], :triangle)

# And put features on this one
track2.add_feature('polymorphism 1','56')
track2.add_feature('polymorphism 2','103')

# Create the actual image as SVG text
g.draw('my_picture.png')

NOTE ON ARGUMENTS

As there can be an overwhelming number of arguments for some methods in Bio::Graphics, any optional arguments have to be provided as a hash. For example: the Track#add_feature method has only one mandatory argument (the feature object) and several optional ones. This is how you can use that method:

track.add_feature(my_feature_object,
                  :label => 'anonymous',
                  :link => 'http://www.google.com',
                  :glyph => :box,
                  :colour => [0,1,0]
                 )

Defined Under Namespace

Modules: Glyph Classes: Feature, ImageMap, Panel, Ruler, SubFeature, Track

Constant Summary collapse

DEFAULT_PANEL_WIDTH =

The defaults

800
TRACK_HEADER_HEIGHT =

How many pixels wide do we want the picture to be?

12
FEATURE_HEIGHT =

The track header will contain the title.

10
FEATURE_V_DISTANCE =

The height in pixels of a glyph.

5
FEATURE_ARROW_LENGTH =

The vertical distance in pixels between glyphs

5
FONT =

In pixels again.

['Georgia', 1, 1]