# [BioC] Contrast matrix in limma factorial design for two color data

Dejian Zhao zhaodj at ioz.ac.cn
Wed Nov 19 15:07:27 CET 2008

```Dear list members and especially limma users,

For the absence of examples about factorial design using two-color
arrays* in limma user's guide,I resort to this email list in the hope of
getting a hint.
(* Chapter  8.7  takes  single-color  arrays  for example.
* Chapter 11.5 takes two-color arrays for example. However, when
constructing design matrix, a common reference is chosen, which makes it
the same way to make contrast matrix as in single-color arrays.)

and proposed two answers for discussion. Later Naomi Altman gave another
solution. I have no idea which answer is right and I'd like to post my

WT and MU are untreated while wt and mu are treated (see diagram below).
The linking lines stand for hybridizations and there are dye-swap
hybridizations in the four comparisons. The interested contrasts are
mu-MU, wt-WT, and (mu-MU)-(wt-WT). I make the design matrix using WT as
ref. My way of making contrast matrix may be controversial but I think
it is reasonable. The contrast matrix wt-WT  is  set to wt ("wt_WT"=wt),
because WT is used as ref in making design matrix thus wt means
comparison with WT implicitly. There should not be an argument about
"mu_MU"=mu-MU. As to the contrast matrix "(mu_MU)_(wt_WT)"=(mu-MU)-wt,
it can be explained in the same way as "wt_WT"=wt.

Although I consider it reasonable, I am not that confident. Any feedback
is welcome.

The diagram for the experimental design and the code are listed below.
For the convenience of comparison and discussion, Adrian and Naomi's
methods are also pasted below.

wt----mu     <--treated
|           |
WT---MU    <--untreated

> targets
Cy3 Cy5 FileName
1  wt  WT    1.gpr
2  mu  MU    2.gpr
3  MU  WT    3.gpr
4  mu  wt    4.gpr
5  WT  wt    5.gpr
6  MU  mu    6.gpr
7  WT  MU    7.gpr
8  wt  mu    8.gpr
> design<-modelMatrix(targets,ref="WT")   #<----WT as ref!
Found unique target names:
mu MU wt WT
> design
mu MU wt
[1,]  0  0 -1
[2,] -1  1  0
[3,]  0 -1  0
[4,] -1  0  1
[5,]  0  0  1
[6,]  1 -1  0
[7,]  0  1  0
[8,]  1  0 -1
>
contrast.matrix<-makeContrasts("wt_WT"=wt,"mu_MU"=mu-MU,"(mu_MU)_(wt_WT)"=(mu-MU)-wt,levels=design)
> contrast.matrix
Contrasts
Levels wt_WT mu_MU (mu_MU)_(wt_WT)
mu     0     1               1
MU     0    -1              -1
wt     1     0              -1

> Dear Prof. Smyth and experts,
>
> I am writing to you as a final option, after not finding an
> appropriate answer in BioC mailing list, internet and online
> tutorials.
> Although the documentation is the 'best reference',  one particular
> piece is missing in the documentation may be due to its complexity.
> That is factorial design of a two-color microarray data.
>
> We are using mouse agilent chips for identifying effect of a drug on a
> mutant vs. normal mouse strain. We used dye-swap for some chips.  The
> target files looks like this:
>
>> targets
>>
>    Array Cy3 Cy5 Treatment Shock
> 1 Array1  WT  MU         Y     H
> 2 Array2  WT  MU         N     C
> 3 Array3  WT  MU         Y     H
> 4 Array4  MU  WT         N     C
> 5 Array5  WT  MU         Y     C
> 6 Array6  WT  MU         Y     C
>
> The aim of the experiment is to find differentially expressed genes
> between MU and WT and importantly find genes differing between
> MU.Treated(Y) and MU.Untreated(N).
> Similarly MU.Heathshock - MU.Noheatshock(C).
>
> Since affy based estrogen data example is highlited in the
> documentation, I am not sure if the following code is correct or
> writing a design for this design is more complex that what I have
> attempted below.
>
> Method 1:
> --------------
>
>
>> TS <- paste(targets\$Cy5,targets\$Cy3,targets\$Treatment,sep='.')
>>
>
>
>> TS <- factor(TS,levels=c("MU.WT.Y","MU.WT.N","MU.WT.Y","WT.MU.N","MU.WT.Y","MU.WT.Y"))
>>
>
>
>> TS
>>
> [1] MU.WT.Y MU.WT.N MU.WT.Y WT.MU.N MU.WT.Y MU.WT.Y
> Levels: MU.WT.Y MU.WT.N MU.WT.Y WT.MU.N MU.WT.Y MU.WT.Y
>
>
>> design <- model.matrix(~0+TS,ref='WT')
>>
>
>
>> colnames(design) <- levels(TS)
>>
>
>
>> design
>>
>   MU.WT.Y MU.WT.N MU.WT.Y WT.MU.N MU.WT.Y MU.WT.Y
> 1       1       0       0       0       0       0
> 2       0       1       0       0       0       0
> 3       1       0       0       0       0       0
> 4       0       0       0       1       0       0
> 5       1       0       0       0       0       0
> 6       1       0       0       0       0       0
> attr(,"assign")
> [1] 1 1 1 1 1 1
> attr(,"contrasts")
> attr(,"contrasts")\$TS
> [1] "contr.treatment"
>
> I am not sure by this method, LiMMA understands dye-swam chips.
>
> Method 2:
> --------------
> Instead, I created a matrix like the following
>
>> mm1 <- as.matrix(mm1)
>> mm1
>>
>      Mu.T Mu.NT
> [1,]    1     0
> [2,]    0     1
> [3,]    1     0
> [4,]    0    -1
> [5,]    1     0
> [6,]    1     0
>
>> myFit <- lmFit(MA,mm1)
>> myFit <- eBayes(myfit)
>>
>
> # here Mu.NT is Mutant no treatment.
> method 2 when tried on my data, it works, and I get differentially
> expressed genes but I am not sure if those genes are correct.
>
> Which one of these methods is correct. I am not sure. If both are
> thank you.
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>

Naomi Altman wrote:
> I generally find it easier to do a single channel analysis for these
> more complicated designs.  Just follow the manual for single channel
> and you can then use the treatments directly to form the contrasts.
>
> --Naomi
>
> At 12:14 PM 10/31/2008, Adrian Johnson wrote:
>> Hi :
>> sorry for re-sending the my question. Lookinf forward for some help.
>> thanks.
>> I searched bioconductor list archive and could not find appropriate
>> modelmatrix and contrast matrix fitting
>> for the following type of data from two color.
>>
>>
>> > targets
>>    Array Cy3 Cy5 Treatment Shock
>> 1 Array1  WT  MU         Y     H
>> 2 Array2  WT  MU         N     C
>> 3 Array3  WT  MU         Y     H
>> 4 Array4  MU  WT         N     C
>> 5 Array5  WT  MU         Y     C
>> 6 Array6  WT  MU         Y     C
>>
>>
>> I want to compare (MU.WT-Y) - (MU.WT-N)
>> and (MU.WT-H)-(MU.WT-C)
>>
>> How can I design my model matrix and fit contrasts.
>>
>> Could some one help me please.
>>
>> thanks
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>
> Naomi S. Altman                                814-865-3791 (voice)
> Associate Professor
> Dept. of Statistics                              814-863-7114 (fax)
> Penn State University                         814-865-1348 (Statistics)
> University Park, PA 16802-2111
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>
```