This function only works if your tax table has the following headers: Kingdom, Phylum, Class, Order, Family, Genus.
First, if you haven’t installed the package, install the hiervis package and load phyloseq. I use the GlobalPatterns dataset for the demo.
#install.packages(devtools)
#devtools::install_github(fbreitwieser/hiervis)
library(phyloseq)
data("GlobalPatterns")
source("plot_hierarchy.R")
It really is as easy as that! This diagram is interactive, so click around to explore the dataset.
Note: increasing the number of taxa risks overplotting and the function slows down considerably. Interactive Sankey diagrams are better than stacked bar plots, but they still aren’t perfect!
plot_hierarchy(physeq = GlobalPatterns, number_of_taxa_to_plot = 50)
These are essentially Krona plots.
plot_hierarchy(physeq = GlobalPatterns, number_of_taxa_to_plot = 50, plot_type = "sunburst")