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",
  sink_abundant_groups = TRUE
)

Arguments

mdf_group

data.frame, data frame containf microbiome data

cdf

data.frame containing the color key

group_level

string of larger taxonomic group

subgroup_level

string of smaller taxonomic group

sample_variable

sample variable to reorder (x- axis component for plot)

sink_abundant_groups

logical reorder the phylum groups so the most abundant is the bottom group

order

string of subgroup to reorder by

Value

list

  • "mdf" reordered melted data frame, ready for plotting

  • "cdf" reordered manual color filling according to new order

Examples

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 = "Bacteroides")