Question: Connect Exons And/Or Cdss With Bio::Graphics
0
gravatar for int11ap1
5.2 years ago by
int11ap1320
Barcelona
int11ap1320 wrote:

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 • 1.8k views
ADD COMMENTlink modified 4.0 years ago by Biostar ♦♦ 20 • written 5.2 years ago by int11ap1320

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

ADD REPLYlink modified 5.2 years ago • written 5.2 years ago by SES8.1k

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 REPLYlink written 5.2 years ago by int11ap1320

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 REPLYlink modified 5.2 years ago • written 5.2 years ago by SES8.1k

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

ADD REPLYlink written 5.2 years ago by int11ap1320
1

(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 REPLYlink modified 5.2 years ago • written 5.2 years ago by SES8.1k

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

ADD REPLYlink modified 5.2 years ago • written 5.2 years ago by int11ap1320
0
gravatar for Neilfws
5.2 years ago by
Neilfws48k
Sydney, Australia
Neilfws48k wrote:

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 COMMENTlink written 5.2 years ago by Neilfws48k

a piece of my data uploaded...

I am running my script: perl script.pl file.gff

ADD REPLYlink written 5.2 years ago by int11ap1320

OK, so you need to run:

perl script.pl file.gff > image.png
ADD REPLYlink written 5.2 years ago by Neilfws48k

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 REPLYlink written 5.2 years ago by int11ap1320
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1760 users visited in the last hour