Use create_color_dfs() to create a specialized data frames containing color and abundance organized microbiome data.

create_color_dfs(
  mdf,
  selected_groups = c("Proteobacteria", "Actinobacteria", "Bacteroidetes", "Firmicutes"),
  top_n_subgroups = 4,
  group_level = "Phylum",
  subgroup_level = "Genus",
  cvd = FALSE,
  top_orientation = FALSE
)

Arguments

mdf

data.frame, melted data frame containing microbiome data

selected_groups

list of groups in group_level taxomomy to specify and color in plot. The vector order is the stacking order. "Other" is always on the top of the stack, but then the rest will follow. The default is "Proteobacteria", "Actinobacteria", "Bacteroidetes", "Firmicutes". "Firmicutes" is on the bottom of the stack.

top_n_subgroups

integer number of top subgroups to show for each selected group the max is 4 top subgroups

group_level

string of larger taxonomic group

subgroup_level

string of smaller taxonomic group

cvd

logical, determines which palette to use, color vision deficent (microshades_cvd_palettes) or microshades_palettes

top_orientation

logical most abundant shades oriented at the top of the stack otherwise, most abundant shades are bottom oriented

Value

list

  • "mdf" melted data frame to pass into ggplot2

  • "cdf" mapping to be used in manual color filling

Details

The top group categories are user specified through the selected_groups parameter, and top subgroup categories are dynamically generated based on abundance. For the top group, the categories not in selected_groups will be changed to "Other". The top_n_subgroups will be determined for each selected group.

Notes:

  • In SILVA 138, some phylum names are different and you should consider passing in the vector c("Proteobacteria", "Actinobacteriota", "Bacteroidota", "Firmicutes")

Examples

library(phyloseq)
data(GlobalPatterns)

mdf <- prep_mdf(GlobalPatterns)

colorframe <- create_color_dfs(mdf)
colorframe <- create_color_dfs(mdf, selected_groups = c("Proteobacteria", "Actinobacteriota", "Bacteroidota", "Firmicutes"))
#> Error in create_color_dfs(mdf, selected_groups = c("Proteobacteria", "Actinobacteriota",     "Bacteroidota", "Firmicutes")): some 'selected_groups' do not exist in the dataset. Consider SILVA 138 c('Proteobacteria', 'Actinobacteriota', 'Bacteroidota', 'Firmicutes')
colorframe <- create_color_dfs(mdf, cvd = TRUE)