plotSunburst: plotSunburst

View source: R/plotSunburst.R

plotSunburstR Documentation

plotSunburst

Description

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.

Usage

plotSunburst(tax, relab = NULL, palettes = NULL, highlight = NULL, ...)

Arguments

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. c("Bacteroidetes" = "Oranges", "Firmicutes" = "Greens")). Palettes should be from rColorBrewer. If the number of palettes specified doesn't include all phyla in the tax table, only the specified ones will be coloured and the rest will be in grey. If palettes is set to NULL, the default colours selected by sunbrustR will be used

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. list("Family"=c("Enterococcaceae","Ruminacoccaceae"). This is applied after palettes is used to colour by phylum if palettes argument is specified.

...

additional arguments for sunburstR::sunburst()

Details

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.

Value

interactive sunburst plot that can be included in rmarkdown or shiny.

Examples

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')))

OxfordCMS/OCMSutility documentation built on Feb. 27, 2025, 8:19 p.m.