I’ve been having great success with ggtree now and have recommended it to several colleages here in Oxford.
Is there any way to seperate the legend in heatmaps? Eg I have plotted a tree in a circular style with outer rings given extra data - I would like a seperate key for each ring - is this possible?
This is a user question. Plotting multiple heatmaps that align to the phylogenetic tree is easy with gheatmap
function.
Here is a simple example:
library("ggplot2")
library("ggtree")
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
circ <- ggtree(tree, layout = "circular")
df <- data.frame(first=c("a", "b", "a", "c", "d", "d", "a", "b", "e", "e", "f", "c", "f"),
second= c("z", "z", "z", "z", "y", "y", "y", "y", "x", "x", "x", "a", "a"))
rownames(df) <- tree$tip.label
p1 <- gheatmap(circ, df[, "first", drop=F], offset=.8, width=.1,
colnames_angle=90, colnames_offset_y = .25)
p2 <- gheatmap(p1, df[, "second", drop=F], offset=5, width=.1,
colnames_angle=90, colnames_offset_y = .25)
Continue reading