| Module | Bio::Graphics |
| In: |
lib/bio/graphics/panel.rb
|
The Bio::Graphics set of objects allow for creating simple images that display features on a linear map. A picture consists of:
Schematically:
panel +-> track 1 | +-> feature 1 | +-> feature 2 | +-> feature 3 +-> track 2 | +-> feature 4 | +-> feature 5 +-> ruler
# 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')
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]
)
| DEFAULT_PANEL_WIDTH | = | 800 | The defaults | |
| TRACK_HEADER_HEIGHT | = | 12 | ||
| FEATURE_HEIGHT | = | 10 | ||
| FEATURE_V_DISTANCE | = | 5 | ||
| FEATURE_ARROW_LENGTH | = | 5 | ||
| FONT | = | ['Georgia', 1, 1] |