diff --git a/R/ModelArray_Constructor.R b/R/ModelArray_Constructor.R index a340b3b..7b92c99 100644 --- a/R/ModelArray_Constructor.R +++ b/R/ModelArray_Constructor.R @@ -369,6 +369,9 @@ numElementsTotal <- function(modelarray, scalar_name = "FD") { #' If TRUE, it will return column names etc to be used for initiating data.frame; #' if FALSE, it will return the list of requested statistic values. #' @param ... Additional arguments for `stats::lm()` +#' @param on_error Character: one of "stop", "skip", or "debug". When an error occurs while +#' fitting one element, choose whether to stop, skip returning all-NaN values for that element, +#' or drop into `browser()` (if interactive) then skip. Default: "stop". #' #' @return If flag_initiate==TRUE, returns column names, and list of term names of final results; #' if flag_initiate==FALSE, it will return the list of requested statistic values for a element. @@ -623,6 +626,9 @@ analyseOneElement.lm <- function(i_element, #' @param flag_sse TRUE or FALSE, Whether to calculate SSE (sum of squared error) for the model (`model.sse`). #' SSE is needed for calculating partial R-squared. #' @param ... Additional arguments for `mgcv::gam()` +#' @param on_error Character: one of "stop", "skip", or "debug". When an error occurs while +#' fitting one element, choose whether to stop, skip returning all-NaN values for that element, +#' or drop into `browser()` (if interactive) then skip. Default: "stop". #' @return If flag_initiate==TRUE, returns column names, #' list of term names of final results, and attr.name of sp.criterion; #' if flag_initiate==FALSE, it will return the list of requested statistic values for a element. diff --git a/R/analyse.R b/R/analyse.R index c5ac558..9e3e204 100644 --- a/R/analyse.R +++ b/R/analyse.R @@ -69,6 +69,9 @@ #' @param verbose TRUE or FALSE, to print verbose message or not #' @param pbar TRUE or FALSE, to print progress bar or not #' @param n_cores Positive integer, The number of CPU cores to run with +#' @param on_error Character: one of "stop", "skip", or "debug". When an error occurs +#' while fitting an element, choose whether to stop, skip returning all-NaN values for +#' that element, or drop into `browser()` (if interactive) then skip. Default: "stop". #' @param ... Additional arguments for `stats::lm()` #' @return Tibble with the summarized model statistics for all elements requested #' @importFrom dplyr %>% @@ -651,6 +654,9 @@ ModelArray.lm <- function(formula, data, phenotypes, scalar, element.subset = NU #' @param verbose TRUE or FALSE, to print verbose messages or not #' @param pbar TRUE or FALSE, to print progress bar or not #' @param n_cores Positive integer, The number of CPU cores to run with +#' @param on_error Character: one of "stop", "skip", or "debug". When an error occurs +#' while fitting an element, choose whether to stop, skip returning all-NaN values for +#' that element, or drop into `browser()` (if interactive) then skip. Default: "stop". #' @param ... Additional arguments for `mgcv::gam()` #' @return Tibble with the summarized model statistics for all elements requested #' @importFrom dplyr %>% mutate @@ -1352,6 +1358,9 @@ ModelArray.gam <- function(formula, data, phenotypes, scalar, element.subset = N #' @param verbose TRUE/FALSE to print messages #' @param pbar TRUE/FALSE to show progress bar #' @param n_cores Positive integer number of CPU cores +#' @param on_error Character: one of "stop", "skip", or "debug". When an error occurs in +#' the user function for an element, choose whether to stop, skip returning all-NaN values +#' for that element, or drop into `browser()` (if interactive) then skip. Default: "stop". #' @param ... Additional arguments forwarded to `FUN` #' @return Tibble/data.frame with one row per element and first column `element_id` #' @importFrom dplyr %>% diff --git a/vignettes/wrap_function.Rmd b/vignettes/wrap_function.Rmd index ced4d01..06fbcd6 100644 --- a/vignettes/wrap_function.Rmd +++ b/vignettes/wrap_function.Rmd @@ -46,7 +46,6 @@ The next step is to use this HDF5 file and the CSV file we prepared to perform s If you installed RStudio (which we recommend), then you can simply launch RStudio. All the commands in this Step 2 section will be run in R. -> Hint for voxel-wise data for Step 2: You can follow the same steps here. Note that each "element" is a *voxel* now, instead of a *fixel*. Make sure you replace the scalar name, covariates, file paths etc with yours. In addition, as voxel-wise data may have subject-specific masks, you can also tailor the lower threshold of number of subjects when applying `ModelArray.lm()` and `ModelArray.gam()`. See `vignette("voxel-wise_data")` page for more. ### Step 2.1. Load ModelArray package in R