Skip to contents

Return the tip labels of a tree as a character vector, whether the tree is already an ape::phylo object in memory or lives in a Newick or Nexus file on disk. Convenience wrapper around tree$tip.label that also handles file input and multi-tree files (returns the tips of the first tree).

Usage

pr_extract_tips(tree)

Arguments

tree

An ape::phylo object, or a length-1 character vector giving the path to a Newick (.nwk, .tre, .tree, .newick) or Nexus (.nex, .nexus) file. Format is auto-detected.

Value

A character vector of tip labels (one element per tip).

See also

pr_normalize_names() for cleaning tip labels before joining against a data frame.

Other name utilities: pr_normalize_names()

Examples

data(tree_jetz)
head(pr_extract_tips(tree_jetz))
#> [1] "Amytornis_barbatus"  "Amytornis_merrotsyi" "Amytornis_dorotheae"
#> [4] "Amytornis_woodwardi" "Amytornis_striatus"  "Amytornis_housei"