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:
- 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().
- 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 ...