count_tips_per_node {castor} | R Documentation |
Given a rooted phylogenetic tree, count the number of tips descending (directy or indirectly) from each node.
count_tips_per_node(tree)
tree |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |
The asymptotic time complexity of this function is O(Nedges), where Nedges is the number of edges.
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.
Stilianos Louca
# 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")