How to do it...

Extracting and working with subtrees using ape can be executed using the following steps:

  1. Load the ape library and then load the tree:
library(ape)
newick <-read.tree(file.path(getwd(), "datasets", "ch4", "mammal_tree.nwk"))
  1. Get a list of all of the subtrees:
l <- subtrees(newick)
plot(newick)
plot(l[[4]], sub = "Node 4")
  1. Extract a specific subtree:
small_tree <- extract.clade(newick, 9)
  1. Combine two trees:
new_tree <- bind.tree(newick, small_tree, 3)
plot(new_tree)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.209.98