count_cherries: Counts the number of cherries in a tree

View source: R/count_cherries.R

count_cherriesR Documentation

Counts the number of cherries in a tree

Description

Given a set of phylogenetic tree(s) returns the number of cherries in each one.

Usage

count_cherries(tree)

Arguments

tree

A tree (phylo or multiPhylo object).

Details

Cherries are components of a phylogenetic tree defined as internal nodes with exactly two terminal descendants.

This function simply counts the number present in a given tree.

Note that any fully dichotomous phylogenetic tree must have at least one cherry.

Value

Returns a vector of cherry counts for each tree retaining the order in which they were supplied.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples


# Create simple two-cherry tree:
tree <- ape::read.tree(text = "((A,B),(C,D));")

# Show count of cherries is two:
count_cherries(tree = tree)

# Create a star tree:
tree <- ape::read.tree(text = "(A,B,C,D);")

# Show count of cherries is zero:
count_cherries(tree = tree)


graemetlloyd/Claddis documentation built on May 9, 2024, 8:07 a.m.