Drawing with multiple glyphs in a single track

From BioPerl
Jump to: navigation, search

(see the bioperl-l thread starting here)

  • Don't neglect your anonymous functions. --Ed.

Matthew Betts asks:

Has any one tried to draw secondary structure with Bio::Graphics, i.e. two different types of glyph with different colours on the same track?


Scott Cain replies:

If you want to put more than one glyph and/or more than one color in a track, it is fairly easy. You just need to provide a callback for each option when you create the track, like this:

$panel->add_track($features_array_ref,
                  -glyph       => sub { #code to set the glyph according the attributes of the feature  },
                  -bgcolor     => sub { #code to set the color },
                  -fgcolor     => 'black',
                ...etc...
);

For more information, see the Graphics HOWTO

Matthew implements:

$panel->add_track(
           '-bgcolor' => sub {
	        my($feature) = @_;
                $feature->display_name eq 'strand' ? 'cyan' : 'magenta';
           },
           '-strand_arrow' => sub {
                my($feature) = @_;
                $feature->display_name eq 'strand' ? 1 : 0;
           },
);
[back to top]


Personal tools
Namespaces
Variants
Actions
Main Links
documentation
community
development
Toolbox