# [BioC] 2 way anova in Bioconductor

Guillaume Meurice guillaume.meurice at igr.fr
Tue Jul 5 15:28:00 CEST 2011

```Dear All,

I have a few more question regarding the design matrix bellow (mainly How to interpret the coefficient ?)

> > design
>   (Intercept) Sex1 Time1 Time2 Sex1:Time1 Sex1:Time2
> 1            1   -1    -1    -1          1          1
> 2            1   -1     0     1          0         -1
> 3            1   -1     1     0         -1          0
> 4            1   -1    -1    -1          1          1
> 5            1   -1     0     1          0         -1
> 6            1   -1     1     0         -1          0
> 7            1    1    -1    -1         -1         -1
> 8            1    1     0     1          0          1
> 9            1    1     1     0          1          0
> 10           1    1    -1    -1         -1         -1
> 11           1    1     0     1          0          1
> 12           1    1     1     0          1          0
> attr(,"assign")
> [1] 0 1 2 2 3 3
> attr(,"contrasts")
> attr(,"contrasts")\$Sex
>       [,1]
> Male      1
> Female   -1
>
> attr(,"contrasts")\$Time
>  [,1] [,2]
> 3    1    0
> 2    0    1
> 1   -1   -1
>
> # In this design matrix, the (Intercept) coefficient is the grand mean, the Sex1 coef is the main effect of Sex,
> # the Time1 and Time2 coef taken together will give you the main effect of Time, and the Sex1:Time1 and
> # Sex1:Time2 coef taken together will give you the interaction term.

Could someone give more explanation of the interaction terms ? Does such terms catch the variability due to
both of these effects ?
In the example given above, let's imagine the time effect is very difficult to detect because the signal
is highly variable due to Sex effect.
Setting the interaction terms in the design matrix allow to discard this variability and then to get genes significantly
differentially expressed due to time 1 (using the time 1 coefficient) ?
And in this case, the logFC obtained are the good one ?

> # Now fit the model with your data
>
> > fit.2x3 <- eBayes(lmFit(YourData,  design))
> # To get the overall F test for the 2x3 take all coef except the Intercept:
> > overall.2x3 <- topTable(fit, coef=2:6, number=Inf)

Does this raise the features which are a significantly differentially expressed in one coefficient at least ?

> > mainSex <- topTable(fit, coef=2, number=Inf)
> # Note that the logFC values need to be multiplied by 2 to get the actual Male:Female logFC value!

I didn't understand why you need to multiply by 2 here ? The coefficient didn't already give the correct logFC values ?

many thanks for the help.

--
GM

```