This function compares phylogenies to identify topological similarities. Let’s start by loading required libraries, and then visualize a set of example phylogenies.

library(ape)
library(phytools)
library(dplyr)

phy.set <- readRDS("phy.list.RDS")
par(mfrow=c(1,3))
plot(phy.set[[1]], cex=2)
plot(phy.set[[2]], cex=2)
plot(phy.set[[3]], cex=2)

We want to compare how the topology of the phylogenies on the center and right compare against the topology on the left. This function always assumes that the target topology of interest is the first entry in the list of trees. The function itself only takes a few arguments:

Let’s load the function, and define our parameters for plotting

source("plot.shared.nodes.R")

pie.cols <- c("#1b9e77", "#d95f02")

cex <- 2

Now we can visualize the plot, and add a legend.

par(mai = c(.5,.1,.1,.1))
plot.shared.nodes(phy.set, pie.cols, cex)
axisPhylo()
legend(x = 0, 
       y = 1.75, 
       legend = c("Present in comparison 1",
                                   "Present in comparison 2"), 
       fill = pie.cols, border = "black",
       cex = .8)