Skip to contents

This function performs weights computation for Transcriptome-Wide Association Study (TWAS) in a multivariate setting. It incorporates steps such as fitting models using mvSuSiE and mr.mash, calculating TWAS weights and predictions, and optionally performing cross-validation for TWAS weights.

Usage

twas_multivariate_weights_pipeline(
  X,
  Y,
  mnm_fit,
  cv_folds = 5,
  sample_partition = NULL,
  data_driven_prior_matrices = NULL,
  data_driven_prior_matrices_cv = NULL,
  canonical_prior_matrices = FALSE,
  mvsusie_max_iter = 200,
  mrmash_max_iter = 5000,
  max_cv_variants = -1,
  cv_threads = 1,
  verbose = FALSE
)

Arguments

X

A matrix of genotype data where rows represent samples and columns represent genetic variants.

Y

A matrix of phenotype measurements, where rows represent samples and columns represent conditions.

mnm_fit

An object containing the fitted multivariate models (e.g., mvSuSiE and mr.mash fits).

cv_folds

The number of folds to use for cross-validation. Defaults to 5. Set to 0 to skip cross-validation.

sample_partition

An optional vector specifying the partition of samples for cross-validation. If NULL, a random partition is generated.

data_driven_prior_matrices

A list of data-driven covariance matrices for mr.mash weights. Defaults to NULL.

data_driven_prior_matrices_cv

A list of data-driven covariance matrices for mr.mash weights in cross-validation. Defaults to NULL.

canonical_prior_matrices

If TRUE, computes canonical covariance matrices for mr.mash. Defaults to FALSE.

mvsusie_max_iter

The maximum number of iterations for mvSuSiE. Defaults to 200.

mrmash_max_iter

The maximum number of iterations for mr.mash. Defaults to 5000.

max_cv_variants

The maximum number of variants to be included in cross-validation. Defaults to -1 which means no limit.

cv_threads

The number of threads to use for parallel computation in cross-validation. Defaults to 1.

verbose

If TRUE, provides more detailed output during execution. Defaults to FALSE.

Value

A list containing results from the TWAS pipeline, including TWAS weights, predictions, and optionally cross-validation results.

Examples

# Example usage (assuming appropriate objects for X, Y, and mnm_fit are available):
twas_results <- twas_multivariate_weights_pipeline(X, Y, mnm_fit)
#> Error: object 'mnm_fit' not found