limma interaction contrasts
Entering edit mode
joelrome88 ▴ 20
Last seen 7.2 years ago


I have a quick doubt about my design matrix and if the contrasts I'm making are correct. I have an experimental design with two factors, genotype and treatment. I have 13 genotypes (control and 12 mutants) and two treatments (A being control and B the actual treatment).

The groups made are the genoytpe*treatment interaction: wtA, wtB, mut1A, mut1B...mut12A,mut12B.

I created my design matrix without an intercept :

> design <- model.matrix(~0+Group) #Then change the names to remove the "Group" part of the name

And so, I'm interested in the genotype by treatment interaction. What is the correct formulation of my contrasts to do this? I've tried different notations with different results:

> cont.matrix <- makeContrasts(


Then the fit, etc:

> fit <- lmFit(v,design)
> fit2 <-, cont.matrix)
> fit2 <- eBayes(fit2)
> results <- decideTests(fit2,lfc = 1,p.value = 0.01)
> summary(results)

   mut1_a mut1_b mut1_c
-1     530       0     108
0    18504   19881   19465
1      847       0     308

I get more DE genes using the first approach which I belive is the correct one,when I check my contrast matrix all the factors that belong to control treatment (mutA wtA) are -1, while those in treatment are +1 (mutB,wtB).

Repeating this for every mutant (mut2...mut12) I get very similar results, 0 DE genes for the second-type approach, more for the first one and less for the third one.

Do you have any insight to if my reasoning is correct?

Thank you!

limma contrast matrix limma design matrix limma • 5.2k views
Entering edit mode

You need to make a limma tag, otherwise the maintainers won't get informed.

Entering edit mode
Aaron Lun ★ 28k
Last seen 13 hours ago
The city by the bay

The correct contrast for testing the interaction term is mut1_b. Consider that, if there were no interaction, then the combined effect of treatment and mutation would be purely additive, i.e., equal to the sum of the separate effects of treatment and mutation. This yields a null hypothesis equivalent to your contrast above:

(mut1B - wtA) # combined effect of treatment and mutation
- (mut1A - wtA) # effect of mutation alone
- (wtB -  wtA) # effect of treatment alone
= (mut1B - mut1A) - (wtB - wtA)
= 0 # under the null hypothesis

Another way of looking at it is that you want to know whether the effect of treatment is the same in both wild type and mutant backgrounds. If so, it means that the treatment is independent of the genotype in which it was performed, i.e., no interaction.

Your results indicate that there is no significant interaction effect in any of your mutants. Your other contrasts yield many DE genes because they are not sensible. In addition, read the note in ?decideTests about using lfc, you should use treat instead.

Entering edit mode

I see, I'll take a look at the decideTests - treat parameter.

In the case of the third contrast (mut1B - wtA), is this a fair comparison to make by itself?

In the case of an interaction effect, does this mean that the difference between the mean values of (wtB-wtA) and (mutB-mutA) is different for the effect to be present?

When I look at the mean expression (using CPMs) of wt at the two conditions and mutant at the two conditions I see cases where what would be the difference of differences would be large (ie, within wt samples are close together but within mut samples are far apart). Could this be an effect of the transformation to log2?


Thank you!











Entering edit mode

1) treat is a separate function.

2) The mut1B - wtA comparison makes little sense to me. There is no way to determine if the DE genes are due to the effect of the mutation or the effect of the treatment.

3) An interaction effect is present when the difference between the mean values of (wtB-wtA) and (mutB-mutA) is non-zero.

4) Yes, because the log-transformation means that the differences now refer to log-fold changes. Obviously, a difference of 10 vs 20 will look different from a difference of 100 vs 200 on the CPM scale, even though the fold-change in both cases is equal to 2.

Entering edit mode

Hi again,

I tried using treat and topTreat but I didn't get different results.

I have a naive question if a different paramterization answers the same questions. If using an intercept, and thus the contrasts as vectors of 0 and 1 I've come across different results.

> design = model.matrix(~Genotype*Treatment,data = meta)

I get the columns (Intercept), Genotype, Treatment and the interaction term Genotype:Treatment. Reading the guide I understand that I can address different questions, for example, the interaction term is given by the 4th term  ( c(0,0,0,1) ), and if I wanted to know the main effect of the treatment on the mutant regardless of the treatment the contrast would be c(0,0,1,1).

1) Is the contrast c(0,1,1,0) a valid one? The way I interpret this is that I get genes that are changing due to either genotype or treatment.

2) An example in the guide drops the last two factors c(0,0,1,1) to ask for genes changing in the mutant due to treatment (mutTreated vs mutUntreated), would the contrast c(0,1,1,1) work as an anova, finding genes that change either due to mutant or treatment? 

Thank you!






Entering edit mode

In the wonderful world of interaction models, one's intuition often breaks down. For the sake of explanation, I'll assume the first level of Genotype is WT, and the first level of Treatment is untreated.

  • Doing c(0, 0, 1, 1) will actually test for DE between KO-treated and KO-untreated. You can't interpret the middle two coefficients as main effects if you have a non-zero interaction term in your fitted model.
  • Doing c(0, 1, 1, 0) makes no sense. The second coefficient represents the log-FC between KO-untreated and WT-untreated, while the third coefficient represents the log-FC between WT-treated and WT-untreated. Here, your null hypothesis would be saying that these two log-FCs sum to zero. What does that mean?
  • If you want an ANOVA, you need multiple columns in your contrast matrix. If you want to account for DE due to any effect of mutation or treatment, then you'd need to drop coef=2:4, which effectively tests for whether there is DE between any of your four groups. Dropping only 2:3 is not enough, see above.

Hopefully, it should be clear by now that a one-way layout is much more intuitive.

Entering edit mode

Yes thank you! it's getting clearer now.

If doing c(0,0,1,1) removes both interaction and treatment effect leaving just the effect of treatment in the mutants, would c(0,1,1,1) ask for any change due to either genotype OR treatment?

Thank you so much for answering my questions!

Entering edit mode

No, c(0,1,1,1) would test for DE between WT-untreated and KO-treated. You need to do an ANOVA to test for differences due to genotype or treatment.


Login before adding your answer.

Traffic: 829 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6