Module 6 · Association · step 2 of 8
6.2The additive logistic model
Commands tested on Windows
In short
We fit a logistic model, which describes the probability of being a case, using the number of copies of one DNA letter. The model estimates how many times each extra copy of the allele multiplies the odds of disease, the chance of having the disease divided by the chance of not having it. This multiplier is the odds ratio.
Do this
- Paste in the RStudio ConsoleThe R command in the Command section below
You should see: An intercept and a dosage coefficient, each with a standard error and a p-value.
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.
1x <- read.table(paste0(guided_path(cfg, "6.1", "example"), ".raw"), header = TRUE, check.names = FALSE)psam <- guided_table(paste0(guided_path(cfg, "5.7"), ".psam"))example <- data.frame(case = as.numeric(psam$Disease[match(x$IID, psam$IID)] == "2"), dosage = as.numeric(x[[7]]))2fit <- glm(case ~ dosage, data = example, family = binomial())summary(fit)exp(coef(fit)["dosage"])- Note 1: Read the exported variant and match each sample to its case or control status.
- Note 2: Fit the model and show how each extra copy changes the odds of disease.
You need
The one-variant export from 6.1 and the final PSAM file (the table of samples).
What we do
Fit a logistic regression (opens in a new tab) for one variant in R. Connect the dosage to the odds ratio.
Why
Logistic regression suits an outcome with two values, here case or control. It models log(p/(1-p)) = intercept + beta * dosage. Here p is the probability of being a case, and beta is the effect of each extra copy of the allele. An additive model (opens in a new tab) assumes that each extra copy changes the log odds by the same amount. exp(beta) is the odds ratio per copy of the allele. It differs from the carrier odds ratio at 6.1. The standard error (opens in a new tab) shows how uncertain the estimate of the log odds ratio is. This example uses one variant and no adjustment. It is not the final association result.
PLINK terminal equivalent. Optional: you do not need it for the course.
Not applicable. This step needs no PLINK operation. The R chunk is the complete command.
R reads or calculates the values it shows. It does not change the genotype files.
Expected result
Show the expected result
An intercept and a dosage coefficient, each with a standard error and a p-value (opens in a new tab). The odds ratio per allele and the carrier odds ratio need not be equal.
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
What does beta = 0 imply for the per-allele odds ratio?
Show the answer
exp(0) = 1. The estimate shows no change in the odds for each extra copy of the allele.
Files created
The example model exists only in R memory. The genotype export from 6.1 stays on disk.