matTree: Transform a phylo object into a matrix.

View source: R/tree_matTree.R

matTreeR Documentation

Transform a phylo object into a matrix.

Description

matTree transforms a phylo tree into a matrix. The entry of the matrix is node number. Each row represents a path connecting a leaf node and the root. The columns are arranged in the order as the path passing the nodes to reach the root.

Usage

matTree(tree)

Arguments

tree

A phylo object

Value

A matrix

Author(s)

Ruizhu Huang

Examples

library(ggtree)

data(tinyTree)
ggtree(tinyTree, branch.length = 'none') +
 geom_text2(aes(label = node))


# each row of the matrix representing a path.
# the first column is leaf nodes; the last non-NA value in a row is the root
mat <- matTree(tree = tinyTree)


fionarhuang/TreeSummarizedExperiment documentation built on June 11, 2025, 9:42 a.m.