R/estimate_inflation_factor.R
estimate_inflation_factor.RdGiven a single-variant association scan, estimate its genomic-control
inflation factor by one of two methods, after the standard LDSC QC
(common variants; the MHC excluded). The returned factor is the input to the
GLOW calibration methods: calibrate_pvalues (M1) and the
z_scale = 1/sqrt(factor) hook in glow_region_test (M2).
estimate_inflation_factor(
scan,
method = c("ldsc_intercept", "lambda_gc"),
ld_scores = NULL,
pvalue_col = "pvalue",
z_col = "Z",
maf_col = "MAF",
maf_min = 0.01,
exclude_mhc = TRUE,
mhc_chr = "6",
mhc_start = 2.5e+07,
mhc_end = 3.5e+07,
winsorize = 80
)A single-variant scan data.frame (the
marginal_scan shape). "ldsc_intercept" needs columns
chr, pos, ref, alt and z_col;
"lambda_gc" needs pvalue_col. maf_col is used for QC
when present.
"ldsc_intercept" (default) or "lambda_gc".
LD-score table from compute_ld_scores
(chr, pos, ref, alt, ld); required for
"ldsc_intercept", ignored for "lambda_gc".
Column names for the p-value ("lambda_gc") and
the Z-score ("ldsc_intercept", \(\chi^2 = Z^2\)). Defaults
"pvalue", "Z".
Minor-allele-frequency column and threshold for the
common-variant QC (default "MAF", 0.01). QC is skipped if
maf_col is absent or maf_min <= 0.
Exclude the MHC region (default
TRUE; chr "6", 25e6-35e6, hg38).
\(\chi^2\) cap passed to ldsc_regression
(default 80).
A one-row data.frame: method, factor,
n_variants, and intercept, intercept_se, slope,
slope_se, confounding_ratio, ratio_se, lambda_gc,
mean_chi2 (the LDSC fields are NA for "lambda_gc"). The
factor column is the calibration factor; the row doubles as a
provenance record to persist alongside a run.
"ldsc_intercept" (the principled, confounding-only factor)The
scan is merged to ld_scores by chr:pos:ref:alt, QC'd
(\(\mathrm{MAF} \ge\)maf_min; the MHC dropped; positive finite LD
scores), and ldsc_regression is run on
\(\chi^2 = Z^2\) vs the LD score; the intercept is the factor.
"lambda_gc" (removes all inflation)The genomic-control
\(\lambda_{\mathrm{GC}}\) via compute_lambda_gc on the
scan's p-values (after the same MAF QC). No LD scores needed.
Applying the same MAF QC to both methods keeps them comparable as
common-variant inflation estimates; set maf_min = 0 (or omit
maf_col) to use all variants.