getClade: Get the node of a given monophyletic group.

View source: R/getClade.R

getCladeR Documentation

Get the node of a given monophyletic group.

Description

This function aims to output the monophyletic group (node number or name) that contains a given set of terminal taxa, and only them.

Usage

getClade(tree, taxa, output = "number")

Arguments

tree

The phylogenetic tree to provide

taxa

The taxa (tips only) forming the monophyletic group (i.e., a monophyletic group is at least composed of two tips).

output

Optional. The format of the output (i.e., the node). Can be either the node number according to the nodelabels function (output="number", the default), or its number across nodes (output="node number"), or its name if this has been specified in the tree (output="name").

Details

This function heavy relies on the function getDescendants from the package phytools, which give all phylogenetical units (i.e., tips and nodes) that are contained in a given clade. By specifying only some of the descendants of a node, the function returns the apicalmost node uniting them (i.e., the crown group node).

Value

The number or name of the node containing the given tips.

Examples

newick_tree<-c("((((A,B),C),(D,E)),F);") # Create a simple tree in NEWICk format
tree<-ape::read.tree(text = newick_tree) # Read it
plot(tree)
ape::nodelabels() # Plot it together with node numbers

taxa<-c("A","B","C") # A monophyletic group
getClade(tree,taxa) # The actual 9 on the phylogeny
getClade(tree,taxa,output="node number") # The node number three going from the root

tree2<-ape::makeNodeLabel(tree,method="number",prefix="N") # Adding names to the nodes
plot(tree2)
ape::nodelabels(tree2$node.label)
getClade(tree2,taxa,output="name")


jacobmaugoust/ULT documentation built on May 16, 2023, 1:29 p.m.