Bio::Graphics::Glyph::ternary_plot(3) Draw ternary plot data


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);
-glyph => 'ternary_plot',
-height => 80,
-fgcolor => 'lightgrey',
-vertices => ['AA','GG','AG'],
-label => 1,
print $panel->png;


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


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


Please report them.


Lincoln Stein <[email protected]>.

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.