In this short recipe, we'll look at how easy it can be to manipulate trees; specifically, how to pull out a subtree as a new object and how to combine trees into other trees.
Extracting and working with subtrees using ape
Getting ready
We'll need a single example tree; the mammal_tree.nwk file in the datasets/ch4 folder will be fine. All the functions we require can be found in the ape package.
How to do it...
Extracting and working with subtrees using ape can be executed using the following steps:
- Load the ape library and then load the tree:
library(ape)
newick...