Module: Bio::Graphics

Defined in:
lib/bio/graphics/panel.rb,
lib/bio/graphics/ruler.rb,
lib/bio/graphics/track.rb,
lib/bio/graphics/feature.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, 'red','triangle')

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

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

FUTURE PROSPECTS

Any help from other developers is welcomed to work on these features:

  • Would be nice if this module would be easily accessible from any object that implements bioruby’s Bio::Map::ActsAsMap.

Defined Under Namespace

Classes: Panel

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
RULER_TEXT_HEIGHT =

In pixels again.

10
RULER_MIN_DISTANCE_TICKS_PIXEL =

And again…

5
FONT =

There should be at least 5 pixels between

consecutive ticks. This is used for the
calculation of tick distance.
['Georgia', 1, 1]