Teaching · Practical course
From DNA to genotypes: arrays, IDAT files, Final Report and PLINK
Twenty-one slides. Use the slide view in class, or read the page view on any screen. The examples are the invented files of the File formats page.
Slide 1 of 21
From DNA to genotypes: arrays, IDAT files, Final Report and PLINK
- GWAS practical course
- How the data of a genotyping array become files that PLINK can read
Speaker notes
Welcome. In this lesson we follow one small dataset from the scanner to PLINK 2. The files are invented: 4 people and 8 variants. You can open all of them on the File formats page.
The aim is simple. When you receive data from a laboratory, you should know what each file is, who made it and what it can and cannot tell you.
Slide 2 of 21
Association studies: allele frequencies in cases and controls
- Case: a person with the disease. Control: a person without it.
- Count one allele in both groups.
- If the frequency differs more than chance allows, the variant is associated.
Invented example Allele G Allele A Cases 300 700 Controls 200 800 
Speaker notes
An allele is one version of a variant. In a case-control study we count how often one allele is seen in the cases and in the controls.
With the invented numbers, the odds of carrying G in the cases are 300 to 700. In the controls they are 200 to 800. The odds ratio is (300 x 800) / (700 x 200), which is about 1.7.
The association test asks if a difference this large could happen by chance. The course does this with logistic regression in module 6.
Slide 3 of 21
Candidate-gene and agnostic (GWAS) approach
Row Candidate gene GWAS Question Is this gene linked to the disease? Which regions of the genome are linked? Variants tested A few, chosen from biology Hundreds of thousands to millions Hypothesis Needed before the study Not needed Threshold Usual 0.05, with few tests About 5e-8, because of many tests Speaker notes
The candidate approach starts from a gene that we already suspect. It can only find what we already think of.
A genome-wide study makes no assumption. We test the whole genome and let the data point to regions. This is why it found many unexpected loci.
Testing so many variants needs a strict threshold. About one million independent common variants exist in people of European ancestry, so 0.05 / 1,000,000 gives 5e-8 (Pe'er et al. 2008).
Reference
- Pe'er I, Yelensky R, Altshuler D, Daly MJ. Genet Epidemiol 2008;32:381-385. doi:10.1002/gepi.20303
Slide 4 of 21
Genetic architecture: GWAS targets common, low-penetrance variants
- Common variants (frequent in the population) with a small effect on risk.
- Rare variants with a large effect are found better by sequencing and family studies.
- One variant rarely explains a disease. Many small effects add up.

Speaker notes
Penetrance is the chance that a person who carries a variant gets the disease. A common variant in a GWAS usually raises risk only a little.
Most variants found by GWAS confer small increments in risk and explain only part of the inherited risk of a disease (Manolio et al. 2009). This is the 'missing heritability' problem.
Our course simulates this: the strongest signals are common variants with moderate effects.
Reference
- Manolio TA, Collins FS, Cox NJ, et al. Nature 2009;461:747-753. doi:10.1038/nature08494
Slide 5 of 21
Discovery and replication
- Discovery: find signals in a first sample.
- Replication: test the same variants in an independent sample.
- A real signal should appear again, in the same direction.
Speaker notes
A very small p-value can still be a false positive, for example from a hidden batch effect or from ancestry. A second sample, collected and genotyped separately, protects us.
Often the two samples are analysed together afterwards in a meta-analysis. Our course stops at the discovery scan, but the checks you learn (quality control, ancestry, lambda) are what make replication possible.
Slide 6 of 21
Linkage disequilibrium and tagging SNPs
- Nearby variants are inherited together in blocks.
- A tag SNP stands for its neighbours.
- So about 700,000 markers are enough to cover the common variation, and imputation can fill in the rest.

Speaker notes
Linkage disequilibrium (LD) means that alleles of nearby variants are correlated, because a stretch of DNA is passed on as a whole across generations.
If two variants are in strong LD, genotyping one tells us most of what the other would say. The array measures a well-chosen set of tag SNPs.
Imputation uses a reference panel of fully sequenced people to infer the variants that were not measured. This is an optional module (A) in the course. In module 3, step 3.4 uses LD to prune variants.
Slide 7 of 21
The genotyping array: beads, probes, two colours
- A chip with many tiny wells. Each bead carries copies of one probe.
- A probe is a short piece of DNA that sits right before the variant.
- One labelled base is added. The scanner reads its colour: green or red.

Speaker notes
The array does not read the DNA letters one by one. It asks one question for each chosen variant: which of the two alleles is present?
The details of the chemistry depend on the product (Infinium assay). For this course it is enough to remember that the answer is a colour, and that the colour is measured as light.
Our example array has 8 variants. A real array, such as the one simulated in the course, has about 300,000 to 700,000.
Slide 8 of 21
IDAT files: intensities only
- Two files for each sample: one
Grnand oneRed. - They hold light intensities, not genotypes.
- The name is the chip barcode, the position and the channel.
200000000001_R01C01_Grn.idat 200000000001_R01C01_Red.idat IlluminaID Mean SD NBeads 10600007 10776 194 5 10600020 4806 330 12
Speaker notes
For every bead type the file gives the mean intensity, the standard deviation and the number of beads that were measured.
The name 200000000001_R01C01_Grn.idat reads: BeadChip 200000000001, row 01, column 01, green channel. The sample sheet links this position to a person, here S01.
The numbers above are invented. In R you can read a real IDAT file with the package illuminaio.
- Two files for each sample: one
Slide 9 of 21
From intensities to genotypes
- Manifest + cluster file + IDAT files go into the calling program.
- The algorithm is GenCall. The result is one GTC file for each sample.
- Programs: GenomeStudio or DRAGEN Array.

Speaker notes
The manifest tells which probe is which variant. The cluster file says where the AA, AB and BB groups usually fall for each variant.
GenCall places each sample in this picture and gives a genotype with a confidence value, the GC Score.
A GTC file is binary: it holds the calls, the scores and the normalised intensities. You do not read it by hand.
Slide 10 of 21
The Final Report
- A text file made by GenomeStudio from the GTC files.
- A header, then a
[Data]table with the columns you choose. - Three layouts: one file for each sample, one long table, or a matrix.
Layout Shape In the course One file per sample SNPs in rows Used All samples, long One row per SNP and sample Same columns Matrix SNPs in rows, samples in columns Compact Speaker notes
Typical columns: SNP Name, Sample ID, Allele1 - Plus, Allele2 - Plus, Allele1 - Top, Allele2 - Top, GC Score, Chr, Position.
Allele1 and Allele2 are not REF and ALT. They are just the two letters of the genotype.
The Final Report holds no phenotype: sex and case or control status come from the sample sheet.
Slide 11 of 21
Reading genotypes
- A call below GC Score 0.15 becomes a no call.
- In our example, sample S02 at 22:22001617 has GC Score 0.12, so it is a no call.
You see Meaning A A Homozygous: two copies of the same allele A G Heterozygous: one copy of each - - No call: the genotype was not assigned Speaker notes
The GC Score runs from 0 to 1. The default threshold of 0.15 is Illumina's usual choice. Calls below it are not trusted.
A no call is not a third genotype. It means that we do not know. PLINK writes it as missing, and we will measure how many are missing for every sample and variant in modules 3 and 4.
Slide 12 of 21
Why not keep a text table?
- About 730,000 SNPs for 130 samples is about 4.5 GB of text.
- That is 130 files, each read from start to end for every question.
- A PLINK
.bedfile stores the same genotypes in about 24 MB.
Speaker notes
The sum for the .bed file: two bits for each genotype, so one variant takes ceil(130 / 4) = 33 bytes, and 730,000 variants x 33 bytes is about 24 million bytes (23 MiB). The text is about 190 times larger.
A Final Report writes every letter, every score and every column again for every sample. It is easy to read and very wasteful.
Binary formats use only the information that analysis needs. For genotypes of two alleles, two bits are enough for each genotype. The next slides show how.
A text file is still useful for looking at a few rows, and for passing data between programs that do not share a binary format.
Slide 13 of 21
PLINK 1.9 and PLINK 2
- The course uses PLINK 2.
Row PLINK 1.9 PLINK 2 Binary files .bed .bim .fam .pgen .pvar .psam (and it still reads .bed) Text files --filefor .ped/.map--pedmapfor .ped/.mapWrites .ped --recode--export pedColumn 5 of .bim Minor allele by default ALT Speaker notes
PLINK 2 is a rewrite, not a small update. It is faster, and its binary format can hold imputed dosages and variants with more than two alleles.
It also reads the older .bed files, so data from any source can enter.
The course tested PLINK 2 v2.0.0-b.1.4. R runs the commands for you and shows the PLINK command on its own.
Slide 14 of 21
.bed: two bits for each genotype
- Binary. It starts with 3 fixed bytes:
6c 1b 01. - Then one block for each variant, 2 bits for each sample.
Bits Genotype 00 Homozygous for allele 1 (column 5 of .bim) 01 Missing 10 Heterozygous 11 Homozygous for allele 2 (column 6) 6c 1b 01 8e 2b ce 3a ce 1b c6 ce 8e = 10 00 11 10 (S04 S03 S02 S01) S01 = 10 = heterozygous (A/G)Speaker notes
Our file has 4 people, so one byte holds all the genotypes of one variant: 4 x 2 bits = 8 bits. The whole file is 11 bytes: 3 for the header and 8 for the variants.
Read the byte from the right. The two lowest bits belong to the first sample in the .fam file. Byte 4 is 8e, which is 10001110. S01 has 10, so it is heterozygous at 1:1000123, as in the Final Report.
The page File formats decodes every byte.
- Binary. It starts with 3 fixed bytes:
Slide 15 of 21
.bim and .fam, column by column
- .fam: family, individual, father, mother, sex (1 male, 2 female), phenotype (1 control, 2 case).
.bim column Example Meaning 1 1 Chromosome 2 1:1000123 Variant name 3 0 Genetic distance (not used) 4 1000123 Position 5 G Allele 1 (A1) 6 A Allele 2 (A2) Speaker notes
Allele order matters. PLINK 1.9 puts the minor allele in column 5, so the order can change from one dataset to another. PLINK 2 keeps ALT in column 5 and REF in column 6.
A text .fam row of our example is: S01 S01 0 0 2 2. Zeros for father and mother mean that they are not in the dataset.
In our example, PLINK 2 chose REF and ALT from the data. The VCF marks this with the flag PR, provisional reference.
Slide 16 of 21
.lgen and .ped: text formats
.lgen: one line for each person and variant. It looks like a Final Report..ped: one line for each person, with two columns for each variant.- Use them to look at genotypes, or to move data in from other software.
S01 S01 1:1000123 A G (.lgen) S01 S01 0 0 2 2 A G C C A T ... (.ped)
Speaker notes
The .lgen format is the easiest bridge from a Final Report to PLINK, because it has the same shape. A no call becomes 0 0.
A .ped file is compact to read for a few variants, and becomes huge for real data: two characters for every allele, variant and person. Do not analyse with it.
Slide 17 of 21
From Final Reports to .bed, .bim and .fam
source("scripts/final_report_to_lgen.R") final_report_to_lgen("04_final_report", "04_final_report/sample_sheet.csv", "example")source(): Load the function final_report_to_lgen() from scripts/final_report_to_lgen.R. Run both lines in R, from the folder examples/formats/array_to_plink of the course.folder: First option: "04_final_report", the folder with the Final Report files.sample sheet: Second option: the path of the sample sheet, "04_final_report/sample_sheet.csv", which gives sex and case or control status.output name: Third option: "example", the start of the names of the new files. It writes example.lgen, example.map and example.fam.
plink2 --lfile example --make-bed --out example
--lfile example: Read the long-format files example.lgen, .map and .fam.--make-bed: Write the PLINK binary files .bed, .bim and .fam.--out example: Start the names of the new files with example. PLINK also writes example.log.
plink2 --bfile input --make-pgen --out out
--bfile input: Read input.bed, input.bim and input.fam. This is the command of step 2.2 of the course.--make-pgen: Write the PLINK 2 files .pgen, .pvar and .psam.--out out: Start the names of the new files with out.
Speaker notes
The first step is a small R function, not a PLINK command. The same conversion is also available as a Python script, to run from a terminal in the same folder: python scripts/final_report_to_lgen.py 04_final_report 04_final_report/sample_sheet.csv example. The three values are the same.
In the course R starts PLINK for you with run_plink(), and shows the PLINK command on its own line. The options are the same as here.
Always read the log. It says how many samples and variants PLINK found, and it is the first place to look when something looks wrong.
The two first commands of this slide are the ones we tested on the example files, with PLINK 2. Step 2.2 starts from the .bed files that the laboratory sent.
Slide 18 of 21
PLINK 2 binary and VCF
.pgen: PLINK 2 binary. It holds dosages, phase and more than two alleles.- VCF: the common text format for variants. Imputation servers read it.
- We will meet VCF again at imputation (optional module A).
plink2 --bfile example --export vcf id-paste=iid --out example
--export vcf: Write a VCF file.id-paste=iid: Use only the sample name (S01), not the pasted name S01_S01.
Speaker notes
A VCF has one line for each variant and one column for each sample. The genotype 0/1 means one REF allele and one ALT allele.
A VCF holds no sex. To go back from VCF to PLINK 2 you give a .psam file, because PLINK needs the sex for chromosome X: plink2 --vcf example.vcf --psam example.psam --make-pgen --out example.
Slide 19 of 21
Pitfalls
- Allele1 and Allele2 are not REF and ALT.
- Strand: Plus or Top. A/T and C/G variants look the same on both strands.
- Genome build: the course uses GRCh38. Never mix builds.

Speaker notes
An A/G variant on one strand is T/C on the other. We can tell which strand from the letters, because A/G is not the same as C/T. But an A/T variant is A/T on both strands, and C/G is C/G on both. Strand cannot be read from the letters. These are the strand-ambiguous SNPs.
Module 2 handles strand and genome build before any analysis: step 2.5 (alleles and strand) and step 2.6 (genome builds). Mixing GRCh37 and GRCh38 puts variants at the wrong place.
Slide 20 of 21
Quality control in nine steps
Step What it checks 3.2 Sample call rate (after rough cleaning at 3.1) 3.3 Recorded sex and genetic sex 3.5 Heterozygosity 3.6 Relatives and duplicates 3.7 Batch effects 4.1 Variant call rate 4.2 Differential missingness 4.3 Allele frequency 4.4 Hardy-Weinberg Speaker notes
Quality control has two parts. First the samples (module 3), then the variants (module 4). The order matters.
Step 3.1 is a rough cleaning with a loose cut before the main call rate check at step 3.2, so we count them together. Step 3.4 prepares the variants for the checks that follow and removes nothing.
Each step has its own page with the PLINK command, the expected numbers and the reason for the threshold.
Slide 21 of 21
What we will do
- Module 2: 2,016 wells and 299,523 variants converted and checked.
- Modules 3 and 4: 1,844 samples and 238,513 variants after quality control.
- Module 5: ancestry, leaving 1,811 samples.
- Modules 6 and 7: the association scan, the QQ plot and the Manhattan plot.
Speaker notes
The numbers are from the simulated course data, and they are the ones you will see on your own screen.
At the end you will have a summary statistics file, a Manhattan plot, a QQ plot and a short report with its limits. Start with module 0 to install the programs.