[Bioperl-l] Graphics:Panel /SeqFeature::Generic

Daniel Lang Daniel.Lang at biologie.uni-freiburg.de
Wed Dec 3 04:06:23 EST 2003


Thanks a lot Lincoln! That worked for me:)

Of course there are some questions remaining;)
I wounder why I can use something like $feature->significance if I 
didn´t set that tag? Are the whole hits attributes available once a hit 
is linked to a feature?

I´m using this (BLAST overview graphics with Bio::Graphics::panel)in a 
modperl handler...Most of the time everything works out absolutely fine, 
but sometimes when the handler is called the graphics are black´n 
white?! (Apache/1.3.27 (Unix)(Red-Hat/Linux) Embperl/2.0b5 
mod_perl/1.26) (All the modules are preloaded in a startup script)
I fear this might be off-topic but has anyone also experienced behaviour 
like this?

Thanks in advance.

Daniel

Lincoln Stein wrote:
> Make sure to set the tag on the subfeatures and to use the segments glyph.  
> The attached demo script encodes the score as red/blue and the significance 
> as height.
> 
> Lincoln
> 
> On Monday 24 November 2003 07:25 am, Daniel Lang wrote:
> 
>>Hi Lincoln,
>>Thanks for your help, but this didn´t improve the situation:(
>>I know now for sure, that the $feature->score is not the evalue, that is
>>set in the while loop, but the normal score!!
>>Additionally, I tried again introducing it as an additional tag, but
>>this tag isn´t available in the callback with e.g.
>>get_tag_values('evalue'). I´m using it in a mod_perl Handler, could this be
>>part of the problem? Thanks in advance,
>>Daniel
>>
>>Lincoln Stein wrote:
>>
>>>Hi Dan,
>>>
>>>Try changing the "generic" glyph to "segments."  The first glyph doesn't
>>>know how to deal with subparts (such as HSPs), the second does.
>>>
>>>Lincoln
>>>
>>>On Monday 17 November 2003 05:06 am, Daniel Lang wrote:
>>>
>>>>Hi,
>>>>I want to generate overview graphics from BLAST reports, where the hits
>>>>are sorted and colored (>1e-10 -->green, ...)according their evalues...
>>>>
>>>>So I thought, I could solve this using a callback function for the
>>>>bgcolor and using the 'low_score' sort_order, but when applied to a
>>>>BLAST report, it results in sorted but only red hits?
>>>>I also tried introducing the evalues as additional tags like done with
>>>>'bits' or 'range', but when testing for this tag in the callback
>>>>(has_tag) its not available?
>>>>So I wander if the function is envoked for each hit in the while loop?
>>>>
>>>>Here the code sniplet:
>>>>
>>>>my $track = $panel->add_track(-glyph       => 'generic',
>>>>                                -label       => 1,
>>>>                                -connector   => 'dashed',
>>>>				-height      => 5,
>>>>                                -bgcolor     =>  sub {
>>>>						    my $feature = shift;
>>>>						    my $evalue = $feature->score;
>>>>						    if ($evalue < 1e-10) {return 'green';}
>>>>						    else {return 'red';}}
>>>>						    ,
>>>>				-fontcolor   => 'green',
>>>>                                -font2color  => 'red',
>>>>                                -sort_order  => 'low_score',
>>>>				-min_score => '1e-1000',
>>>>				-max_score => '10000',
>>>>                                -description => sub {
>>>>                                  my $feature = shift;
>>>>                                  return unless
>>>>$feature->has_tag('bits'); my ($description) =
>>>>$feature->each_tag_value('bits');
>>>>                                  my $score = $feature->score;
>>>>                                  my ($range) =
>>>>$feature->each_tag_value('range');
>>>>				  "Score=$description bits, E-value=$score, $range";
>>>>                                 });
>>>>
>>>>    while( my $hit = $result->next_hit ) {
>>>>	my $evalue = $hit->significance;
>>>>	my $feature = Bio::SeqFeature::Generic->new(-score   => $evalue,
>>>>						    -display_name => $hit->name,
>>>>						    -tag     => { 'bits' => $hit->bits,
>>>>								  'range' => "from ". $hit->start('query') . " to " .
>>>>$hit->end('query'),
>>>>								  },
>>>>						    );
>>>>	while( my $hsp = $hit->next_hsp ) {
>>>>	   $feature->add_sub_SeqFeature($hsp,'EXPAND');
>>>>	 }
>>>>	$track->add_feature($feature);
>>>>  }
>>>>
>>>>Thanks in advance,
>>>>Daniel
>>>>
>>>>_______________________________________________
>>>>Bioperl-l mailing list
>>>>Bioperl-l at portal.open-bio.org
>>>>http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>
>>_______________________________________________
>>Bioperl-l mailing list
>>Bioperl-l at portal.open-bio.org
>>http://portal.open-bio.org/mailman/listinfo/bioperl-l
> 
> 
> 
> ------------------------------------------------------------------------
> 
> full_length:
> 
> hit:
> description	Human non-histone chromatin protein HMG1 (HMG1) gene, complete cds.
> name	U51677
> 
> hit:
> description	Mus musculus (clone Clebp-1) high mobility group 1 protein (HMG-1)
> name	L38477
> 
> hit:
> description	M.musculus HMG1 gene
> name	X80457
> 
> hit:
> description	Mus musculus HMG-1 mRNA, complete cds.
> name	U00431
> 
> hit:
> description	Human non-histone chromosomal protein (HMG-1) retropseudogene.
> name	L08048
> 
> hit:
> description	Human mRNA for high mobility group-1 protein (HMG-1).
> name	X12597
> 
> hit:
> description	Rat amphoterin mRNA, complete cds.
> name	M64986
> 
> hit:
> description	M.musculus mRNA for non-histone chromosomal high-mobility group 1
> name	Z11997
> 
> hit:
> description	Human mRNA for HMG-1, complete cds.
> name	D63874
> 
> hit:
> description	Human DNA sequence from BAC 445C9 on chromosome 22q12.1.
> name	Z95115
> 
> hit:
> description	Bovine mRNA for high mobility group 1 (HMG1) protein
> name	X12796
> 
> hit:
> description	Bovine high-mobility-group protein (HMG-1) mRNA, 3' end.
> name	M26110
> 
> hit:
> description	Mus musculus HMG-like protein (Trf) mRNA, complete cds.
> name	AF009343
> 
> hit:
> description	Pig nonhistone protein HMG1 mRNA, complete cds.
> name	M21683;M21684
> 
> hit:
> description	Homo sapiens (clone 06) high mobility group 1 protein mRNA
> name	L13805
> 
> hit:
> description	Human chromosomal protein HMG1 related gene.
> name	D14718
> 
> hit:
> description	Chinese hamster HMG-1 gene for high mobility group protein 1
> name	Y00365
> 
> hit:
> description	Rat high mobility group 1 protein synthetic gene, complete cds.
> name	M63852
> 
> hit:
> description	Rat mRNA for high mobility group protein HMG1
> name	Y00463
> 
> hit:
> description	M.musculus HMG1-R-227 gene
> name	X80466
> 
> hit:
> description	M.musculus HMG1-R-154 gene
> name	X80462
> 
> hit:
> description	M.musculus HMG1-R-145 gene
> name	X80461
> 
> hit:
> description	M.musculus HMG1-R-177 gene
> name	X80459
> 
> hit:
> description	M.musculus HMG1-R-87 gene
> name	X80467
> 
> hit:
> description	M.musculus HMG1-R-168 gene
> name	X80465
> 
> hit:
> description	M.musculus HMG1-R-159 gene
> name	X80463
> 
> hit:
> description	Rainbow trout HMG-1 gene exons 2-5, complete cds.
> name	L32859
> 
> hit:
> description	M.musculus HMG1-R-135 gene
> name	X80460
> 
> hit:
> description	M.musculus HMG1-R-161 gene
> name	X80464
> 
> hit:
> description	Trout mRNA for high mobility group protein HMG-T
> name	X02666
> 
> hit:
> description	Xenopus laevis high mobility group protein-1 (HMG-1) mRNA, complete
> name	U21933
> 
> 
> 
> ------------------------------------------------------------------------
> 
> #!/lab/bin/perl
> 
> use strict;
> use lib '.';
> use Bio::Graphics;
> use Bio::SearchIO;
> 
> use constant BLAST_FILE => './doc/howto/examples/graphics/blastn.out';
> 
> my $searchio = new Bio::SearchIO (-format => 'blast',
> 				  -file => BLAST_FILE);
> 
> my $result = $searchio->next_result;
> 
> #Create a panel object
> my $panel = Bio::Graphics::Panel->new( -length => $result->query_length,
> 				       -width => 1000,
> 				       -pad_left => 10,
> 				       -pad_right => 10,
> 				     );
> 
> my $full_length = Bio::SeqFeature::Generic->new(-start => 1,
>                                              -end => $result->query_length,
> 					     -primary_tag => 'full_length',
>                                              -seq_id=> $result->query_name
>                                             );
> $panel->add_track($full_length,
>                -glyph   => 'arrow',
>                -tick    => 2,
>                -fgcolor => 'black',
>                -double  => 1,
>                -label   => 1,
>               );
> 
> my $track = $panel->add_track(-glyph        => 'segments',
>                            -label        => 1,
>                            -connector    => 'dashed',
>                            -bgcolor      => sub {
> 			     my $feature = shift;
> 			     my $score = $feature->score;
> 			     $score < 50 ? 'blue' : 'red';
> 			   },
> 			   -height => sub {
> 			     my $feature = shift;
> 			     $feature->significance < 1e-50 ? 20 : 10;
> 			   },
>                            -font2color   => 'red',
>                            -sort_order   => 'high_score',
>                            -description  => sub {
>                              my $feature = shift;
>                              return unless $feature->has_tag('desription');
>                              my ($description) = $feature->each_tag_value('description'); my
>                              $score = $feature->score;
>                              "$description, score=$score";
>                                  }
>                           );
> 
> while( my $hit = $result->next_hit ) {
>   next unless $hit->significance < 1e-20;
>   my $feature = Bio::SeqFeature::Generic->new(-score  =>  $hit->raw_score,
> 					      -seq_id => $hit->name,
> 					      -primary_tag => 'hit',
> 					      -tag    => {
> 							  description => $hit->description,
> 							  name => $hit->name,
> 							 },
> 					     );
>   while( my $hsp = $hit->next_hsp ) {
>     $feature->add_sub_SeqFeature($hsp,'EXPAND');
>   }
> 
>   $track->add_feature($feature);
> }
> 
> print $panel->png;
> 
> __END__
> 
> my @boxes = $panel->boxes;
> foreach ( $panel->boxes() ) {
>    my $feature_box = $_->[0];
>    my $coords  = join( ',', @{$_}[1..4] );
> 
>    print $feature_box->primary_tag,":\n";
>    my @tags = $feature_box->get_all_tags();
>    for my $x (@tags) {
>      print $x,"\t",$feature_box->each_tag_value($x),"\n";
>    }
>    print "\n";
> }



More information about the Bioperl-l mailing list