phyltree_paths: Extract path information from a phylogenetic tree

View source: R/phyltree_paths.R

phyltree_pathsR Documentation

Extract path information from a phylogenetic tree

Description

The function computes for each node its path to the root and its distance to the root. It returns an “enhanced” phylo type tree.

Usage

phyltree_paths(phyltree)

Arguments

phyltree

The phylogeny - an object of class phylo, i.e. tree in ape format. The "standard" ape node indexing is assumed: for a tree with n tips, the tips should have indices 1:n and the root index n+1.

Details

The function removes a root edge, i.e. $root.edge if one is present.

Value

The function returns a phylo type tree with the below additional fields.

Ntips

Number of tips on the tree.

path.from.root

A list of length equalling the number of nodes. Each entry is a list made up of two fields nodes and edges. nodes are the nodes on the path to the root and edges the edges.

time.of.nodes

A vector of length equalling the number of nodes. Each entry is the node's distance from the root. This is only calculated if the input tree has the $edge.length field.

tree_height

The height of the tree if it is ultrametric, otherwise the length of the longest path from root to tip.

tip_species_index

The node numbers corresponding to tip nodes, should equal 1:n.

internal_nodes_index

The node numbers corresponding to internal nodes, should equal (n+1):(2n-1).

root_index

The node number corresponding to the root, should equal n+1.

Note

The ape and phangorn packages include related tree manipulation functions.

Author(s)

Krzysztof Bartoszek

See Also

ape, phangorn

Examples

    RNGversion(min(as.character(getRversion()),"3.6.1"))
    set.seed(12345, kind = "Mersenne-Twister", normal.kind = "Inversion")
    phyltree<-ape::rtree(5)
    phyltree_augmented<-phyltree_paths(phyltree)
    RNGversion(as.character(getRversion()))

mvSLOUCH documentation built on Nov. 21, 2023, 1:08 a.m.