How it works...

This code achieves a lot very quickly. It can do this by virtue of its ggplot-like layer syntax. Here's what each step does and its output:

  1. Load in a tree from a file. The tree here has 191 tips, so it's quite large. It happens to be in Newick format, so we use the ape read.tree() function. Note that we don't need to have a treedata object for ggtree in subsequent steps; the phylo object returned from read.tree() is perfectly acceptable to ggtree().
  2. Create a basic tree with ggtree(). This function is a wrapper for a longer ggplot-style syntax, specifically, ggplot(itol) + aes(x,y) + geom_tree() + theme_tree(). Hence, all the usual ggplot functions can be used as extra layers in the plot. The code in this step gives us the ...

Get R Bioinformatics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.