[BioC] Limma-include interaction term

James W. MacDonald jmacdon at uw.edu
Tue Jun 12 19:33:43 CEST 2012


Hi Jack,

The conventional method is to use the model.matrix() function. I have no 
idea what your data look like, so here is a random example:

 > treat <- factor(rep(0:1, each = 5))
 > treat
  [1] 0 0 0 0 0 1 1 1 1 1
Levels: 0 1
 > age <- sample(25:35, 10, TRUE)
 > age
  [1] 32 30 32 35 29 26 27 25 33 34
 > model.matrix(~treat*age)
    (Intercept) treat1 age treat1:age
1            1      0  32          0
2            1      0  30          0
3            1      0  32          0
4            1      0  35          0
5            1      0  29          0
6            1      1  26         26
7            1      1  27         27
8            1      1  25         25
9            1      1  33         33
10           1      1  34         34
attr(,"assign")
[1] 0 1 2 3
attr(,"contrasts")
attr(,"contrasts")$treat
[1] "contr.treatment"

Note that this uses a different parameterization. In this case the 
treat1 coefficient is the difference between the treated and untreated 
samples (so you wouldn't specify a contrasts.matrix, you just do lmFit() 
and then eBayes()). The treat1:age coefficient captures the difference 
between the slopes for the treated and untreated samples.

So topTable(fit2, coef=2) gives you genes that are differentially 
expressed between treated and untreated and topTable(fit2, coef=4) gives 
you genes where the change in expression at different ages varies 
between treated and untreated subjects.

Best,

Jim




On 6/12/2012 12:57 PM, Yao Chen wrote:
> Thanks, James
>
> How to include "age:treatment" interaction in the design matrix?
>
> Jack
>
> 2012/6/12 James W. MacDonald <jmacdon at uw.edu <mailto:jmacdon at uw.edu>>
>
>     Hi Jack,
>
>
>     On 6/12/2012 10:10 AM, Yao Chen wrote:
>
>         Dear All,
>
>         I try to find differential expressed genes between treat and
>         untreated
>         samples, and also I want to include the age effects.
>
>         The design matrix is like this:
>
>         treat  untreated  age
>           1        0            30
>           0         1           40
>           1        0            35
>
>
>         The "treat" is factor, but "age" is continuous.  How can I set the
>          "cont.matrix"?
>
>
>     Pretty much just like you (or at least I) would expect:
>
>     contrast <- makeContrasts(treat - untreat, levels =  design)
>
>     But note that the design you are specifying allows different
>     intercepts, but the slope is assumed to be the same for treated
>     and untreated. If you want to allow different slopes as well, you
>     need to introduce an age:treatment interaction term. Here I am
>     assuming you have more than three samples.
>
>     Best,
>
>     Jim
>
>
>
>         Thanks,
>
>         Jack
>
>                [[alternative HTML version deleted]]
>
>         _______________________________________________
>         Bioconductor mailing list
>         Bioconductor at r-project.org <mailto:Bioconductor at r-project.org>
>         https://stat.ethz.ch/mailman/listinfo/bioconductor
>         Search the archives:
>         http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>
>     -- 
>     James W. MacDonald, M.S.
>     Biostatistician
>     University of Washington
>     Environmental and Occupational Health Sciences
>     4225 Roosevelt Way NE, # 100
>     Seattle WA 98105-6099
>
>

-- 
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099



More information about the Bioconductor mailing list