Skip to contents

Applies specified weight methods to the datasets X and Y, returning weight matrices for each method. Handles both univariate and multivariate methods, and filters out columns in X with zero standard error. This function utilizes parallel processing to handle multiple methods.

Usage

twas_weights(
  X,
  Y,
  weight_methods,
  num_threads = 1,
  fitted_models = NULL,
  retain_fits = FALSE,
  verbose = 1
)

Arguments

X

A matrix of samples by features, where each row represents a sample and each column a feature.

Y

A matrix (or vector, which will be converted to a matrix) of samples by outcomes, where each row corresponds to a sample.

weight_methods

A list of methods and their specific arguments, formatted as list(method1 = method1_args, method2 = method2_args), or alternatively a character vector of method names (eg, c("susie_weights", "enet_weights")) in which case default arguments will be used for all methods. methods in the list can be either univariate (applied to each column of Y) or multivariate (applied to the entire Y matrix).

num_threads

The number of threads to use for parallel processing. If set to -1, the function uses all available cores. If set to 0 or 1, no parallel processing is performed. If set to 2 or more, parallel processing is enabled with that many threads.

fitted_models

Optional named list of fitted SuSiE-family models.

retain_fits

If TRUE, retain fitted model objects as attributes on returned weight matrices when supported by the weight method.

verbose

Integer controlling verbosity level: 0 = suppress all messages, 1 = suppress external package messages (default), 2 = show all messages including those from external packages.

Value

A list where each element is named after a method and contains the weight matrix produced by that method.