Bio::Graphics::Glyph::ternary_plot.3pm

Langue: en

Autres versions - même langue

Version: 2009-02-26 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Bio::Graphics::Glyph::ternary_plot - Draw ternary plot data

SYNOPSIS

  #!/usr/bin/perl
 
  use strict;
  use warnings;
 
  use Bio::Graphics;
  use Bio::Graphics::Feature;
 
  my $segment  = Bio::Graphics::Feature->new(-start=>1,-end=>700);
  my $snp1     = Bio::Graphics::Feature->new(-start     => 500,
                                            -end       => 501,
                                            -name      => 'rs000001',
                                            -attributes=> {triples => [
                                                                       [0.01, 0.81, 0.18, 'red',  'CEPH'],
                                                                       [0.25, 0.25, 0.50, 'blue', 'JPT+CHB'],
                                                                       [0.81, 0.01, 0.18, 'green','YRI'],
                                                                      ]
                                                           }
                                           );
  my $snp2     = Bio::Graphics::Feature->new(-start     => 300,
                                            -end       => 301,
                                            -name      => 'rs12345',
                                            -attributes=> {triples => [
                                                                       [0.04, 0.64, 0.32, 'red',  'Controls'],
                                                                       [0.16, 0.36, 0.48, 'blue', 'Cases'],
                                                                      ]
                                                           }
                                           );
 
  my $panel = Bio::Graphics::Panel->new(-segment=>$segment,-width=>800);
 
  $panel->add_track($segment,-glyph=>'arrow',-double=>1,-tick=>2);
  $panel->add_track([$snp1,$snp2],
                   -glyph    => 'ternary_plot',
                   -height   => 80,
                   -fgcolor  => 'lightgrey',
                   -vertices => ['AA','GG','AG'],
                   -label    => 1,
                  );
 
  print $panel->png;
 
 

DESCRIPTION

This glyph draws a light gray equilateral triangle with its base centered on the feature. The top of the equilateral triangle is equal to the specified height. To look good, please choose a height of >= 15.

Inside, the glyph will plot one or more data points using ternary plot conventions (see http://en.wikipedia.org/wiki/Ternary_plot). The data consists of a series of (A,B,C) triplets chosen such that the range of each component is [0.0,1.0] and A + B + C = 1.0. The left, right and apex of the triangle represent the proportions of A, B and C respectively. As a component approaches 1.0, it gets closer to its corresponding vertex.

The data can be represented as one or more feature tags called ``triples'' each in the format:

    A1,B1,C1,<color>,<label>   # (color and label are optional)
 
 

or as a callback specified by the option -triples, which should return a list of arrays, where each array is a triple, followed by an optional color. E.G.

  sub my_calback {
    my $feature = shift;
    return [[0.1,0.5,0.4,'red','pt1'],[0.2,0.2,0.6,'blue','pt2'],[0.8,0.2,0.0,'green','pt4']];
  }
 
 

The color, if it is missing, will be the same as the bgcolor.

OPTIONS

In addition to the common options, the following glyph-specific options are recognized:

   Option      Description 
   ------      -----------
 
   -triples    The callback to return triple data.
   -vertices   Labels for the left,right & top vertices
 
 

BUGS

Please report them.

SEE ALSO

Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::triangle, Bio::Graphics::Glyph::whiskerplot, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD

AUTHOR

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2006 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.