MGHome page

GWAS course

Course map

0 of 64 steps done

Start with step 0.1Install R

Saved in this browser only.

Step A.9

Module A · Genotype imputation · step 9 of 10

A.9Test imputed variants for association

Commands tested on Windows

In short

We test the imputed variants of the region around locus L4 for association with disease, with the same model as the main analysis. We compare the result of the simulated risk variant, which is not on the array, with the best variant of the region.

Do this

You should see: The L4 variant chr18:38042715:G:A: imputation R2 0.95, odds ratio 1.47, p-value 1.7e-06.

Command

Module setup, needed before this step

R: module setup

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

R command

Type or paste into the RStudio console.

1module_a <- file.path(cfg$data_dir, "module_a")assoc <- imputation_association(cfg, file.path(module_a, "imputed", "chr18.dose.vcf.gz"))2stopifnot(nrow(assoc) == 8334L)3print(imputation_l4(assoc))
  1. Note 1: Test the imputed dosages of chromosome 18 with the model of the main analysis.
  2. Note 2: Check the number of tested variants.
  3. Note 3: Compare the L4 variant with the best variant of the region.

You need

Your final cohort from 5.7, the covariates from 6.3 and the imputed output of chromosome 18 in the module A data.

What we do

Test the imputed variants of the region around locus L4 for association, with the model of the main analysis. Then compare the simulated risk variant of L4 with the best variant of the region.

Why

PLINK 2 reads dosages directly from the VCF files that Minimac4 or a server returns. We use the same samples, covariates and principal components as in the main analysis (step 6.4). Otherwise the results of the two analyses cannot be compared. A test on the dosage keeps the uncertainty of each genotype (Marchini and Howie 2010 (opens in a new tab)).

Locus L4 is a simulated risk variant on chromosome 18 (chr18:38042715:G:A, odds ratio 1.4 by design). It is not on the array. In the main analysis the region did not reach genome-wide significance. Does imputation help?

This is one example, from one simulated region and one panel. It shows what can happen. It is not a rule: in another region, or with a larger panel, the result can go either way.

What each option does

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

Reads the imputed output of chromosome 18 from the module A data.

Modifier of --vcf: dosage

With DS, reads the dosage field: the expected number of copies of the alternate allele, from 0 to 2.

--double-id

Uses the sample name of the VCF file as both family ID and individual ID, so that the rows match the covariate file.

--extract-if-info

Keeps the variants whose imputation quality R2, in the INFO column, is at least 0.3.

--update-sex

Takes the recorded sex of each sample from s5-7_state.psam, because a VCF file has no sex.

Modifier of --update-sex: col-num

With 3, reads the sex from column 3 of that file.

--pheno

Reads the case and control status from s5-7_state.psam, because a VCF file has no phenotype.

--pheno-name

Selects the column Disease of that file.

--maf

Keeps variants whose less common allele (DNA version) has a frequency of at least 1% in the 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.

Modifier of --glm: sex

Adds the recorded sex 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.

Modifier of --glm: cols

With +a1freq,+machr2, adds the allele frequency and the imputation quality that PLINK computes from the dosages.

--out

Starts output file names with sA-9_chr18_assoc, including sA-9_chr18_assoc.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

8,334 variants tested. The L4 variant chr18:38042715:G:A: imputation R2 0.95, odds ratio 1.47, p-value 1.7e-06.

AnalysisVariantFrequencyR2Odds ratiop-value
Array sites (main analysis)best: 18:38107932:C:A, 65 kb away0.25measured1.496.6e-07
Imputedthe L4 variant itself0.280.951.471.7e-06
Imputedbest in the region: chr18:38106879:G:C0.410.811.544.2e-08
True genotypes (only in a simulation)the L4 variant0.291.461.3e-06
True genotypes (only in a simulation)best in the region0.371.461.6e-07

The rows of the array sites and of the true genotypes come from the author's run, not from this chunk.

What this example shows:

  • The L4 variant is imputed well. Its result is almost the same as with its true genotype.
  • It is not the top of its region. Variants 50 to 80 kb away, in LD with it, give smaller p-values. This happens in real studies too: the lead variant is not necessarily the cause (step 7.6).
  • After imputation the best variant crosses 5e-08. With the true genotypes, the region does not go below 1.6e-07. Here, part of the "genome-wide significant" result comes from noise in the dosages of a variant with R2 0.81. Noise can push a p-value up as well as down; in this region it pushed it down.

Validation: executable chunks passed on Windows with PLINK 2.0 b.1.4 on the 1,811 samples of the course cohort (data release 2026.1) and the module A data. The numbers equal the run of the author on 23 November 2026.

If something goes wrong

If something goes wrong

"The L4 variant is not in the result": the R2 filter or the frequency filter removed it; check the filters. Many samples with missing phenotypes: the dosage file and your cohort come from different data releases. Use the module A data of the same release as your course data. A different number of tested variants: check that you kept the quotes around "R2 >= 0.3".

Quick check

After imputation, a variant with R2 0.81 crosses the genome-wide threshold, while the array site next to it does not. Is the imputed result a discovery?

Show the answer

Not yet. In this example the true genotypes do not reach the threshold: part of the result comes from noise in the dosages. Report the R2 of every variant you discuss, look at the measured neighbours, and confirm by direct genotyping or in another study.

Files created

sA-9_chr18_assoc.Disease.glm.logistic.hybrid and the log files.