Before you start
- You know p-values and basic distributions (see Stats you cannot avoid), and you can run basic R (see R basics).
- Any term new? The Glossary has it.
Learning objectives
By the end of this lesson you will be able to: read a simple regression as a slope and intercept, interpret a coefficient in a multiple regression, recognize that the t-test and ANOVA are special cases of a linear model, and fit and read lm() in R.
Regression is just a recipe for predicting an outcome
A regression model describes one outcome (the thing you measured, like gene expression) as a function of one or more predictors (the things you think explain it, like drug dose or genotype). It does not prove cause; it summarizes how the outcome tends to change as the predictors change.
The simplest version, simple linear regression, fits a straight line through your data. That line has just two numbers:
y = b0 + b1 × x
- b1, the slope: how much the outcome
ychanges for each one-unit increase in the predictorx. Ifb1 = 2, then y goes up by 2 for every extra unit of x. - b0, the intercept: the predicted value of
ywhenxis zero. It sets where the line crosses the vertical axis.
1Seeing the slope and intercept
Each real point sits a little above or below the line. Those gaps are the residuals. Regression chooses the slope and intercept that make those residuals as small as possible overall (the "least squares" fit (it minimizes the sum of squared residuals)).
2Multiple regression: holding the others constant
Real biology rarely has one cause. Multiple regression just adds more predictors:
y = b0 + b1×x1 + b2×x2 + ...
Now each coefficient has a precise meaning: it is that predictor's effect on the outcome holding the other predictors constant. So b1 is the change in y per unit of x1 among samples that share the same x2. This is how you adjust for a confounder such as batch, sex, or age: put it in the model, and the other coefficients describe effects beyond it.
3The big idea: your favorite tests are linear models
Here is the insight that makes everything click. Many tests you already know are special cases of one linear model, differing only in what kind of predictor you feed it.
| Familiar test | Is really a linear model with... | What the slope means |
|---|---|---|
| Two-group t-test | one binary (0/1) predictor | the difference in group means |
| One-way ANOVA | one categorical predictor (several groups) | each group's mean vs a reference group |
| ANCOVA | one categorical plus one numeric predictor | group difference adjusted for the numeric covariate |
| Pearson correlation | one numeric predictor (both variables standardized) | the strength of the linear relationship |
When you compare two groups with a classic (equal-variance) t-test, you are fitting y = b0 + b1×group where group is 0 for one group and 1 for the other. The intercept b0 is the first group's mean, and the slope b1 is exactly how much the second group differs. ANOVA is the same idea with a categorical predictor that has more than two levels. Learn the linear model once and these tests stop being separate things to memorize.
Why this matters in bioinformatics
The workhorse RNA-seq tools are all built on linear models: DESeq2 and edgeR use generalized linear models (linear models extended to count data), and limma fits ordinary linear models to log-transformed expression values. The "design formula" you write for them, such as ~ condition + batch, is exactly the predictor list of a linear model. Understanding lm() is the foundation for understanding those tools.
4Worked example: fitting lm() in R
Suppose you measured a gene's expression at several drug doses and want to know how strongly expression tracks dose. In R you fit the model and read its summary:
# expression measured across a range of doses dose <- c(0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5) expression <- c(5.0, 6.2, 5.4, 6.9, 6.2, 7.9, 6.9, 8.6, 7.7, 9.4) fit <- lm(expression ~ dose) summary(fit) # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 5.17 0.39 13.2 1.03e-06 # dose 0.82 0.15 5.6 0.000507 <- slope b1 # # Multiple R-squared: 0.80 (output shortened)
How to read it:
- The dose estimate (0.82) is the slope: expression rises by about 0.82 units for every one-unit increase in dose.
- Its p-value (0.000507) tests whether that slope differs from zero. Small p means dose is associated with expression more than you would expect by chance.
- The (Intercept) 5.17 is the predicted expression at dose zero.
- R-squared (0.80) is the fraction of variation in expression that the model explains: here about 80 percent.
To run a t-test as a linear model instead, you would write lm(expression ~ group) with a two-level group, and the group coefficient is the difference in means.
5A quick word on assumptions
Linear models trust three things, and it is worth a glance before believing the numbers. First, that the relationship is roughly linear (a straight line is a fair summary, not a curve). Second, that the residuals are reasonably symmetric, similar in spread across the range, and not strongly patterned. Third, that each data point is independent: technical replicates of the same sample are not separate data points. A quick plot(fit) in R shows residual plots that flag obvious problems. If the relationship curves, you may need to transform a variable or use a different model.
Common trap
The intercept is only meaningful if x = 0 is a real, sensible value. For a dose that never reaches zero, the intercept is just a mathematical anchor for the line, not a quantity to interpret on its own.
Do not predict beyond your data
A fitted line describes the range you actually measured. Using it far outside that range is called extrapolation, and it quietly assumes the straight line keeps going. Biology rarely cooperates: responses level off, cells die at high doses, and if a line slopes down, it will eventually predict impossible values, such as expression below zero.
Check your understanding
lm() function fits the model and summary() reports the coefficients, p-values, and R-squared.Sources & further reading
- Altman N, Krzywinski M. Simple linear regression. Nat Methods 12: 999-1000, 2015. doi:10.1038/nmeth.3627
- Krzywinski M, Altman N. Multiple linear regression. Nat Methods 12: 1103-1104, 2015. doi:10.1038/nmeth.3665
- Ritchie ME, Phipson B, Wu D, Hu Y, Law CW, Shi W, Smyth GK. limma powers differential expression analyses for RNA-sequencing and microarray studies. Nucleic Acids Res 43: e47, 2015. doi:10.1093/nar/gkv007
- Lindeløv JK. "Common statistical tests are linear models (or: how to teach stats)". lindeloev.github.io
Last reviewed: October 2026.