Skip to contents

Applies a single QC pass to a QtlSumStats or GwasSumStats collection: per-row sanity checks via .applySanityChecks (drop rows with out-of-range / zero P, BETA == 0, SE <= 0, NA in vital columns; clamp tiny P; normalize CHR; coerce signed columns to numeric), variant-content filters (MAF / INFO / N) via .applyContentFilters, optional skipRegion drop, optional PIP screen, panel-vs-sumstats allele harmonization against the ldSketch via harmonizeAlleles (which handles indels, strand-ambiguous variants, sign / strand flips, and duplicate drops in a single sweep), optional SLALOM/DENTIST LD-mismatch QC, and optional RAISS imputation. No Bioconductor genome / dbSNP packages required.

Usage

summaryStatsQc(
  sumstats,
  removeIndels = FALSE,
  removeStrandAmbiguous = TRUE,
  mafCutoff = 0,
  infoCutoff = 0,
  nCutoff = 5,
  keepVariants = NULL,
  skipRegion = NULL,
  pipCutoffToSkip = 0,
  zMismatchQc = c("none", "slalom", "dentist"),
  alleleFlipKriging = FALSE,
  effectiveN = TRUE,
  impute = FALSE,
  imputeOpts = list(rcond = 0.01, r2Threshold = 0.6, minimumLd = 5, lamb = 0.01),
  matchMinProp = 0,
  coerceNumeric = TRUE,
  normalizeChr = TRUE,
  dropNonstandardChr = TRUE,
  dropMissData = TRUE,
  dropPOutOfRange = TRUE,
  clampSmallP = TRUE,
  smallPFloor = 4.94065645841247e-324,
  dropZeroEffect = TRUE,
  dropNonpositiveSe = TRUE
)

Arguments

sumstats

A QtlSumStats or GwasSumStats collection.

removeIndels

Logical (length 1). When TRUE, drop indels during panel harmonization. Default FALSE.

removeStrandAmbiguous

Logical (length 1). When TRUE, drop A/T and C/G strand-ambiguous variants. Default TRUE.

mafCutoff

Numeric (length 1). MAF threshold (variants with MAF < mafCutoff are dropped). Default 0. Requires MAF or FRQ column when non-zero.

infoCutoff

Numeric (length 1). INFO score threshold. Default 0. Requires INFO column when non-zero.

nCutoff

Numeric (length 1). Sample-size deviation threshold: drop variants whose N is more than nCutoff median-absolute-deviations from the median. Set to 0 to disable. Default 5.

keepVariants

Optional character vector of variant IDs (SNP column) to retain prior to harmonization.

skipRegion

Optional character vector of "chr:start-end" strings, or a GRanges, of regions to drop.

pipCutoffToSkip

Numeric (length 1). When != 0, run an LD-independent single-effect SER screen and skip the entry if no PIP exceeds the cutoff. < 0 resolves to 3 / nVariants. Default 0 (no screen).

zMismatchQc

One of "none" (default), "slalom", "dentist".

alleleFlipKriging

Logical (length 1). Opt-in kriging LD-consistency prefilter run before SLALOM/DENTIST. Default FALSE.

effectiveN

Logical (length 1). When TRUE (default) and the input carries case/control counts — per-variant N_CASE / N_CONTROL mcols, else the study-level nCase / nControl scalars — the working per-variant N is set to the effective sample size effectiveN(nCase, nControl) BEFORE the N-cutoff filter, so the filter, kriging, and the downstream fit all use N_eff. When both counts and an N column are present the counts win: N is overridden and the override is logged. Inputs with no counts (quantitative traits) are unchanged. The escape hatch effectiveN = FALSE restores the raw N column (or, when there is no N, the raw total nCase + nControl) with no override. qcInfo$options$effectiveN records the setting and each entry's nSource is one of "effective", "column", "total", or NA.

impute

Logical (length 1). Run RAISS imputation against the ldSketch. Default FALSE. (Note: RAISS against the sketch is not yet fully wired for the new path; the option is accepted but currently emits a warning and is skipped.)

imputeOpts

Named list of RAISS parameters.

matchMinProp

Minimum proportion of LD panel variants that must be matched by the sumstats; default 0.

coerceNumeric

Logical. Coerce signed columns (Z/BETA/SE/OR/LOG_ODDS/SIGNED_SUMSTAT/P/MAF/FRQ/INFO/N) to numeric. Default TRUE.

normalizeChr

Logical. Strip "chr" prefix, uppercase the chromosome label, and map 23->X, 24->Y, M->MT. Default TRUE.

dropNonstandardChr

Logical. Drop variants whose CHR (after normalization) is outside 1..22, X, Y, MT. Default TRUE.

dropMissData

Logical. Drop rows with NA in any vital column (chrom, pos, A1, A2, and at least one of Z / BETA). Default TRUE.

dropPOutOfRange

Logical. Drop rows where P < 0 or P > 1. Default TRUE.

clampSmallP

Logical. Floor non-negative P values below smallPFloor to smallPFloor so -log10(P) stays finite. Applied to both input and Z-derived P values. Default TRUE.

smallPFloor

Numeric (length 1). Floor for clampSmallP. Default 5e-324 (R's smallest positive double).

dropZeroEffect

Logical. Drop rows where any effect column is exactly 0 (BETA, LOG_ODDS, SIGNED_SUMSTAT) or OR is exactly 1. Default TRUE.

dropNonpositiveSe

Logical. Drop rows where SE <= 0. Default TRUE.

Value

A new QtlSumStats / GwasSumStats with cleaned entries and qcInfo populated.

Details

The returned collection has its qcInfo slot populated with a per-entry audit record (variant counts, drop counts at each step, which filters fired, etc.). Fine-mapping and TWAS-weights pipelines reject SumStats inputs where length(getQcInfo(x)) == 0L.

Column-availability error contract: a non-zero mafCutoff requires every entry to carry a MAF column; non-zero infoCutoff requires INFO; non-zero nCutoff requires N. Missing column with a non-zero cutoff is a hard error.