Skip to contents

Multi-context summary-statistics analog of twas_multivariate_weights_pipeline. Bundles per-context RSS QC, cross-context variant alignment, optional RAISS missing-variant imputation, data-driven prior construction (reusing build_mrmash_prior_matrices and the same FLASH / diagonal covariance helpers as the individual-level pipeline), and multi-context weight training via mrmash_rss_weights and/or mvsusie_rss_weights.

Usage

twas_multivariate_weights_sumstat_pipeline(
  sumstats_list,
  LD_data,
  n,
  methods = list(mrmash_rss = list(), mvsusie_rss = list()),
  qc_method = NULL,
  keep_indel = TRUE,
  impute = FALSE,
  impute_missing = FALSE,
  impute_opts = list(rcond = 0.01, R2_threshold = 0.6, minimum_ld = 5, lamb = 0.01),
  data_driven_prior_matrices = NULL,
  canonical_prior_matrices = TRUE,
  estimate_priors_from_sumstats = TRUE,
  verbose = 1
)

Arguments

sumstats_list

Named list of per-context sumstats data.frames. Each data.frame must contain variant_id, chrom, pos, A1, A2, and either z or beta/se. List names become condition labels.

LD_data

Shared LDData S4 object covering the union of variants. Each per-context sumstats is QC'd against this same LD panel.

n

Per-context sample sizes; either a named numeric vector matching names(sumstats_list) or a single scalar to broadcast.

methods

Named list of multivariate RSS weight methods to fit. Function names must match <name>_weights. Defaults to mr.mash-RSS and mvSuSiE-RSS with default arguments.

qc_method

Per-context QC method passed to summary_stats_qc; one of "slalom", "dentist", or NULL/"none". Default NULL (basic harmonization only).

keep_indel

Passed through to QC. Default TRUE.

impute

Logical. If TRUE, run per-context RAISS re-imputation of LD-mismatch outliers (QC re-imputation). Default FALSE.

impute_missing

Logical. If TRUE, after per-context QC and before cross-context alignment, RAISS imputes per-context z-scores for LD-reference variants absent from each context's sumstats. Widens the intersection used downstream. Default FALSE.

impute_opts

Named list of RAISS parameters shared by both impute and impute_missing.

data_driven_prior_matrices

Optional list of pre-computed prior matrices (with element U) passed to build_mrmash_prior_matrices. When NULL and estimate_priors_from_sumstats = TRUE, the pipeline estimates a data-driven covariance from the cross-context Bhat matrix via compute_cov_flash. If FLASH fails the error is allowed to propagate; supply data_driven_prior_matrices explicitly or set estimate_priors_from_sumstats = FALSE to bypass.

canonical_prior_matrices

Passed to build_mrmash_prior_matrices. Default TRUE.

estimate_priors_from_sumstats

Logical. When TRUE (default) and data_driven_prior_matrices is NULL, estimate data-driven priors from the cross-context Bhat matrix using compute_cov_flash. FLASH errors are not swallowed; see data_driven_prior_matrices for the explicit-prior path.

verbose

Integer verbosity level.

Value

A list with

twas_weights

A TWASWeights S4 object with per-context weight matrices (variants x conditions).

qc_summary

Per-context QC and alignment counts.

Z

The aligned z-score matrix (variants x conditions) fed to the weight learners.