Skip to contents

This is is the main function in v0 of verywise. It checks the user inputs and runs the single_lmm function across all vertices.

Usage

run_vw_lmm(
  formula,
  pheno,
  subj_dir,
  outp_dir = NULL,
  hemi = c("both", "lh", "rh"),
  seed = 3108,
  n_cores = 1,
  chunk_size = 1000,
  FS_HOME = Sys.getenv("FREESURFER_HOME"),
  folder_id = "folder_id",
  verbose = TRUE,
  ...
)

Arguments

formula

: Model formula object. This should specify a linear mixed model using `lme4` syntax. #' e.g. vw_thickness ~ sex * age + site + (1|id). The *outcome* should be a brain surface metric. Available options: * `vw_thickness` * `vw_area` * `vw_area.pial` * `vw_curv` * `vw_jacobian_white` * `vw_pial` * `vw_pial_lgi` * `vw_sulc` * `vw_volume` * `vw_w_g.pct` * `vw_white.H` * `vw_white.K`

pheno

: the phenotype data object (already loaded in the global environment) or a string containing a file path. Supported file extensions are: rds, csv, txt and sav.

subj_dir

: path to the FreeSurfer data, this expects a verywise structure.

outp_dir

: output path, where do you want results to be stored. If none is provided by the user, a "results" sub-directory will be created inside subj_dir.

hemi

: (default = "both") which hemispheres to run.

seed

: (default = 3108) random seed.

n_cores

: (default = 1) number of cores for parallel processing.

chunk_size

: (default = 1000) size of data chunk for parallel processing

FS_HOME

: FreeSurfer directory, i.e. $FREESURFER_HOME.

folder_id

: (default = "folder_id") the name of the column in pheno that contains the directory names of the input neuroimaging data (e.g. "sub-10_ses-T1").

verbose

: (default = TRUE)

...

Arguments passed on to hemi_vw_lmm

fwhm

: (default = 10) full-width half maximum value

fs_template

: (default = "fsaverage") template on which to register vertex-wise data. The following values are accepted: * fsaverage (default) = 163842 vertices (highest resolution), * fsaverage6 = 40962 vertices, * fsaverage5 = 10242 vertices, * fsaverage4 = 2562 vertices, * fsaverage3 = 642 vertices Note that, at the moment, these are only used to downsample the brain map, for faster model tuning. `verywise` expects the input data to be always registered on the "fsaverage" template and the final analyses should also be run using `fs_template = "fsaverage"` to avoid (small) imprecisions in vertex registration and smoothing.

apply_cortical_mask

: (default = TRUE) remove vertices that are not on the cortex.

save_ss

: (default = TRUE) save the super-subject matrix as an rds file for quicker processing in the future.

model

: (default = "lme4::lmer") # "stats::lm"

use_model_template

: pre-compile the model?

Value

A list of file-backed matrices containing pooled coefficients, SEs, t- and p- values and residuals.

Author

Serena Defina, 2024.