Connect Exons And/Or Cdss With Bio::Graphics
1
0
Entering edit mode
10.9 years ago
int11ap1 ▴ 490

Hello,

I'm trying to display my data from a GFF file into an image using Bio::Graphics in Perl. I obtain what I want to obtain, but, however, my exons or CDS do not connect... My code now:

#!/usr/bin/perl

use warnings;
use Bio::Graphics;
use Bio::Tools::GFF;
use Bio::SeqFeature::Generic;

$gff3_file = $ARGV[0];
$gffio = Bio::Tools::GFF -> new(-file =>$gff3_file , -gff_version => 3);

while ($feature = $gffio->next_feature()) {
  push(@features, $feature);
}

$gffio->close();

$panel = Bio::Graphics::Panel->new(
                            -length => 20000,
                            -width  => 800,
                            -key_style => 'left'
                            );

for $f (@features) {
  $tag = $f->primary_tag();
  push @{$sorted_features{$tag}}, $f;
}

@colors = qw(cyan orange blue purple green chartreuse magenta yellow aqua);
for $tag (keys %sorted_features) {
  $panel->add_track($sorted_features{tag},
                    -glyph => 'transcript2',
                    -label => 1,
                    -connector => 'solid',
                    -bgcolor => $cyan,
                    -key => "${tag}s",
                   );
}

print $panel->png;

A piece of my data (the exons shown should be all together or connected):

##gff-version 3
313-9640000-9660000:19634:fwd    maker    gene    1978    7195    .    +    .    ID=maker-313-9640000-9660000%3A19634%3Afwd-augustus-gene-0.10;Name=maker-313-9640000-9660000%253A19634%253Afwd-augustus-gene-0.10
313-9640000-9660000:19634:fwd    maker    mRNA    1978    7195    .    +    .    ID=maker-313-9640000-9660000%3A19634%3Afwd-augustus-gene-0.10-mRNA-1;Name=maker-313-9640000-9660000%253A19634%253Afwd-augustus-gene-0.10-mRNA-1;Parent=maker-313-9640000-9660000%3A19634%3Afwd-augustus-gene-0.10
313-9640000-9660000:19634:fwd    maker    exon    1978    2207    0.48    +    .    Parent=maker-313-9640000-9660000%3A19634%3Afwd-augustus-gene-0.10-mRNA-1
313-9640000-9660000:19634:fwd    maker    exon    3081    3457    0.48    +    .    Parent=maker-313-9640000-9660000%3A19634%3Afwd-augustus-gene-0.10-mRNA-1
313-9640000-9660000:19634:fwd    maker    exon    3535    3700    0.48    +    .    Parent=maker-313-9640000-

Any idea?

bioperl • 3.8k views
ADD COMMENT
0
Entering edit mode

What happened to the question? If an answer was found then please post the solution.

ADD REPLY
0
Entering edit mode

I've just written a similar question with a strong improvement of my code, and I wanted to delete this post in order to make the forum less redundant...

ADD REPLY
0
Entering edit mode

It would actually be better to delete that question and update this question, IMO. The reason is that this question cannot be deleted because there is an answer. It can be closed but people can still view it and everyone will wonder what is going on here. Also, I don't see any major difference from that post and what was originally in this post.

ADD REPLY
0
Entering edit mode

Now I use the module you suggested me... parsing the GFF file but exons do not connect

ADD REPLY
1
Entering edit mode

(I've updated this post and deleted the other one because the answer below is still relevant. Also, it is confusing to be responding to the same question in 3 different posts, so let's keep the discussion in this thread.)

See Neil's answer below, and also check which features you are adding for each track. It's not clear from your code because we can't see the data. I would start by adding some debugging code to check which features you are adding to each track.

ADD REPLY
0
Entering edit mode

A piece of my data uploaded. I have 37 rows of information and in the @features there are 37 elements...

ADD REPLY
0
Entering edit mode
10.9 years ago
Neilfws 49k

Difficult to debug without knowing what is in the file annot.gff. However: how are you running the script? Remember that you have to pipe the output to a display program or redirect to a PNG file.

From the HOWTO:

After processing all the hits, we call the panel's png() method to render them and convert it into a Portable Network Graphics (PNG) file, the contents of which are printed to standard output. We can now view the result by piping it to our favorite image display program. Users of operating systems that don't support pipes can simply redirect the output to a file and view it in their favorite image program.

ADD COMMENT
0
Entering edit mode

a piece of my data uploaded...

I am running my script:

perl script.pl file.gff
ADD REPLY
0
Entering edit mode

OK, so you need to run:

perl script.pl file.gff > image.png
ADD REPLY
0
Entering edit mode

ah, well, sorry, actually, I run perl script.pl file.gff | display -, it's the same... but exons are like independent features, no connections between the exons of the same gene...

ADD REPLY

Login before adding your answer.

Traffic: 2092 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