# [BioC] [limma] 3-Way Factorial design

Ron Ophir ron.ophir at weizmann.ac.il
Sun Jul 30 12:49:49 CEST 2006

```Dear All,

As it described in Limma User's Guide chapter 8.7 there are more than
one approach to create the design and contrst matrices. I would like to
focus in this question on the first example where in the design matrix
one creates all possible combinations between the factors. Thus for
target file of Genotype and treatment

FileName Strain Treatment
File1     WT       U
File2     WT       S
File3     Mu       U
File4     Mu       S
File5     Mu       S

we get a design matrix as follow

WT.U WT.S Mu.U Mu.S
1  1    0    0    0
2  0    1    0    0
3  0    0    1    0
4  0    0    0    1
5  0    0    0    1
attr(,"assign")
[1] 1 1 1 1
attr(,"contrasts")
attr(,"contrasts")\$TS
[1] "contr.treatment"

and contrast for the interaction is

Int
WT.U     1
WT.S    -1
Mu.U    -1
Mu.S     1

My question is how to move to three factors. I know that this design
was pointed by Sean in one of the previous messages. However, he was
intrested mainly in the main effects and the solution that was suggested
by Gordon was based on the "treatment-contrast parametrization" approach
by running model.matrix(~factorA*factorB*factorC).

I would like to use the "all combinations" approach and I have the
following experimental design

Dev    Treat Cultivar
1    Stage1 Ctl   HS
2    Stage1 Str   HS
3    Stage1 Ctl   HS
4    Stage1 Str   HS
5    Stage1 Ctl   HT
6    Stage1 Str   HT
7    Stage1 Ctl   HT
8    Stage1 Str   HT
9    Stage2 Str   HS
10   Stage2 Ctl   HS
11   Stage2 Str   HS
12   Stage2 Ctl   HS
13   Stage2 Ctl   HT
14   Stage2 Str   HT
15   Stage2 Ctl   HT
16   Stage2 Str   HT

after creating a design matrix by

DTC <- factor(paste(ThreeWay\$Dev, ThreeWay\$Treat, ThreeWay\$Cultivar,
sep="."))
design<-model.matrix(~0+DTC)

I am interesting in in three interactions. The interaction with in each
stage between Treatment and Cultivar and Interaction between all, i.e.,
Dev*Treat*Cultivar.

Would the contrasts matrix for these question should be looks like
that

Stg1.Tr.Cult    Stg2.Tr.Cult    Stg.Tr.Cult
Stage1CtlHS      1                  0              -1
Stage1CtlHT     -1                  0               1
Stage1StrHS     -1                  0               1
Stage1StrHT      1                  0              -1
Stage2CtlHS      0                  1               1
Stage2CtlHT      0                 -1              -1
Stage2StrHS      0                 -1              -1
Stage2StrHT      0                  1               1
?

Thanks,
Ron

```