R/color_mapping_functions.R
reorder_samples_by.Rd
This function will reorder the user selected subgroup taxa based on abundance, and can also
reorder the stacked groups levels based on abundance, using sink_abundant_groups
reorder_samples_by(
mdf_group,
cdf,
order_tax = "NA",
group_level = "Phylum",
subgroup_level = "Genus",
sample_variable = "Sample",
sample_ordering = NA,
sink_abundant_groups = TRUE
)
data.frame, data frame containing microbiome data
data.frame containing the color key
string of larger taxonomic group
string of smaller taxonomic group
sample variable to reorder (x- axis component for plot)
list of samples in desired order for plotting
logical reorder the phylum groups so the most abundant is the bottom group
string of subgroup to reorder by
list
"mdf" reordered melted data frame, ready for plotting
"cdf" reordered manual color filling according to new order
library(phyloseq)
data(GlobalPatterns)
mdf <- prep_mdf(GlobalPatterns)
color_obj <- create_color_dfs(mdf)
mdf_group <- color_obj$mdf
cdf <- color_obj$cdf
mdf_new <- reorder_samples_by(mdf_group, cdf)
mdf_new <- reorder_samples_by(mdf_group, cdf, order_tax = "Bacteroides")