[Bioperl-l] creating a graphic

Orvis, Joshua D. (HSC) Joshua-Orvis at ouhsc.edu
Tue Jun 22 13:08:30 EDT 2004


i'm trying to use bioperl to create a graphical representation of what I have been doing using ASCII so far.  i need to create illustrations of how a forward and reverse read have assembled, like this:

(part below won't look right without a fixed-width font)


    1         153                 481
    |          |                   |
F  >-------------------------------->
               |||||||||||||||||||||
R             <----------------------------------------<
               |                   |                  |
              524                 196                 1

    |________________________________________________|
                           675


What sort of glyphs would be best to try to do this?  I would like them to have arrows on the ends to indicate the direction of forward and reverse reads.  I can use triangles or the "pinsertion" to label the numbered positions, and a span to label the assembled length.  Using the biographics examples as a guide I have written the code below, which will do it (sort of), but it feels like i'm missing an easier way to do it.

Any advice would be great.

Joshua

--------------------------------------

#!/usr/bin/perl

use strict;
use Bio::Graphics::Panel;
use Bio::Graphics::Feature;

my $ftr = 'Bio::Graphics::Feature';

my $segment = $ftr->new(-start=>-100,-end=>900,-name=>'assembly',-type=>'clone');

my $forward = $ftr->new(-segments=>[[1, 481]],
                   -name=>'forward',
                   -subtype=>'exon',-type=>'transcript');
          
my $reverse = $ftr->new(-segments=>[[153, 675]],
                    -name=>'reverse',
                    -strand => -1,
                    -subtype=>'exon',-type=>'transcript');

my $panel = Bio::Graphics::Panel->new(
                                      -gridcolor => 'lightcyan',
                                      -grid => 1,
                                      -segment => $segment,
                                      -spacing => 15,
                                      -width   => 600,
                                      -pad_top  => 20,
                                      -pad_bottom  => 20,
                                      -pad_left => 20,
                                      -pad_right=> 20,
                                      -key_style => 'between',
                                  -image_class=> 'GD'
                                     );
                    
my $t = $panel->add_track(
                          transcript2 => [$forward, $reverse],
                          -label => 1,
                          -bump => 1,
                          -key => 'Assembly'
                         );

my $gd    = $panel->gd;

## open an output file
open (my $ofh, ">arrows.png") || die "can't create output file: $!\n";
print $ofh $gd->png;

--------------------------------------


More information about the Bioperl-l mailing list