[ensembl-dev] EnsEMBL + Bio::Graphics to draw chromosome ideograms - how?

Marc P. Hoeppner mphoeppner at gmail.com
Tue Dec 13 12:44:52 GMT 2011


I do hope this is the appropriate list - sorry if not.
Anyhow, here is my problem:

I have been trying to put together a small script that can retrieve 
chromosome information via the Ensembl API and then draw a chromosome 
ideogram from it, using bioperls Bio::Graphics module. The documentation 
especially for the ideogram glyph is super-sparse, and sure enough I 
can't get it to work.

Does anyone happen to have a similar script I can use or can point me to 
a resource where all this is explained in a comprehensible manner?

I don't have a lot of experience writing in PERL, so there may be a 
couple of issues with the script below. Basically, it fails with the 
error message:

"MSG: asking for tag value that does not exist stain"

Any advice or help would be greatly appreciated! Could be a number of 
things, starting with the older version of Bioperl used by Ensembl, my 
lack of mad PERL skillz or a simple misunderstanding of how the graphics 
module is supposed to be used here.


[ relevant section of script below]

my $chromosome = $slice_adaptor->fetch_by_region("chromosome", "X");

my $panel = Bio::Graphics::Panel->new(
                                       -length    => $chromosome->end,
                                       -width     => 800,
                                       -height      => 500,
                                       -pad_left  => 10,
                                       -pad_right => 10,

my $chromosome_feature = Bio::SeqFeature::Generic->new(
         -start => 0,
         -end => $chromosome->end,
         -label => $chromosome->seq_region_name

foreach my $band (@{$chromosome->get_all_KaryotypeBands}) {
         my $band_feature = Bio::SeqFeature::Generic->new(
             -start => $band->start,
             -end => $band->end,
             -tag => {
                 -stain => $band->stain


my $track = $panel->add_track(
     -glyph => 'ideogram',
     -label => 1,
     -bgcolor => "gneg:white gpos25:silver gpos50:gray gpos:gray  
gpos75:darkgray gpos100:black acen:cen gvar:var",
     -fgcolor => 'green',
     -font2color => 'red'

print $panel->png;

More information about the Dev mailing list