[Bioperl-l] Bio::Graphics & Binding Sites visualization

Lincoln Stein lstein@cshl.org
Fri, 11 Oct 2002 09:02:12 -0400


Hi Tommy,

What you want to do is to specify a callback for the color attribute 
when you create the binding site track.  

	my $f1 = Bio::SeqFeature::Generic(-start=>10,-end=>100,
					-strand=>-1,-source=>'MCM1');
	my $f2 = Bio::SeqFeature::Generic(-start=>120,-end=>200,
					-strand=>+1,-source=>'SP1');
	$panel->add_track(generic=>[$f1,$f2],
			-strand_arrow=>1,
			-bgcolor => sub {
				my $feature= shift;
				return 'yellow' if $feature->source_tag eq 'MCM1';
				return 'blue'    if $feature->source_tag eq 'SP1'}
		);

You can do the same thing with Bio::Graphics::Feature, but the Generic class
is preferred.  Any of the options passed to add_track() can be subroutines.  They
will be called with the feature as the argument and are expected to return an
option string.  In this case, the -bgcolor callback is examininign the feature's
source_tag() method to return the appropriate color, but you can do other
things, like examining the score to set the height of the glyph, etc.

Lincoln


			
On Friday 11 October 2002 04:55 am, Tommy Kaplan wrote:
> Dear Lincoln,
>
> I'm attaching two files: makeFig.pl and a gif image created by it.
>
> I would like to have all binding sites on the same track, but with
> different colors.
>
> I had another two ideas:
> - Creating a Binding glyph, with some significance feature
> (score, pvalue, etc.)
> This feature can control the darkness of the arrow and label, being almost
> transparent for low-scoring sites, and bold for high-scoring sites.
>
> - Also, maybe adding a ``-key_style => before'' option might be nice,
> having the key on exactly the same line/track as the features, but left to
> the image itself.
>
> Thanks.
> Tommy