4.8 – Ternary plots

Introduction

Ternary plots are used to show composition of a mixture of three components. For example, simple soil composition analysis, a ternary plot is used to display the relative proportions of sand, clay, and silt in a soil sample (eg, Shepard’s diagram). The R package soiltexture contains a number of routines for soil analysis, including generating ternary plots. The package also includes a simple graphical user interface, soiltexture_gui().

In population genetics, de Finetti diagram is used to display three ratio variables that, together, sum to one. For example, display frequency of the three genotypes of a one gene, two allele system in a population. Download the package Ternary from the R mirror. From the Ternary package, we can get a blank plot by simply calling the function TernaryPlot(). R returns the blank plot to the Graphics window (Fig 1).

Figure 1. Blank Graphics window with initial ternary plot.

The basic ternary plot is shown in Figure 1. Running from one corner to another you can see how the frequencies range from 0 to 100%. While we can use the Ternary package, other packages allow you to make ternary plots too, including HardyWeinberg. This package includes several useful tests of the Hardy Weinberg model for population genetics data, so we’ll use that package.

Our example will use the HWTernaryPlot function in the HardyWeinberg package. Before proceeding with the example, download and install the package. 

A nice site on ternary plots in Microsoft Excel (24 steps!) is provided at chemostratigraphy.com. Instructions also worked for LibreOffice Calc (pers. obs.). Take a look at www.ternaryplot.com for a really nice online plot builder.

Example. Recall your basic population genetics, for a locus with 2 alleles with frequency p and q in the population, and given Hardy-Weinberg assumptions apply (e.g., no evolution!), then expected genotype frequencies are given by expanding (p + q)2 = 1. 

Consider a population genetics example using Skittles (Fig 2). 

a few Skittles candies

Figure 2. A few Skittles® candies.

For several bags, count the greens (p) and the oranges (q). Data for 17 mini bags reported Table 1.

Table 1. Counts of green and orange Skittles from 17 mini bags.

BagGREENORANGE
bag142
bag282
bag333
bag434
bag557
bag651
bag7135
bag842
bag963
bag1032
bag1154
bag1299
bag1302
bag1473
bag1554
bag1662
bag1723

Next, we calculate the genotype frequencies from our counts. For example, for bag1, p = 4/6 and q = 2/6. We can imagine a diploids at the locus: GG, GO, and OO, with frequencies p2, 2pq, and q2. The frequencies for the three genotypes are shown in Table 2.

Table 2. Genotype frequencies for our hypothetical population of Skittle diploid critters.

Bagp^22pqq^2
bag10.440.440.11
bag20.640.320.04
bag30.250.50.25
bag40.180.490.33
bag50.170.490.34
bag60.690.280.03
bag70.520.40.08
bag80.440.440.11
bag90.440.440.11
bag100.360.480.16
bag110.310.490.2
bag120.250.50.25
bag13001
bag140.490.420.09
bag150.310.490.2
bag160.560.380.06
bag170.160.480.36

For the plot, the HWTernaryPlot function expects counts, not frequencies of three genotypes of a gene in a population, with genotype frequency that sums to one. Table 3 shows calculated genotype data, assuming 20 Skittle diploid critters per bag.

Table 3. Expected genotype counts.

BagGGGOOO
bag1992
bag21361
bag35105
bag44107
bag53107
bag61461
bag71082
bag8992
bag9992
bag107103
bag116104
bag125105
bag130020
bag141082
bag156104
bag161181
bag173107

Example

Create  an R data.frame called skittles from Table 3. Because HWTernaryPlot requires input only of the genotype data, remove the first column

dSkittles <- subset(skittles, select = -c(Bag) )
require(HardyWeinberg)
#Create a Ternaryplot
HWTernaryPlot(dLactose,100,pch=19, cex=2, region=1,hwcurve=TRUE, curvecols=c("red", "green"), vbounds=FALSE, vertex.cex=2, verbose=TRUE)

ternary plot, Skittle example

Figure 3. Ternary plot of our Skittle critter data.

What do we have? The function plots three convex curved lines. The green points are the heterozygote (GO) frequencies. They all fall on the middle line, as expected, because I had used HW to calculate frequency of the heterozygotes. If any population had numbers of observed heterozygotes different from expected values, then the population point would be represented by a red point and it would fall in one of the regions above or below the curved lines.

Question

  1. Repeat the Skittles example, but replace with counts for purple (p) and red (q) candies (scroll down to data below, or click here).
    1. Optional: A more realistic example would be to draw 2 candies from Skittles bag and record the counts (e,g, how many purple+ purple, purple+red, red+red pairs drawn), then make Ternary plots on the observed and not the expected frequencies.
  2. Genetic example. The ternary plot is useful for displaying population genetic frequency data. For example, ability to digest lactose, i.e., lactase persistence, is in part due to genotype at SNP rs4988235 (Enattah et al 2002). Genotypes CC tend to be lactose intolerant, genotypes CT and TT are lactose tolerant. I gathered allele frequencies from the ALFA: Allele Frequency Aggregator for several human populations, calculated genotype frequencies assuming Hardy-Weinberg equilibrium. I also created results for a hypothetical population “Madeup.” (Scroll down to data below, or click here). Enter the data into R as a dataframe, eg, data.SNP, copy R code from this page, make the necessary changes, and recreate the plot shown in Figure 4. 
    • What do you conclude about the heterozygotes in Madeup population? 

ternary plot rs4988235

Figure 4. rs4988235 genotype frequencies, data.SNP.

  1. Add a new row of data to your rs4988235 data set, data.SNP. CC= 4, CT = 10, TT = 6. The data were derived from frequencies reported in Figure 2, Baffour-Awuah et al 2016 (PMC4308731). To add a new row, modify the code below
    data.SNP <- rbind(data.SNP, “PMC4308731” = c(4, 10, 6))
    Create another ternary plot, and address whether or not this new data set shows heterozygotes in agreement with Hardy Weinberg assumptions.

Quiz Chapter 4.8

Ternary plots

Data sets

Skittles Data

BagGREENORANGEREDPURPLE
bag14233
bag28248
bag33342
bag43412
bag55767
bag65123
bag713555
bag84252
bag96344
bag103253
bag115423
bag129968
bag130252
bag147367
bag155413
bag166242
bag172314

SNP Data

PopulationCCTT
Mambila9910
Ben Amir9910
Zaramo10000
Bedouin9550
Druze9370
Kuwaiti86131
Dutch124543
Finns32968
Swedes11387
Bengali87131
Naga10000
Mala88120
Han10000
Japanese10000
Koreans10000
Cheyene9370
Pima9820
Maya90100
Brazilian50429
Chilean60355
Colombian81181
Madeup40555

 


Chapter 4 contents