Generating trees as a subclass of graphs with the igraph package is the de-facto standard in R
.
The package ggtree is very versatile in tree visualization. It seems some plotting functionalities go beyond the capabilties of igraph.
This leads to the question:
Is there a way to use a valid tree graph object generated by igraph package (i.e. example below) as input for a visualization with ggtree
?
library(igraph)
g <- graph.tree(20, 2)
Visualizing phylogenetic trees with ggtree is easy by using a single command ggtree(tree) . The ggtree package provides several geometric layers to display tree components such as tip labels, symbolic points for both external and internal nodes, root-edge, etc.
After you've loaded your tree in R, visualization is really simple. The ggtree function directly plots a tree and support several layouts, such as rectangular, circular, slanted, cladogram, time-scaled, etc. Add a tree scale. You can easily turn your tree into a cladogram with the branch.
A phylogenetic tree can be annotated by mapping different line type, size, color or shape to the branches or nodes that have been assigned to different groups. Treeio package parses diverse annotation data from different software outputs into S4 phylogenetic data objects.
The ggtree package is a general tool for tree visualization and annotation and it fits the ecosystem of R packages. Most of the S3/S4 tree objects defined by other R packages are also supported by ggtree, including phylo (session 4.2), multiPhylo (session 4.4), phylo4 , phylo4d , phyloseq , and obkData .
This is a good idea.
ggtree is designed for phylogenetic analysis. Some of the functionalities may not be applied to other objects like igraph directly. To make the support more smoothly is to convert the igraph object as a phylo object. So that after conversion, ggtree can be used to visualize it and all functionalities are supported.
The issue for conversion is that igraph allow singleton as in the example posted while phylo don't allow since it's meaningless in evolution.
I will consider to develop a conversion function in future version.
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution. doi:10.1111/2041-210X.12628
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With