phylostructure: Generating Node Relations

Description Usage Arguments Details Value Author(s) Examples

View source: R/phylostructure.R

Description

phylostructure returns the neighboring nodes and descendant leaves for each internal node of a binary phylogenetic tree.

Usage

1
phylostructure(phylotree)

Arguments

phylotree

A phylo-class object as in the phyloseq package. The tree has to be binary.

Details

For each internal node (i.e. non-leaf node) in phylotree, this function calculates its parent node, child nodes and all of its descendant leaves. The labeling of nodes are the same as in phylotree$edge, which is assumed to obey the following convention. Leaves are labeled from 1 to ntaxa(phylotree) and internal nodes are labeled from ntaxa(phylotree) + 1 to ntaxa(phylotree) + phylotree$Nnode. The root label is ntaxa(phylotree) + 1. Parent node always has a lower label than its child internal nodes.

Value

A list containing the following components:

phylotree

Input object

phylochildren

Numerical matrix of child node labels. The kth row contains the children node labels of node k. Leaf nodes have their their row vectors set to zero.

phyloparent

Numerical vector of parent node labels. The kth element contains the parent node label of node k. Root node has its parent set to zero.

descendant

Logical matrix of decendant leaves. The kth row shows whether the leaves are descendants of node k.

Author(s)

Yunfan Tang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(ape)
set.seed(10)

## Analyze a random binary phylogenetic tree with 6 leaf nodes
pstrct <- phylostructure(rtree(6))
## Show children of node 7 (root):
pstrct$phylochildren[7, ]
## Show parent of node 1:
pstrct$phyloparent[1]
## List all leaf nodes under node 8:
which(pstrct$descendant[8, ])

yunfantang/PhyloScan documentation built on May 4, 2019, 7:44 p.m.