reorder_samples_by: Reorder the samples or stacked group levels by abundance

reorder_samples_byR Documentation

Reorder the samples or stacked group levels by abundance

Description

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

Usage

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
)

Arguments

mdf_group

data.frame, data frame containing 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)

sample_ordering

list of samples in desired order for plotting

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

KarstensLab/microshades documentation built on June 11, 2024, 11:41 a.m.