MGHome page

GWAS course

Course map

0 of 64 steps done

Start with step 0.1Install R

Saved in this browser only.

Step 6.4

Module 6 · Association · step 4 of 8

6.4Run the association scan

Commands tested on Windows

In short

We test variants whose less common DNA version occurs at a frequency of at least 1% in the final study group. We adjust for age, sex and ten numbers describing genetic variation, then check and save the results.

Do this

You should see: The frequency check in the final cohort removes another 1,698 variants.

Command

Module setup, needed before this step

R: module setup

source("R/guided.R")cfg <- guided_init()

Blue: PLINK option · Orange: value you can change · Green: file name

R command

Type or paste into the RStudio console.

1out <- guided_path(cfg, "6.4", "association")run_plink(cfg, c("--pfile", guided_path(cfg, "5.7"), "--maf", "0.01", "--covar", guided_path(cfg, "6.3", "covariates.tsv"),  "--covar-name", "Age,PC1-PC10", "--covar-variance-standardize", "--glm", "sex", "hide-covar", "firth-fallback", "--out", out))results <- guided_association(out)2valid <- valid_p(results$P)stopifnot(sum(valid) == 236815L, sum(results$P[valid] < 5e-8) == 8L)3guided_write(results, guided_path(cfg, "6.4", "results.tsv"))# Course bookkeeping: records the counts for the next step. Do not change.guided_artifact_checkpoint(cfg, "6.4", c(paste0(out, ".Disease.glm.logistic.hybrid"), guided_path(cfg, "6.4", "results.tsv")), parent = "6.3")
  1. Note 1: Test variants with the frequency rule and the chosen adjustment factors.
  2. Note 2: Check the number of valid tests and results below the course significance threshold.
  3. Note 3: Save a table of the association results.

You need

The final genotype files from 5.7 and the covariates from 6.3.

What we do

Fit the additive logistic model, planned in advance, at every retained variant that PLINK can analyse. The model includes age, sex and ten PCs.

Why

The scan tests one variant at a time. The covariates stay the same for every test. The null hypothesis (opens in a new tab) of the additive test is beta = 0, which means no effect. A small p-value is evidence against the null hypothesis, if the model and its assumptions are right. It does not measure the size of the effect. It does not prove a cause. It is not the probability that the null hypothesis is true. Firth fallback means that PLINK switches to Firth correction when the ordinary fit fails, which gives a more stable result. The ordinary fit can fail because of separation (opens in a new tab). We never choose the covariates after we look at the peaks in the results.

What each option does

Each option, with the modifiers under the option they belong to.
Option or modifierWhat it does
--pfile

Reads s5-7_state.pgen, .pvar and .psam, which hold the final study genotypes and sample details.

--maf

Keeps variants whose less common allele (DNA version) has a frequency of at least 1% in the final study group.

--covar

Reads s6-3_covariates.tsv, matching age and genetic component scores to samples by their IDs.

--covar-name

Selects Age and PC1 to PC10 as extra factors to adjust the disease comparison; each PC describes one pattern of genetic variation.

--covar-variance-standardize

Rescales the numerical adjustment factors to mean zero and variance one, a common scale that helps the model calculation remain stable.

--glm

Fits a logistic model at each variant to estimate how each extra copy of the tested DNA version changes the odds of disease. The odds of disease are the chance of having the disease divided by the chance of not having it.

Modifier of --glm: sex

Adds the recorded sex from s5-7_state.psam as an adjustment factor in the model.

Modifier of --glm: hide-covar

Reports the genetic tests without separate rows for the effects of age, sex and genetic component scores.

Modifier of --glm: firth-fallback

Uses Firth correction, which gives usable estimates when very few people carry the allele, when the ordinary model calculation fails.

--out

Starts output file names with s6-4_association, including s6-4_association.Disease.glm.logistic.hybrid.

Every command also uses --threads 2 (PLINK runs at most two tasks at the same time) and --memory 2048 (PLINK uses at most about 2 GB of memory).

PLINK terminal equivalent. Optional: you do not need it for the course.

Blue: PLINK option · Orange: value you can change · Green: file name

Terminal equivalent: plain PLINK 2

Select any option to see what it does. Do not paste terminal commands into the R console.

Command

bin/plink2

No option selected. Each underlined part of the command is an option you can open.

Use bin\plink2.exe on Windows.

Expected result

Show the expected result

The frequency check in the final cohort removes another 1,698 variants. This leaves 236,815 additive p-values that are finite numbers. Eight of them are below 0.00000005. A variant kept before the scan can still fail the frequency check after the cohort changes. Read the output and the log. Never replace a missing result with zero.

The tested PLINK version is defined in config.R and recorded in software_versions.txt. Validation: executable chunks passed on Windows; main test counts and significance match the expected values.

If something goes wrong

If something goes wrong

Stop at the first error. Check the input file named in the message and the previous step. Keep the command and the console log. Do not use files from a different version of the dataset. See troubleshooting (opens in a new tab).

Quick check

Does a tiny p-value imply a large odds ratio?

Show the answer

No. The p-value depends on the effect, the uncertainty and the sample size. Also report the effect estimate and its interval.

Files created

s6-4_association.Disease.glm.logistic.hybrid, the log files and s6-4_results.tsv, a cleaned copy of the results.