## -----------------------------------------------------------------------------
#| label: setup
#| include: false

# Nothing in this vignette is evaluated: it exists to show the shape of the
# changes, not to fit models.
knitr::opts_chunk$set(eval = FALSE)


## -----------------------------------------------------------------------------
# Before: models were returned unless you said otherwise
results <- seqwrap(container, cores = 4)
results@models[[1]]

# Now: ask for them explicitly
results <- seqwrap(container, return_models = TRUE, cores = 4)


## -----------------------------------------------------------------------------
# Before: a named list, indexed by target
results@summaries[["ENSG00000141510"]]

# Now: one data frame, filtered
subset(results@summaries, target == "ENSG00000141510")


## -----------------------------------------------------------------------------
results <- seqwrap(container, cache = "disk", cores = 4)

# Read and combine the cached chunks
combined <- seqwrap_summarise(results)

seqwrap_cache_clear(results)


## -----------------------------------------------------------------------------
# Before
warned <- results@errors |>
  dplyr::filter(purrr::map_lgl(warnings_fit, ~ !is.null(.x[[1]]))) |>
  dplyr::pull(warnings_fit)

# Now
warned <- seqwrap_errors(results, stage = "fit", type = "warning")

# Which warnings dominate
warned |>
  dplyr::count(message, sort = TRUE)


## -----------------------------------------------------------------------------
results@targets

# Targets that completed cleanly
setdiff(results@targets, seqwrap_errors(results)$target)


## -----------------------------------------------------------------------------
combined <- seqwrap_summarise(results, drop_warnings = TRUE)
combined$dropped


## -----------------------------------------------------------------------------
combined <- seqwrap_summarise(results)

usable <- subset(combined$evaluations, converged & !singular)


## -----------------------------------------------------------------------------
results <- seqwrap(container, eval_fun = residual_diagnostics, cores = 4)

