Skip to contents

Shared helper used by both mrmashWrapper (individual-level) and mrmashRssWeights (summary statistics). Constructs the S0 list of prior covariance matrices via the canonical mixture (mr.mashr::compute_canonical_covs) and optional data-driven matrices, expanded over a scaling grid via mr.mashr::expand_covs. The prior grid is derived from Bhat and Shat via computeGrid when not supplied.

Usage

buildMrmashPriorMatrices(
  Bhat,
  Shat,
  K = NULL,
  dataDrivenPriorMatrices = NULL,
  canonicalPriorMatrices = TRUE,
  priorGrid = NULL,
  hetgrid = c(0, 0.25, 0.5, 0.75, 1),
  singletons = TRUE
)

Arguments

Bhat

Numeric matrix of effect-size estimates (variants x conditions).

Shat

Numeric matrix of standard errors (variants x conditions).

K

Number of conditions. When NULL, inferred from ncol(Bhat).

dataDrivenPriorMatrices

Optional list with element U (list of raw covariance matrices) computed e.g. by computeCovFlash / computeCovDiag.

canonicalPriorMatrices

Logical. When TRUE (default for RSS), include the standard canonical mixture from mr.mashr::compute_canonical_covs(). When FALSE, dataDrivenPriorMatrices must be supplied.

priorGrid

Optional pre-computed scaling grid (numeric vector). When NULL, derived from Bhat, Shat via computeGrid().

hetgrid

Heterogeneity grid passed to mr.mashr::compute_canonical_covs(). Default c(0, 0.25, 0.5, 0.75, 1), matching the individual-level wrapper.

singletons

Whether to include single-condition prior components. Default TRUE.

Value

A list with components S0 (the expanded list of prior covariance matrices) and prior_grid (the scaling grid that was used).