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?
What happened to the question? If an answer was found then please post the solution.
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...
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.
Now I use the module you suggested me... parsing the GFF file but exons do not connect
(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.
A piece of my data uploaded. I have 37 rows of information and in the @features there are 37 elements...