treeToPoly {treenomial} | R Documentation |
Convert trees to coefficient matrices
Description
Converts rooted full binary trees to tree distinguishing polynomials described with coefficient matrices.
Usage
treeToPoly(
trees,
type = c("default", "yEvaluated", "tipLabel"),
y,
varLabels = FALSE,
numThreads = -1
)
Arguments
trees |
a single phylo object or a list of phylo objects |
type |
one of:
|
y |
the y value to evaluate the polynomial at when type is “yEvaluated”, ignored otherwise |
varLabels |
boolean for whether to add row and column names corresponding to the variables in the polynomial |
numThreads |
number of threads to be used, the default (-1) will use the number of cores in the machine and numThreads = 0 will only use the main thread |
Value
the resulting coefficient matrix or matrices of the form:
- “real”
a real matrix where the ith row, jth column represents the x^(j-1)*y^(i-1) coefficient
- “yEvaluated”
a vector where the kth column represents the x^(k-1) coefficient
- “tipLabel”
given trees with two unique tip labels “a”, “b” a complex matrix where the ith row, jth column represents the a^(i-1)*b^(j-1) coefficient
Examples
library(treenomial)
library(ape)
# generate a tree
tree <- rtree(n = 30, rooted = TRUE)
# a real coefficient matrix
treeToPoly(tree, varLabels = TRUE, numThreads = 0)
# complex coefficient vector for the tree
treeToPoly(tree, type = "yEvaluated", y = 1+1i, varLabels = TRUE, numThreads = 0)
# for a list of trees
treeToPoly(rmtree(4, 20), varLabels = TRUE, numThreads = 0)