Learn R Programming

treenomial

Overview

The package treenomial is an application of polynomials that uniquely describe trees. It provides tools for tree analysis and comparison based on polynomials. The core functions are:

  • treeToPoly(): convert rooted unlabeled binary trees to tree distinguishing polynomials described with coefficient matrices

  • polyToDistMat(): construct a distance matrix from multiple coefficient matrices using a distance measure

For the mathematical description of the tree defining polynomial see:

Liu, Pengyu. “A tree distinguishing polynomial.” arXiv preprint arXiv:1904.03332 (2019).

Installation

To install using CRAN:

install.packages("treenomial")

For the development version:

library(devtools)
install_github("mattgou1d/treenomial")

Example tree and polynomial

Consider a three tip tree:

library(ape)
library(treenomial)

threeTipTree <- rtree(3, rooted = T)
plot.phylo(threeTipTree, use.edge.length = F, show.tip.label = F, direction = "downwards")

It’s polynomial is x^3+xy+y which can equivalently be described with a coefficient matrix where the element in the ith row, jth column represents the y^(i-1) * x^(j-1) coefficient:

treeToPoly(threeTipTree, varLabels = T)
#>     x^0 x^1 x^2 x^3
#> y^0   0   0   0   1
#> y^1   1   1   0   0
#> y^2   0   0   0   0

Using the coefficients of the polynomials, distances between trees can be compared, below the two closest trees to a random target tree are found from a random sample:

# random 12 tip target tree 
target <- rtree(12)

# random sample of 100 trees
sample <- rmtree(100,12)

minInfo <- plotExtremeTrees(target,sample, n = 2, comparison = "min", type = "d")

Copy Link

Version

Install

install.packages('treenomial')

Monthly Downloads

64

Version

1.1.4

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Matthew Gould

Last Published

June 6th, 2022

Functions in treenomial (1.1.4)

treeToDistMat

Calculates the distance matrix from a list of phylo objects
treeJuliaSet

Plots a Julia Set for a tree
treeToPoly

Convert trees to coefficient matrices
wedge

Performs the wedge operation
treeDist

Calculates the distance between trees
polyToDistMat

Calculates the distance matrix from a list coefficient matrices
plotExtremeTrees

Plot the min/max distance trees from a target tree
polyDist

Calculates the distance between coefficient matrices
alignPoly

Align various types of coefficient matrices
allTrees

Calculate all full unordered m-ary trees up to n tips