plotSunburst | R Documentation |
Creates interactive sunburst plot based on taxonomy. The sunburst plot can show areas based on relative abundance or based on the number of taxa at a given taxonomic level.
plotSunburst(tax, relab = NULL, palettes = NULL, highlight = NULL, ...)
tax |
dataframe. taxonomy table with featureID, Phylum, Class, Order, Family, Genus as columns. See Details about NAs in the taxonomy table |
relab |
dataframe. default NULL. relative abundance data with samples in columns and features in rows. Feature IDs in the rownames. |
palettes |
named vector. default NULL. Can specify a palette for each
Phylum, where values are the colour palette to use and name
is the corresponding phylum (e.g.
|
highlight |
named list. default NULL. This can be used to
highlight all taxa relevant to a specific taxon and any taxa that
are not specified will be coloured as grey.
e.g. |
... |
additional arguments for |
When relab
is set to NULL, the sunburst plot will show the number of
taxa observed at each taxonomic level. When relative abundance is supplied,
sunburst leaves reflect mean relative abundance of each taxon
across all samples
Note NAs in the taxonomy table cause colouring to be assigned in unexpected
order so it is best to use ocms_reannotateTax
to apply a taxonomy
roll-down and remove all NAs. sunburstR
uses hyphens (-
) to
distinguish taxonomic levels so any hyphens in the taxonomy name will be
interpreted as two separate levels. Therefore, all hyphens are silently and
automatically removed from taxonomy names.
interactive sunburst plot that can be included in rmarkdown or shiny.
data("dss_example")
#' set count feature ids as rownames
count_df <- dss_example$merged_abundance_id %>%
column_to_rownames('featureID')
#' clean up some sample names
colnames(count_df) <- paste0('id', colnames(count_df))
tax_df <- dss_example$merged_taxonomy
#' aggregate counts
agg_gen <- aggregateCount(count_df[tax_df$featureID,], tax_df, "Genus")
count_genus <- agg_gen$count_df
#' reannotate taxonomy
tax_genus <- reannotateTax(agg_gen$tax_df)
relab <- relab(count_genus)
#' color specific phyla
plotSunburst(relab = NULL, tax = tax_genus,
palettes = c("Proteobacteria" = "Oranges",
"Bacteroidetes" = "Greens"))
#' color specific phyla taking into account of relative abundance
plotSunburst(relab = relab, tax = tax_genus,
palettes = c("Proteobacteria" = "Oranges", "Bacteroidetes" = "Greens"))
#' highlight specific genera
plotSunburst(relab = relab, tax = tax_genus,
palettes = c("Bacteroidetes" = "Greens",'Firmicutes'='Blues'),
highlight = list("Genus" = c("Bacteroides",'Clostridium XlVa')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.