[Bioperl-l] Re: changing subfeature colors with Bio::Graphics and Bio::SeqFeature

Lincoln Stein lstein at cshl.org
Sun Feb 9 14:27:00 EST 2003


Sorry it took so long to respond.  You need to distinguish between the types 
of your motifs either by changing their primary_tag or source_tag.  Then you 
can control the drawing color using a callback.  Example:

my $motif1 = Bio::SeqFeature::Generic->new(-start=>1,-end=>100, 
                                           -primary=>'motif1'); 
my $motif2 = Bio::SeqFeature::Generic->new(-start=>500,-end=>600, 
                                           -primary=>'motif2'); 
my $promoter_composition = 
Bio::SeqFeature::Generic->new(-start=>1,-end=>1000); 
$promoter_composition->add_sub_SeqFeature($motif1); 
$promoter_composition->add_sub_SeqFeature($motif2); 
 
 
my $panel = Bio::Graphics::Panel->new(-segment=>$promoter_composition, 
                                     -width => 600); 
 
$panel->add_track([$promoter_composition], 
                  -glyph => 'segments', 
                  -bgcolor => sub { 
                    my $feature = shift; 
                    return 'red' if $feature->primary_tag eq 'motif1'; 
                    return 'green' if $feature->primary_tag eq 'motif2'; 
                    } 
                 ); 
 
print $panel->png; 


Another alternative is to use the heterogeneous_segments glyph, which provides 
a simple way to do this without writing a callback.

Lincoln

On Thursday 30 January 2003 04:14 pm, you wrote:
> Hi! Dr Stein,
>
> I am a graduate student at pennstate, I am using the Bio::Graphics and
> Bio::SeqFeature modules for a relatively simple task. I want to show the
> cis-acting elements in the promoters of our genes of interest as a picture.
> my script works fine and makes images (sample image attached)... but i can
> not control the color of the cis-elements that I add using the following:
>
> 	$promoter_composition->add_sub_SeqFeature($motif)
>
> 	where, $promoter_composition is a predefined Bio::SeqFeature::Generic
> 	object, 1000 bp long and $motif is a new Bio::SeqFeature::Generic object
>  	whose length is about 6-8 nucleotides.
>
> Is it possible to control the color of objects/features added using the
> add_sub_SeqFeature method? and How?
>
> I read the tutorials on the Bioperl website and there is no detail of how
> to change the color of different features within a track.
>
> regards,
> Nigam.
>
> PS: I use $track = $panel->add_track(<TRACK DETAILS HERE>) to add my track
> and
> $track->add_feature($promoter_composition) to add the promoter to the
> track.

-- 
Lincoln Stein
lstein at cshl.org
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)



More information about the Bioperl-l mailing list