count_tips_per_node {castor} | R Documentation |
Count descending tips.
Description
Given a rooted phylogenetic tree, count the number of tips descending (directy or indirectly) from each node.
Usage
count_tips_per_node(tree)
Arguments
tree |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |
Details
The asymptotic time complexity of this function is O(Nedges), where Nedges is the number of edges.
Value
An integer vector of size Nnodes, with the i-th entry being the number of tips descending (directly or indirectly) from the i-th node.
Author(s)
Stilianos Louca
See Also
Examples
# generate a tree using a simple speciation model
tree = generate_random_tree(list(birth_rate_intercept=1),max_tips=1000)$tree
# count number of tips descending from each node
tips_per_node = count_tips_per_node(tree);
# plot histogram of tips-per-node
barplot(table(tips_per_node[tips_per_node<10]), xlab="# tips", ylab="# nodes")
[Package castor version 1.8.2 Index]