Skip to contents

Unified TWAS Z-statistic: accepts a weight vector (single method/context) or a (variants x K) weight matrix, computes the per-tuple TWAS Z-score and two-sided p-value, and optionally delegates cross-tuple p-value combination to combinePValues.

Usage

twasZ(
  weights,
  z,
  R = NULL,
  X = NULL,
  V = NULL,
  D = NULL,
  nSketch = NULL,
  combineMethods = NULL
)

Arguments

weights

Numeric vector of weights (single tuple) or a numeric matrix with one column per tuple (method / context). When a vector, the column name defaults to "method1".

z

Numeric vector of GWAS Z-scores aligned to the rows of weights.

R

Optional LD correlation matrix.

X

Optional genotype matrix used to compute R when R is missing.

V, D, nSketch

SVD components of the LD sketch (right-singular vectors, singular values, panel sample size). Supplying all three selects the SVD path.

combineMethods

Optional character vector of method names to forward to combinePValues for cross-tuple combination. NULL (default) skips combination.

Value

A list with:

Z

A K x 2 numeric matrix with columns c("Z", "pval"); rownames are the column names of weights.

combined

Output of combinePValues (or its trivial K=1 equivalent) when combineMethods is non-NULL, otherwise NULL.

Details

For each column k of weights:

  • stat_k = w_kᵀ z

  • denom_k = w_kᵀ R w_k

  • Z_k = stat_k / sqrt(denom_k), p_k = 2 * (1 - Phi(|Z_k|))

When combineMethods is non-NULL and K >= 2, the cross-tuple correlation matrix rho_{i,j} = covY_{i,j} / sqrt(covY_{i,i} * covY_{j,j}) is constructed once and forwarded to combinePValues as the R argument. When K == 1, the combined p-value trivially equals the per-tuple p-value.

The SVD path (V, D, nSketch) lets the caller avoid materializing the full LD matrix: covY = (VᵀW · sqrt(Lambda))ᵀ (VᵀW · sqrt(Lambda)) with Lambda_i = D_i^2 / (nSketch - 1). Use the R path when an LD correlation matrix is already available; use the X path to compute R from a genotype matrix.

See also

combinePValues for the combination method menu.