Skip to contents

Flags variants whose observed z-score is inconsistent with the value predicted from its LD neighbours, using susieR's kriging diagnostic. susieR::kriging_rss() computes the leave-one-out conditional distribution of each z_i given the rest (with the LD-mismatch scale s defaulting to susieR::estimate_s_rss()) and a per-variant logLR for the allele-switch hypothesis. This helper reuses susieR's own allele-switch rule — logLR > logLRThreshold & abs(z) > zThreshold (the same logLR > 2 & |z| > 2 used in susie_rss_utils) — to flag variants whose sign should be flipped. RSS-only helper, opt-in via alleleFlipKriging; never wired into alleleQc() / matchRefPanel(). Requires a susieR that provides kriging_rss() and estimate_s_rss().

Usage

krigingOutlierQc(
  zScore,
  R,
  n,
  variantIds = NULL,
  zThreshold = 2,
  logLRThreshold = 2
)

Arguments

zScore

Numeric vector of harmonized z-scores.

R

Square LD correlation matrix aligned to zScore.

n

Sample size, forwarded to susieR::kriging_rss() (whose default s is susieR::estimate_s_rss()).

variantIds

Optional variant IDs for the diagnostics table.

zThreshold

Absolute-z cutoff for the allele-switch rule (default 2, matching susieR).

logLRThreshold

Log-likelihood-ratio cutoff for the allele-switch rule (default 2, matching susieR).

Value

A list with flip (logical vector; TRUE = allele switch, z-score should be sign-flipped) and diagnostics (data frame of per-variant z, condmean, z_std_diff, logLR, and the flipped flag).