View source: R/taxon_colours.R
taxon_colours | R Documentation |
This function creates a named colour for each taxon in a phyloseq object at a specified taxonomic level.
taxon_colours(
ps_obj,
tax_level,
merged_label = "Other",
merged_clr = "grey90",
palette = NULL,
base_clr = "#008CF0"
)
ps_obj |
A phyloseq object |
merged_label |
The label of the merged taxa (usually "Other") |
merged_clr |
The colour to assign to the merged taxa |
palette |
A custom colour palette. Can be named. |
base_clr |
the colour from which to generate the palette if no palette is provided. |
If no palette is provided, colours are generated using the
nested_palette
function from the
ggnested
package. Only the taxonomic group with the merged_label
will get a custom colour. If a palette is provided, its colours will replace
the generated colours in the order in which they were specified. If a named
palette is provided, they will be used to replace specific colours.
A named character vector
data(GlobalPatterns)
# Get top taxa and generate a palette
top <- top_taxa(GlobalPatterns, n_taxa = 10)
pal <- taxon_colours(top$ps_obj, tax_level = "Phylum")
scales::show_col(pal)
# Generate a palette with a different base_clr
pal <- taxon_colours(top$ps_obj, tax_level = "Phylum", base_clr = "blue")
scales::show_col(pal)
# Provide a custom incomplete palette
pal <- taxon_colours(top$ps_obj, tax_level = "Phylum", palette = c("blue", "pink"))
scales::show_col(pal)
# Provide a custom incomplete named palette
pal <- taxon_colours(top$ps_obj, tax_level = "Phylum", palette = c(Cyanobacteria = "blue", Proteobacteria = "pink"))
scales::show_col(pal)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.