Skip to contents

A Recipe is a description of the steps to be applied to a data set in order to prepare it for data analysis.

Usage

recipe(
  microbiome_object = NULL,
  var_info = NULL,
  tax_info = NULL,
  steps = list()
)

Arguments

microbiome_object

Phyloseq-class object or TreeSummarizedExperiment-class object.

var_info

A character string of column names corresponding to variables that will be used in any context.

tax_info

A character string of taxonomic levels that will be used in any context.

steps

list with steps.

Value

An object of class Recipe with sub-objects:

phyloseq

object of class phyloseq with taxa abundance information.

var_info

A tibble that contains the current set of terms in the data set. This initially defaults to the same data contained in var_info.

tax_info

A tibble that contains the current set of taxonomic levels that will be used in the analysis.

Examples

data(metaHIV_phy)

## Define recipe
rec <-
  recipe(metaHIV_phy, var_info = "RiskGroup2", tax_info = "Phylum") |>
  step_subset_taxa(tax_level = "Kingdom", taxa = c("Bacteria", "Archaea")) |>
  step_filter_taxa(.f = "function(x) sum(x > 0) >= (0.3 * length(x))") |>
  step_metagenomeseq(rm_zeros = 0.01) |>
  step_maaslin()

## Prep recipe
da_results <- prep(rec)

## Consensus strategy
n_methods <- 2
da_results <- bake(da_results, count_cutoff = n_methods)

## Results
cool(da_results)
#>  Bake for count_cutoff = 2
#> # A tibble: 3 × 2
#>   taxa_id taxa         
#>   <chr>   <chr>        
#> 1 Otu_96  Bacteroidetes
#> 2 Otu_391 Lentisphaerae
#> 3 Otu_1   Euryarchaeota

## You can also crate a recipe without var and tax info
rec <- recipe(metaHIV_phy)

rec
#> ── DAR Recipe ──────────────────────────────────────────────────────────────────
#> Inputs:
#> 
#>       phyloseq object with 451 taxa and 156 samples 
#>       undefined variable of interest. Use add_var() to add it to Recipe! 
#>       undefined taxonomic level. Use add_tax() to add it to Recipe! 
#> 

## And define them later
rec <- rec |>
  add_var("RiskGroup2") |>
  add_tax("Genus")

rec
#> ── DAR Recipe ──────────────────────────────────────────────────────────────────
#> Inputs:
#> 
#>       phyloseq object with 451 taxa and 156 samples 
#>       variable of interes RiskGroup2 (class: character, levels: hts, msm, pwid) 
#>       taxonomic level Genus 
#> 
#> 

## When trying to add an identical step to an existing one, the system
## returns an information message.
rec <- step_ancom(rec)
rec <- step_ancom(rec)
#> ! This step is already defined with the same parameters and will be skipped: 
#> rec %>% step_ancom(fix_formula = c('RiskGroup2'), rand_formula = NULL, p_adj_method = c('holm'), prv_cut = 0.1, lib_cut = 0, s0_perc = 0.05, group = NULL, struc_zero = FALSE, neg_lb = FALSE, alpha = 0.05, n_cl = 1, verbose = FALSE, global = FALSE, pairwise = FALSE, dunnet = FALSE, trend = FALSE, rarefy = FALSE)

## The same with bake
da_results <- bake(da_results)
da_results <- bake(da_results)
#> ! This step is already defined with the same parameters and will be skipped: 
#> rec %>% step_bake(count_cutoff = NULL, weights = NULL, exclude = NULL)