For a Recipe with at least one preprocessing or DA operation run the steps in a convenient order.
Usage
prep(rec, parallel = TRUE, workers = 4, force = FALSE)
# S4 method for class 'Recipe'
prep(rec, parallel = TRUE, workers = 4, force = FALSE)
Arguments
- rec
A
Recipe
object. and furrr packages.- parallel
if FALSE, no palatalization. if TRUE, parallel execution using future and furrr packages.
- workers
Number of workers for palatalization.
- force
Force the reexecution of all steps. This remove previous results.
Examples
data(metaHIV_phy)
## Define Recipe
rec <-
recipe(metaHIV_phy, var_info = "RiskGroup2", tax_info = "Class") |>
step_subset_taxa(tax_level = "Kingdom", taxa = c("Bacteria", "Archaea")) |>
step_filter_taxa(.f = "function(x) sum(x > 0) >= (0.03 * length(x))") |>
step_maaslin()
## Prep Recipe
da_results <- prep(rec)
## If you try
## Consensus strategy
n_methods <- 2
da_results <- bake(da_results, count_cutoff = n_methods)
da_results
#> ── DAR Results ─────────────────────────────────────────────────────────────────
#> Inputs:
#>
#> ℹ phyloseq object with 278 taxa and 156 samples
#> ℹ variable of interes RiskGroup2 (class: character, levels: hts, msm, pwid)
#> ℹ taxonomic level Class
#>
#> Results:
#>
#> ✔ maaslin__Sad_cake diff_taxa = 146
#>
#> ℹ 146 taxa are present in all tested methods
#>
#> Bakes:
#>
#> ◉ 1 -> count_cutoff: 2, weights: NULL, exclude: NULL, id: bake__Dutch_letter
## If you try to run prep on an object of class PrepRecipe it returns an
## error.
err <- testthat::expect_error(prep(da_results))
err
#> <error/rlang_error>
#> Error in `prep()`:
#> ! The input Recipe has already been prep!
#> ℹ To force the rerun of all steps plese run prep(rec, force = T)
#> ---
#> Backtrace:
#> ▆
#> 1. └─pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
#> 2. └─pkgdown::build_site(...)
#> 3. └─pkgdown:::build_site_local(...)
#> 4. └─pkgdown::build_reference(...)
#> 5. ├─pkgdown:::unwrap_purrr_error(...)
#> 6. │ └─base::withCallingHandlers(...)
#> 7. └─purrr::map(...)
#> 8. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 9. ├─purrr:::with_indexed_errors(...)
#> 10. │ └─base::withCallingHandlers(...)
#> 11. ├─purrr:::call_with_cleanup(...)
#> 12. └─pkgdown (local) .f(.x[[i]], ...)
#> 13. ├─base::withCallingHandlers(...)
#> 14. └─pkgdown:::data_reference_topic(...)
#> 15. └─pkgdown:::run_examples(...)
#> 16. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 17. └─downlit::evaluate_and_highlight(...)
#> 18. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 19. └─evaluate:::evaluate_call(...)
#> 20. ├─evaluate (local) timing_fn(...)
#> 21. ├─evaluate (local) handle(...)
#> 22. │ └─base::try(f, silent = TRUE)
#> 23. │ └─base::tryCatch(...)
#> 24. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 25. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 26. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 27. ├─base::withCallingHandlers(...)
#> 28. ├─base::withVisible(...)
#> 29. └─evaluate:::eval_with_user_handlers(expr, envir, enclos, user_handlers)
#> 30. └─base::eval(expr, envir, enclos)
#> 31. └─base::eval(expr, envir, enclos)
#> 32. ├─testthat::expect_error(prep(da_results))
#> 33. │ └─testthat:::expect_condition_matching(...)
#> 34. │ └─testthat:::quasi_capture(...)
#> 35. │ ├─testthat (local) .capture(...)
#> 36. │ │ └─base::withCallingHandlers(...)
#> 37. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#> 38. ├─dar::prep(da_results)
#> 39. └─dar::prep(da_results)
## You can force the overwrite with:
prep(rec, force = TRUE)
#> ── DAR Results ─────────────────────────────────────────────────────────────────
#> Inputs:
#>
#> ℹ phyloseq object with 278 taxa and 156 samples
#> ℹ variable of interes RiskGroup2 (class: character, levels: hts, msm, pwid)
#> ℹ taxonomic level Class
#>
#> Results:
#>
#> ✔ maaslin__Sad_cake diff_taxa = 146
#>
#> ℹ 146 taxa are present in all tested methods
#>
## This function can operate in parallel thanks to future and furrr packages.
prep(rec, parallel = TRUE, workers = 2)
#> ── DAR Results ─────────────────────────────────────────────────────────────────
#> Inputs:
#>
#> ℹ phyloseq object with 278 taxa and 156 samples
#> ℹ variable of interes RiskGroup2 (class: character, levels: hts, msm, pwid)
#> ℹ taxonomic level Class
#>
#> Results:
#>
#> ✔ maaslin__Sad_cake diff_taxa = 146
#>
#> ℹ 146 taxa are present in all tested methods
#>