[Bioperl-l] addition of GD::graphic object to Bio::Graphics

Lincoln Stein lincoln.stein at gmail.com
Mon Apr 28 21:33:19 UTC 2008


Hi,

No, I'm perfectly happy with combining images like this. It is part of what
I intended.

Another idea would be to use the Image glyph to embed graphs at particular
genomic locations in the panel. Right now the glyph is designed in the
expectation that the image passed to it is sitting on the file system (or a
web URL), but it would be easy to modify it so that a callback can generate
the GD on the fly, by using, for example GD::Graph.

Lincoln

On Mon, Apr 28, 2008 at 5:15 PM, Smithies, Russell <
Russell.Smithies at agresearch.co.nz> wrote:

> I thought it was a bit of a hack but I guess if someone else is doing it
> too, it can't be all bad  :-)
>
> It looks like you can combine your drawing methods like this:
> (I'm sure Lincoln will tell us this is bad but it seems to work ok)
> ------------------------------------------------------------------------
> -------------
>
> #!perl -w
> use GD::Graph::lines;
> use GD::Graph::colour;
> use GD::Graph::Data;
>
> use Bio::Graphics;
> use Bio::SeqFeature::Generic;
>
> # create and draw on a graphics panel
> my $panel = Bio::Graphics::Panel->new(
>                                       -length => 500,
>                                      -width  => 500
>                                     );
> my $track = $panel->add_track(
>                              -glyph => 'generic',
>                              -label => 1
>                             );
>
> # create and add a few features
> for($i = 100; $i < 500; $i+= 100){
>   my $feature = Bio::SeqFeature::Generic->new(
>                                               -display_name => "feature:
> $i",
>                                              -score        => $i,
>                                              -start        => $i,
>                                              -end          => $i + 100
>                                             );
>  $track->add_feature($feature);
> }
>
>
> # create and draw the graph
> my @data = (
>    ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
>    [    1,    2,    5,    6,    3,  1.5,    1,     3,     4],
>    [ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]
> );
> my $graph = GD::Graph::lines->new(500, 300);
>
> $graph->set(
>      x_label           => 'X Label',
>      y_label           => 'Y label',
>      title             => 'Some simple graph',
>      y_max_value       => 8,
>      y_tick_number     => 8,
>      y_label_skip      => 2
> ) or die $graph->error;
>
> $graph->set( dclrs => [ qw( green blue black red pink) ] );
>
> my $gd = $graph->plot(\@data) or die $graph->error;
>
> # combine the two images
> my $combined = $panel->gd($gd);
>
> open(IMG, '>file.png') or die $!;
> binmode IMG;
> print IMG $combined->png;
>
> ------------------------------------------------------------------------
> ------------------
>
> > -----Original Message-----
> > From: Chris Fields [mailto:cjfields at uiuc.edu]
> > Sent: Monday, 28 April 2008 9:54 a.m.
> > To: Smithies, Russell
> > Cc: sergei ryazansky; bioperl-l at bioperl.org
> > Subject: Re: [Bioperl-l] addition of GD::graphic object to
> Bio::Graphics
> >
> > I think this is how some of the synteny mapping is done using
> > SynBrowse (the trapezoids connecting syntenous genes on different
> > tracks).
> >
> > http://www.gmod.org/wiki/index.php/SynView
> >
> > chris
> >
> > On Apr 27, 2008, at 4:27 PM, Smithies, Russell wrote:
> >
> > > You can get the GD object back from the Bio::Graphics::Panel  then
> > > draw
> > > on it using GD methods
> > >
> > > Eg:
> > >
> > > #create a BioPerl panel
> > > my $panel = Bio::Graphics::Panel->new(
> > >                                                     -length   => 600
> > >                                                     -width    =>
> 800,
> > >                                     -bgcolor  => 'white'
> > >                                     );
> > > # add your features
> > > my $feature = Bio::SeqFeature::Generic->new( -start => 1,-end   =>
> > > 200,);
> > > $panel->add_track($feature, glyph   =>   'segments',
> > >                                     -label   =>   0,
> > >                                     -height  =>   30,
> > >                                     -bgcolor  =>  'red',
> > >                                     -fgcolor  => 'red'
> > >                                      );
> > >
> > > # grab the GD thingy
> > > my $gd = $panel->gd;
> > >
> > > #create a color - not sure if there's a better way?
> > > $black = $gd->colorAllocate(0,0,0);
> > >
> > > #draw on your GD thingy
> > > $gd->line(10,10,$panel->width -10,10,$black);
> > > $gd->string(gdSmallFont,20,10,'test' ,'$black);
> > >
> > > # print it as normal
> > > print $panel->png;
> > >
> > >
> > >
> > >
> > >> -----Original Message-----
> > >> From: bioperl-l-bounces at lists.open-bio.org
> > > [mailto:bioperl-l-bounces at lists.open-
> > >> bio.org] On Behalf Of sergei ryazansky
> > >> Sent: Monday, 28 April 2008 2:05 a.m.
> > >> To: bioperl-l at bioperl.org
> > >> Subject: [Bioperl-l] addition of GD::graphic object to
> Bio::Graphics
> > >>
> > >> Hi all,
> > >>
> > >> is it possible to add a GD::graphic object (chart) to Bio::Graphics
> > > panel
> > >> to obtain a file with image of both the chart and bioseq object?
> > >>
> > >> _______________________________________________
> > >> Bioperl-l mailing list
> > >> Bioperl-l at lists.open-bio.org
> > >> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> > > =
> > >
> > =============================================================
> > =========
> > > Attention: The information contained in this message and/or
> > > attachments
> > > from AgResearch Limited is intended only for the persons or entities
> > > to which it is addressed and may contain confidential and/or
> > > privileged
> > > material. Any review, retransmission, dissemination or other use of,
> > > or
> > > taking of any action in reliance upon, this information by persons
> or
> > > entities other than the intended recipients is prohibited by
> > > AgResearch
> > > Limited. If you have received this message in error, please notify
> the
> > > sender immediately.
> > > =
> > >
> > =============================================================
> > =========
> > >
> > > _______________________________________________
> > > Bioperl-l mailing list
> > > Bioperl-l at lists.open-bio.org
> > > http://lists.open-bio.org/mailman/listinfo/bioperl-l
> >
> > Christopher Fields
> > Postdoctoral Researcher
> > Lab of Dr. Robert Switzer
> > Dept of Biochemistry
> > University of Illinois Urbana-Champaign
> >
> >
>
> =======================================================================
> Attention: The information contained in this message and/or attachments
> from AgResearch Limited is intended only for the persons or entities
> to which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipients is prohibited by AgResearch
> Limited. If you have received this message in error, please notify the
> sender immediately.
> =======================================================================
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>



-- 
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse at cshl.edu



More information about the Bioperl-l mailing list