There is an increasing box of tricks for display data on phylogenetic trees. However, it can be difficult to visualize lots of different values on the internal branches of trees. Here, I show phylo.ternary.plot – a function for summarizing (specificaly) three different sets of results on a phylogeny.

source("phylo.ternary.plot.R")

The function, which you can download here, shows the results of analyses where the branch lengths of a phylogeny have been changed to represent a rate. Here, I will use two analyses from BayesTraits (for size and shape) and one from PAML (showing dN/dS). The function itself takes five arguments:

The function requires a few packages

  library(tricolore)
  library(ape)
  library(dplyr)
  library(grid)
  library(gridExtra)
  library(ggplot2)
  library(ggtree)

source("phylo.ternary.plot.R")

Now let’s load the phylogenetic data

 base.phy <- read.nexus("coracii.nex")
 targetPhy1 <- read.nexus("summaryPaml.nex")
 targetPhy2 <- read.nexus("summaryShapeTree.nex")
 targetPhy3 <- read.nexus("summarySizeTree.nex")
 
 # and their names
 names <- c("dN/dS", "rateShapeEvol", "rateSizeEvol")

For comparison, let’s see what each of these trees look like when plotted individually

par(mfrow=c(2,2))
plot(base.phy, no.margin = TRUE)
plot(targetPhy1, no.margin = TRUE)
plot(targetPhy2, no.margin = TRUE)
plot(targetPhy3, no.margin = TRUE)

Now let’s look like when all three are visualized on the same phylogeny

res <- phylo.ternary.plot(source.phy = base.phy, 
                   targetPhy1 = targetPhy1, 
                   targetPhy2 = targetPhy2, 
                   targetPhy3 = targetPhy3, 
                   names = names)

res[[1]]

print(res[[2]])

The individual points in the legend correspond to individual branches on the phylogeny. You can see the one highly blue branch corresponds to the phylogeny with the high rate of shape evolution. It’s a fairly specific way of showing data on a phylogeny, but i think it has potential utility.