Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot igraph tree objects with ggtree

Tags:

r

igraph

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)
like image 958
user2030503 Avatar asked Jul 15 '15 21:07

user2030503


People also ask

How do you visualize a phylogenetic tree?

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.

How do you visualize a phylogenetic tree in R?

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.

How do you annotate a phylogenetic tree?

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.

What is Ggtree?

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 .


1 Answers

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.

reference

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.

like image 96
Guangchuang Yu Avatar answered Sep 28 '22 15:09

Guangchuang Yu