## data input, 20% most abundant taxa, asinh-transformed counts
data(cc)
log5 <- function(x) log(.5 + x)
cc1 <- normalize(trimq(cc, taxonQ=.7), transform=log5)
## select and pre-process metadata to plot
df <- as.data.frame(samples(cc))
df$pH <- (5 * ((.25 + df$pH) %/% .5)) / 10
## create dendrogram, in desired order
ddr <- as.dendrogram(hclust(dist(t(communities(cc1)))))
o <- with(samples(cc1), order(nugent_2_group))
ddr <- rev(reorder(ddr, o))
df <- df[order.dendrogram(ddr),]
## plot
dendroribbons(ddr, df)
Run the code above in your browser using DataLab