Integrating OTU abundance heatmap and collapsed tree

100 views
Skip to first unread message

Chun-Hui Gao

unread,
Apr 16, 2018, 11:43:37 AM4/16/18
to ggtree
Hi,

I have a microbiome dataset, and want to show the species abundance with phylogenic tree. 

# random tree of OTUs
set.seed(0)
tr <- rtree(100)

# taxnomy of the OTUs
tax <- data.frame(name = sample(tr$tip.label),
                  phylum = sapply(sample(1:3,Ntip(tr),replace = TRUE), function(x) paste("phylum",x,sep="_")),
                  class = sapply(sample(1:10,Ntip(tr),replace = TRUE), function(x) paste("class",x,sep="_")),
                  family = sapply(sample(1:12,Ntip(tr),replace = TRUE), function(x) paste("family",x,sep="_")),
                  genus = sapply(sample(1:20,Ntip(tr),replace = TRUE), function(x) paste("genus",x,sep="_"))
                  )

# species abundance of the OTUs in samples
data <- data.frame(matrix(runif(600),ncol=6),row.names = sample(tr$tip.label))

p <- ggtree(tr) + geom_tiplab(align = TRUE)

gheatmap(p,data)


This can be done by these codes and give a figure like this.


















But what I want is more. Since these OTUs are group to different phylum, class, family and genus, it may give more information by collapsed tree leaves at a given phylogenic level, for example genus. 

I draw a picture to show this thought, but don't know how to do using R + ggtree.

This picture shows: 1) OTUs in this tree were collapsed at genus level. 2) the genus nodes were shaped and/or colored by different genus. 3) name of genus were used as label. 4) heatmap of three genus were integrated with the tree.



Reply all
Reply to author
Forward
0 new messages