Skip to contents

These helpers wrap reduce(method = "ols:voxelwise") for subject-level map workflows. They return a lazy GDS plan; call compute() to materialise the fitted maps.

Usage

group_ols(x, formula = ~1, col_data = NULL, options = list(), ...)

one_sample(x, subset = NULL, col_data = NULL, options = list(), ...)

two_sample(
  x,
  group = "group",
  baseline = NULL,
  level = NULL,
  col_data = NULL,
  options = list(),
  ...
)

Arguments

x

A realised gds or gds_plan.

formula

One-sided model formula for group_ols().

col_data

Optional subject-level covariates to attach before fitting.

options

Reducer options passed to reduce().

...

Additional arguments passed to reduce().

subset

Optional expression evaluated in col_data(x) to select subjects before fitting the one-sample model.

group

Name of the grouping column in col_data(x).

baseline

Optional reference level for the grouping factor.

level

Optional non-baseline level to compare against baseline. When omitted, all non-baseline levels are retained in the model.

Value

A gds_plan with an OLS reduce node.

Examples

# Synthetic voxel-like data: 5 samples x 4 subjects x 1 contrast
beta <- array(rnorm(5 * 4), c(5, 4, 1))
var <- array(1, c(5, 4, 1))
g <- new_gds(list(beta = beta, var = var), space_sample_labels(letters[1:5]),
             subjects = paste0("s", 1:4), contrasts = "c1",
             col_data = data.frame(group = c("control", "control",
                                             "patient", "patient"),
                                   row.names = paste0("s", 1:4)))

fit <- group_ols(g, ~ group) |> compute()
names(assays(fit))
#>  [1] "sigma2"               "df_res"               "n_obs"               
#>  [4] "cov_tri"              "coef:(Intercept)"     "coef:grouppatient"   
#>  [7] "se_coef:(Intercept)"  "se_coef:grouppatient" "t_coef:(Intercept)"  
#> [10] "t_coef:grouppatient"  "p_coef:(Intercept)"   "p_coef:grouppatient" 
one <- one_sample(g) |> compute()
two <- two_sample(g, group = "group", baseline = "control") |> compute()