subdivide_by_environment: Nest phyloseq objects according to sample variables

View source: R/phyloseq_subset.R

subdivide_by_environmentR Documentation

Nest phyloseq objects according to sample variables

Description

This function tries to mimic tidyr::nest, subsetting the phyloseq object based on all combinations of sample data.

Usage

subdivide_by_environment(
  physeq,
  variables,
  keep_variables = TRUE,
  keep_empty = TRUE,
  extract_list = FALSE,
  ...
)

Arguments

physeq

A phyloseq object

variables

A character vector containing the names of the variables to nest by, these variables should be discrete (factor, logical, integer, character)

keep_variables

Logical, should the names of the sample variables being used, be kept in the phyloseq objects?

keep_empty

Logical, should sample data combinations applying to no samples be kept? If TRUE, the coresponding phyloseq entity will be coded as NULL.

extract_list

Logical, if TRUE, only the the phyloseq list column is returned

...

Ignored

Details

If only one variable is provided, the element of the phyloseq column is named after this column

Value

A tibble where the variables are in the in the first columns, while the last column is named phyloseq and contains the corresponding objects. If extract_list=TRUE, only this last column is returned. phyloseq and contains the phyloseq object correspodning to the specific combination of sample variables.

Examples

library(phyloseq)
data("soilrep")
subdivide_by_environment(soilrep,variables=c('Treatment','warmed','clipped'),
keep_variables=FALSE,keep_empty=FALSE)

AlmaasLab/micInt documentation built on April 1, 2022, 10:37 a.m.