R/color_mapping_functions.R
create_color_dfs.Rd
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
)
data.frame, melted data frame containing microbiome data
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.
integer number of top subgroups to show for each selected group the max is 4 top subgroups
string of larger taxonomic group
string of smaller taxonomic group
logical, determines which palette to use, color vision deficent (microshades_cvd_palettes) or microshades_palettes
logical most abundant shades oriented at the top of the stack otherwise, most abundant shades are bottom oriented
list
"mdf" melted data frame to pass into ggplot2
"cdf" mapping to be used in manual color filling
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")
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)