[Bioperl-l] Bio::Graphics::Panel->add_track problem
Lincoln Stein
lstein at cshl.edu
Wed Aug 4 17:11:24 EDT 2004
Use a callback for the track -bgcolor. The callback can assign colors
to individual glyphs.
Lincoln
On Wednesday 04 August 2004 04:25 pm, mql201 wrote:
> Hello
>
> I want to print out a number of glyphs of different colours on the
> same track, but with this code there doesn't seem to be a way round
> having more than 1 colour per track:
>
> ## start with an array of colours
> #
> @colours = qw(white red green blue black yellow ...); # 190
> colours in all
>
> ## specify new panel once, background white
> #
> $panel = Bio::Graphics::Panel->new(-length => 700, # length of
> panel in nt
> -width => 700, # physical
> width of img -pad_top => 10, # padding -pad_bottom => 10,
> -pad_left => 10,
> -pad_right => 10,
> -bgcolor => 'white', # colour
> of panel -key_color => 'white',
> -key_style => 'bottom');
>
> ## the following code should create a 28 track panel (down) with 6
> glyphs on ## each track (across), with each glyph a different
> colour got out of the array
> ## @colours.
> #
> my($start) = 10;
> my($end) = 60;
> for($x = 0; $x <=28; $x++) { # 28 tracks to make
> ## define glyph track
> #
> $track = $panel->add_track(-glyph => 'graded_segments',
> -linewidth => 2,
> -height => 8,
> -fontcolor => '#1d4305',
> # -bgcolor => 'some color',
> -label => 1,
> -bump => 1,
> -description => 1);
>
> ## but instead i want to use -bgcolor in the for loop below
> #
> for ($i = 0; $i <= 6; $i++) {
> my($feature) =
> Bio::SeqFeature::Generic->new(-display_name=>$key, -score=>2000,
> -start=>$start, ERROR, THIS SHOULD BE IN ADD_TRACK ABOVE ->
> -bgcolor => shift(@colours), ALTHOUGH I WANT IT IN HERE
> -> -end=>$end);
>
> $track->add_feature($feature);
> $start += 90;
> $end += 90;
> }
> $start = 10;
> $end = 60;
> }
>
>
> As you can see, its a std way of adding tracks, and glyphs to
> tracks, except i can't work out how to add glyphs without them
> having the same colour as the glyphs on the same track because i'd
> have specified the colour of the glyphs on that track, rather than
> the colour of the individual glyph.
>
> i've a feeling its a simple solution. Anybody have any idea?
>
> Many ta IA
> Mark
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
More information about the Bioperl-l
mailing list