[Bioperl-l] Can Bio::Graphics render a muti_segments picture?

Lincoln Stein lstein at cshl.org
Thu May 15 14:22:05 EDT 2003


With the current CVS version of bioperl, this script produces the attached 
picture.  It is almost identical to the fragment that you sent me, except 
that the generic sequence feature is created with -display_name, rather than 
-seq_id, since the meaning of the latter field has changed subtly since the 
tutorials were written (they have been updated too).

Lincoln

#!/usr/bin/perl

use strict;
use lib '.';
use Bio::Graphics;
use Bio::SeqIO;
use Bio::SeqFeature::Generic;

my $io = Bio::SeqIO->new(-format=>'fasta' , -file=>'t/data/genomic-seq.fasta') 
or die;
my $seq = $io->next_seq;
my $wholeseq =Bio::SeqFeature::Generic->new(-start=>1,-end=>$seq->length,
					    -display_name=>$seq->display_name);
$wholeseq->attach_seq($seq);

my $panel = Bio::Graphics::Panel->new(
                                     -length    => $seq->length,
                                     -key_style => 'between',
                                     -width     => 700,
				      -pad_top   => 30,
				      -pad_bottom => 30,
                                     -pad_left  => 50,
                                     -pad_right => 50,
                                      );  
$panel->add_track($wholeseq,
                  -glyph  => 'dna',
                  -fgcolor => 'black',
                  -height => 100,
                  -bgcolor => 'red',
                  -do_gc        => 'true',
                  -gc_bins => 100,
                  -axis_color=> 'blue',
                  -strand => 'forward',);

print $panel->png;


