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. Deprecated; supply targets to add_model() instead.

tax_info

A character string of taxonomic levels that will be used in any context. Deprecated; supply tax_level to add_model() instead.

steps

list with steps.

Value

An object of class Recipe containing the microbiome object, an optional centralized model and the configured processing or DA steps. Legacy selector slots are retained for compatibility during the deprecation cycle.

Examples

data(metaHIV_phy)

## Define recipe
rec <-
  recipe(metaHIV_phy) |>
  add_model(~ RiskGroup2, targets = "RiskGroup2", tax_level = "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_deseq() |>
  step_maaslin()

## Prep recipe
da_results <- prep(rec)
#> Warning: Estimated rdf < 1.0; not estimating variance
#> Warning: Estimated rdf < 1.0; not estimating variance
#> Warning: Estimated rdf < 1.0; not estimating variance

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

## Results
cool(da_results)
#>  Baking with count_cutoff = 2
#> # A tibble: 1 × 9
#>   taxa_id taxa    contrast_id comparison contrast_type var   effect method_count
#>   <chr>   <chr>   <chr>       <chr>      <chr>         <chr> <chr>         <dbl>
#> 1 Otu_96  Bacter… RiskGroup2… RiskGroup… main          Risk… down              2
#> # ℹ 1 more variable: methods <chr>

## A recipe without a model can be used for preprocessing
rec <- recipe(metaHIV_phy)

rec
#> ── DAR Recipe ──────────────────────────────────────────────────────────────────
#> Inputs:
#> 
#>       phyloseq object with 451 taxa and 156 samples 
#>       undefined analysis target. Use add_model() to define the analysis! 
#>       undefined taxonomic level. Use add_model() to define the analysis! 
#> 

## Define the complete analysis configuration later
rec <- rec |>
  add_model(~ RiskGroup2, targets = "RiskGroup2", tax_level = "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 
#> 
#> Statistical model:
#> 
#>       ~RiskGroup2 
#> 
#> 

## When trying to add an identical step to an existing one, the system
## returns an information message.
rec <- step_aldex(rec)
rec <- step_aldex(rec)
#> ! This step is already defined with the same parameters and will be skipped.
#>  `rec %>% step_aldex(max_significance = 0.05, mc.samples = 128, denom = "all",
#>   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)`