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

View source: R/allTrees.R

allTreesR Documentation

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

Description

Return normal coefficient matrices, substituted y coefficient vectors, or phylo objects for all possible unordered full m-ary trees up to n tips. For binary trees (m = 2), the number of trees at each number of tips follows the Wedderburn-Etherington numbers.

Usage

allTrees(n, m = 2, type = c("default", "yEvaluated", "phylo"), y)

Arguments

n

max number of tips

m

max number of children for each node

type

one of:

“real”

tree distiguishing polynomials in two variables x (columns) and y (rows)

“yEvaluated”

tree distiguishing polynomials with y evaluated at a specified argument

“phylo”

phylo objects

y

the y value to evaluate the polynomial at when type is “yEvaluated”, ignored otherwise

Value

list of lists containing all the trees in type format for each number of tips

Note

only m = 2 is currently supported

Examples

library(treenomial)
library(ape)

# generate coefficient matrices describing the polynomials of all possible
# unordered full binary trees up to 10 tips

allBinTenRealCoeff <- allTrees(10, type = "phylo")

# number of trees at each number of tips follows Wedderburn-Etherington numbers
lengths(allBinTenRealCoeff)

# phylo type example, plot all 6 tip unordered full binary trees

# backup par options
oldpar <- par(no.readonly =TRUE)

allBinSixPhylo <- allTrees(6, type = "phylo")[[6]]
par(mfrow=c(1,6))
plots <- lapply(allBinSixPhylo, function(t){
  plot.phylo(ladderize(t), direction = "downwards", show.tip.label = FALSE)
})

# restore par options
par(oldpar)


treenomial documentation built on June 7, 2022, 1:08 a.m.