On Wednesday 14 May 2003 09:07 pm, tongw wrote:
> Yes, I still met some problems of rendering gc content by bioperl 1.2, I
> got the plot but with just a straight line in the middle (50%) from lelf
> to righ. And I can`t find more manual for the dna glyph. The following
> is the code:
>
> use strict;
> use Bio::Graphics;
> use Bio::SeqIO;
> .....
> my $io = Bio::SeqIO->new(-format=>"$format" , -file=>$file) or
> die("can`t open the $file.\n");
> my $seq = $io->next_seq                or die USAGE;
> my $wholeseq =
> Bio::SeqFeature::Generic->new(-start=>1,-end=>$seq->length,-seq_id=>$seq
> ->display_name);
> $wholeseq->attach_seq($seq);
>
> my $panel = Bio::Graphics::Panel->new(
>                                      -length    => $seq->length,
>                                      -key_style => 'between',
>                                      -width     => 700,
> 			-pad_top   => 30,
> 			-pad_bottom => 30,
>                                      -pad_left  => 50,
>                                      -pad_right => 50,
>                                       );
> $panel->add_track($wholeseq,
>                   -glyph  => 'dna',
>                   -fgcolor => 'black',
>                   -height => 100,
>                   -bgcolor => 'red',
>                   -do_gc	=> 'true',
>                   -gc_bins => 100,
>                   -axis_color=> 'blue',
>                   -strand => 'forward',);
> .....
>     I want to know the correct usage of dna glyph in bioperl 1.2.
> Kind Regards.
>
> Wei Tong
>
>
> -----Original Message-----
> From: Lincoln Stein [mailto:lstein at cshl.org]
> Sent: 2003Äê5ÔÂ15ÈÕ 05:44
> To: tongw
> Cc: bioperl-l at bioperl.org
> Subject: Re: [Bioperl-l] Can Bio::Graphics render a muti_segments
> picture?
>
>
> Hi,
>
> I highly recommend using version 1.2 for a whole host of reasons. Try 1.
> 2, and
> if the GC plot still isn't working, let me know.
>
> Lincoln
>
> On Wednesday 14 May 2003 05:23 am, tongw wrote:
> > Hi, Lincoln,
> >         I met the same problem emerged in the mail of Lucas Quincy Ton
> >
> > in Feb 3,2003:
> >         "Using the 'dna' glyph of Bio::Graphics  to render GC-content
> > plot, I get the plot but with just a straight line in the middle (50%)
> >
> > from lelf to right".  And you answered, "I have checked in a new
> > version of the dna.pm module that should fix this so that the GC
> > content glyph will work correctly".
> >         So I want to know whether the problem in dna glyph has been
> > fixed in bioperl version 1.2.
> >
> >
> > Wei Tong
> >
> >
> > -----Original Message-----
> > From: Lincoln Stein [mailto:lstein at cshl.org]
> > Sent: 2003Äê5ÔÂ14ÈÕ 05:41
> > To: tongw
> > Cc: bioperl-l at bioperl.org
> > Subject: Re: [Bioperl-l] Can Bio::Graphics render a muti_segments
> > picture?
> >
> >
> > Hi Wei,
> >
> > If you are trying to wrap the picture so that it spans multiple lines,
> >
> > like a paragraph of text, then Bio::Graphics won't do that
> > automatically.  The best
> > that you can do is to generate one very long GD image, and then to
>
> break
>
> > it
> > into small rectangles and paste them back together into the desired
> > geometry
> > using the $gd->copy() function.
> >
> > Lincoln
> >
> > On Monday 12 May 2003 11:00 pm, tongw wrote:
> > > Hi, dear Lincoln:
> > >        Thanks for your so quick response. It`s the problem of my
> > > English expression about my previous question. My puzzle is:
> > >     When your sequence is too long to be drawn in one line, can
> > > Bio::Graphics help us to draw the long sequence in muti_parts, such
> > > as
> > >
> > > drawing a 200k sequence in two parts, each is 100k. But not to say
> > > how
> > >
> > > to draw  a muti_segments feature in a sequence.
> > >        Because I want to write a script to draw the picture of
> > > genes` annotation of small genomes by the Bio::Graphics module,
> > > which are too
> > >
> > > long to display in one line. Kind Regards.
> > >                                                     Wei Tong
> > >
> > >
> > > -----Original Message-----
> > > From: Lincoln Stein [mailto:lstein at cshl.org]
> > > Sent: 2003Äê5ÔÂ12ÈÕ 21:54
> > > To: tongw; bioperl-l at bioperl.org
> > > Subject: Re: [Bioperl-l] Can Bio::Graphics render a muti_segments
> > > picture?
> > >
> > >
> > > Here's an example of drawing a multi-segment object:
> > >
> > > use strict;
> > > use Bio::Graphics;
> > > use Bio::SeqFeature::Generic;
> > >
> > > my $Generic = 'Bio::SeqFeature::Generic';  # to reduce typing
> > >
> > > # create a feature to use for the scale arrow
> > > my $whole_region = $Generic->new(-start=>1,
> > > -end=>10000,-seq_id=>'whole');
> > >
> > > # create a multi-segment feature
> > > my $blue1        =
> > > $Generic->new(-start=>5000,-end=>9000,-seq_id=>'blue1');
> > > $blue1->add_SeqFeature($Generic->new(-start=>5000,-end=>6000));
> > > $blue1->add_SeqFeature($Generic->new(-start=>7000,-end=>7500));
> > > $blue1->add_SeqFeature($Generic->new(-start=>8000,-end=>9000));
> > >
> > > my $panel =
> > > Bio::Graphics::Panel->new(-segment=>$whole_region,-width=>800);
> > > $panel->add_track($whole_region,
> > >                   -glyph  => 'arrow',
> > >                   -double => 1,
> > >                   -tick   => 2);
> > >
> > > $panel->add_track($blue1,
> > >                   -glyph   => 'segments',
> > >                   -label   => 1,
> > >                   -bgcolor => 'blue');
> > >
> > > print $panel->png;
> > >
> > > Best,
> > >
> > > Lincoln
> > >
> > > On Monday 12 May 2003 06:18 am, tongw wrote:
> > > > Greeting all, especially the developers of Bioperl:
> > > >     It`s my first time to locate the mail list of Bioperl, and I
> > > > have applied the Bioperl modules to sovle the problems in my
> > > > research, which is more comfotable than write the perl scripts,
> > > > specially in the
> > > >
> > > > format changing and drawing the picture by GD module.
> > > >   But I meet a question: I think the Bio::Graphics only draw the
> > > > whole
> > > >
> > > > sequence in one segment. I want to know whether there is some
> > > > methods to render a muti_segments picture, and it is more
> > > > necessary when the sequence is very long. Kind Regards. Specially
> > > > thank Lincoln, your howto docment about Graphics helps me to grasp
> > > >
> > > > the main usages in graphics module.
> > > >
> > > >                                                        Wei Tong
> > > >
> > > >
> > > > ============================================
> > > >
> > > > Wei Tong
> > > >
> > > > Bioinformatics Department
> > > > Beijing Genomics Institute/
> > > > Genomics & Bioinformatics Center Chinese Academy of Science
> > > > Beijing Airport Industrial Zone B6 Beijing 101300, P.R. China
> > > >
> > > > Tel: 0086-10-80481833 (Office)
> > > > Email : tongw at genomics.org.cn
> > > > http://www.genomics.org.cn
> > > > ============================================
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Bioperl-l mailing list
> > > > Bioperl-l at bioperl.org
> > > > http://pw600a.bioperl.org/mailman/listinfo/bioperl-l

-- 
========================================================================
Lincoln D. Stein                           Cold Spring Harbor Laboratory
lstein at cshl.org			                  Cold Spring Harbor, NY
========================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_gc.png
Type: image/png
Size: 1589 bytes
Desc: not available
Url : http://pw600a.bioperl.org/pipermail/bioperl-l/attachments/20030515/d55e6d1f/test_gc.png


More information about the Bioperl-l mailing list