Internal node number

Some of the functions in ggtree work with clade and accept a parameter of internal node number. To get the internal node number, user can use geom_text2 to display it:

Another way to get the internal node number is using MRCA() function by providing a vector of taxa names. The function will return node number of input taxa’s most recent commond ancestor (MRCA). It works with tree and graphic object.

## [1] 17
## [1] 21
## [1] 17

View Clade

ggtree provides a function viewClade to visualize a clade of a phylogenetic tree.

Group Clades

The ggtree package defined several functions to manipulate tree view. groupClade and groupOTU methods were designed for clustering clades or related OTUs. groupClade accepts an internal node or a vector of internal nodes to cluster clade/clades.

Both groupClade and groupOTU work fine with tree and graphic object.

The following command will produce the same figure.

With groupClade and groupOTU, it’s easy to highlight selected taxa and easy to select taxa to display related features.

Group OTUs

groupOTU accepts a vector of OTUs (taxa name) or a list of OTUs. groupOTU will trace back from OTUs to their most recent common ancestor and cluster them together. Related OTUs are not necessarily within a clade, they can be monophyletic (clade), polyphyletic or paraphyletic.

groupOTU can also input a list of tip groups.

groupOTU also works with graphic object.

The following example use groupOTU to display taxa classification.

Collapse clade

With collapse function, user can collapse a selected clade.

Expand collapsed clade

The collapsed clade can be expanded via expand function.

Scale clade

Collpase selected clades can save some space, another approach is to zoom out clade to a small scale.

Of course, scaleClade can accept scale larger than 1 and zoom in the selected portion.

Rotate clade

A selected clade can be rotated by 180 degree using rotate function.

Flip clade

The positions of two selected clades (should share a same parent) can be flip over using flip function.

Open tree

ggtree supports fan layout and can also transform the circular layout tree to a fan tree by specifying an open angle to open_tree function.

Rotate tree

Rotating a circular tree is supported by rotate_tree function.

Interactive tree manipulation

Interactive tree manipulation is also possible, please refer to https://guangchuangyu.github.io/2016/06/identify-method-for-ggtree.