This repository provides an R-only utility to apply Genomic Control (GC) to GWAS or SAIGE step‑2 summary statistics.
scripts/gc_adjust_general.R: R script using optparse + data.table to construct a chi‑square statistic from common columns (CHISQ, Tstat/var, BETA/SE, p.value.NA, p.value), estimate one lambda with optional MAC/MAF filter, optionally use a fixed prespecified lambda, and output GC‑adjusted results.data/test_data.csv: small synthetic dataset to try the tool.
You need R with packages data.table and optparse.
Rscript scripts/gc_adjust_general.R \
--input data/test_data.csv \
--out out/test_gc_rThis will write out/test_gc_r.tsv.gz and out/test_gc_r.lambda.tsv.
Use a fixed lambda (bypass estimation):
Rscript scripts/gc_adjust_general.R \
--input data/test_data.csv \
--out out/test_gc_r_fixed \
--lambda_fixed 1.12Set threads for data.table with --cpus (defaults to parallel::detectCores()):
Rscript scripts/gc_adjust_general.R \
--input data/test_data.csv \
--out out/test_gc_r_threads \
--cpus 8See docs/USAGE.md for CLI options and examples. docs/METHODS.md summarizes the chi‑square fallbacks and lambda estimation.
- Lambda is clamped to >= 1 unless you pass
--allow_deflation. - When using SAIGE binary outputs, the primary
p.valueis SPA-based; the scripts warn if they must derive chi‑square from that. - Optional filtering for lambda estimation supports MAC or MAF. If both are provided, MAC is preferred.