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

- NAME
- SYNOPSIS
- DESCRIPTION

- OPTIONS

- BUGS
- SEE ALSO
- AUTHOR

# NAME

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

Back to Top

# 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;

Back to Top

# 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

Back to Top

# BUGS

Please report them.

Back to Top

# SEE ALSO

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

Back to Top

# 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.

Back to Top

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