Issues Dynamically Computing Track Configuration With Gbrowse 2
1
0
Entering edit mode
12.5 years ago

The GBrowse2 documentation provides instructions for dynamically computing certain track configurations. I am trying to take advantage of this feature with some data I have, but so far I've been unsuccessful.

I'm looking at a 25kb region in Arabidopsis at Phytozome. I uploaded the following data file...

##gff-version   3
Chr2    MyData    locus    5588218    5588322    .    .    .    attr5=0;attr4=0;attr3=0;attr2=0;attr1=1
Chr2    MyData    locus    5590052    5591422    .    .    .    attr5=1;attr4=0;attr3=0;attr2=1;attr1=0
Chr2    MyData    locus    5593060    5598296    .    .    .    attr5=1;attr4=0;attr3=1;attr2=0;attr1=0
Chr2    MyData    locus    5598421    5599923    .    .    .    attr5=1;attr4=0;attr3=0;attr2=0;attr1=0

...and then edited the configuration to dynamically calculate feature color--specifically, I added this callback routine to the bgcolor and fgcolor.

sub
{
  my $feature = shift(@_);
  my($attr1) = $feature->get_tag_values("attr1");
  return "red" if($attr1 > 0);
  my($attr2) = $feature->get_tag_values("attr2");
  return "orange" if($attr2 > 0);
  my($attr3) = $feature->get_tag_values("attr3");
  return "gold" if($attr3 > 0);
  my($attr4) = $feature->get_tag_values("attr4");
  return "green" if($attr4 > 0);

  return "blue";
}

After saving this configuration, all of my features show up as black, so something I am doing is not right. I tested this approach on the command line with the following script...

use strict;
use Bio::Tools::GFF;

my $loader = Bio::Tools::GFF->new( -fh => \*STDIN, -gff_version => 3 );
while(my $feat = $loader->next_feature)
{
  printf("color: %s\n", mycolor($feat));
}

sub mycolor
{
  my $feature = shift(@_);
  my($attr1) = $feature->get_tag_values("attr1");
  return "red" if($attr1 > 0);
  my($attr2) = $feature->get_tag_values("attr2");
  return "orange" if($attr2 > 0);
  my($attr3) = $feature->get_tag_values("attr3");
  return "gold" if($attr3 > 0);
  my($attr4) = $feature->get_tag_values("attr4");
  return "green" if($attr4 > 0);

  return "blue";
}

...and it seemed to work fine. What am I doing wrong here?

bioperl annotation • 2.4k views
ADD COMMENT
0
Entering edit mode

Scott's answer is correct. However, there is a way to accomplish this without using Perl callbacks in the configuration. The "heatmap" glyph gives you quite a bit of flexibility with colors. If your start color and end color have good separation on the spectrum (such as red and green), then you will be able to blend these colors to create quite a lot of intermediates. The "heatmap" glyph uses the score field to select the feature's color, so that's essentially what I ended up doing--set my start color to red, my end color to green, and modulated the feature score on discrete intervals between 0 and 1 to get red, orange, yellow, light green, and dark green.

ADD REPLY
1
Entering edit mode
12.5 years ago
scott ▴ 70

Hi Daniel,

This question will probably answered in more detail at the gbrowse mailing list:

https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse

The central issue is that perl callbacks are not allowed in user uploaded configuration files; it would open a massive security hole if we allowed random perl from random users to be executed on the server.

Scott

PS it seems biostars has once again lost my openid account; bummer :-/

ADD COMMENT

Login before adding your answer.

Traffic: 1771 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6