[BioC] Confusion over limma documentation and design/contrast
michael watson (IAH-C)
michael.watson at bbsrc.ac.uk
Fri Nov 12 14:42:22 CET 2004
Hi Gordon
Thanks for the response. I worked through my two examples and found out
they are equivalent.
>Do you know how to multiply a vector by a matrix? If you do, then I
think
>the best way to figure out what the design matrix is doing for you is
just
>to sit down with a piece of paper and a pencil for a few minutes, and
>multiply the design matrix by the coefficient vector.
I did actually do this previous to sending the mail but it didn't easy
my confusion. Eg:
> apoai.design
ApoAI Control
1 0 1
2 0 1
3 0 1
4 0 1
5 0 1
6 0 1
7 0 1
8 0 1
9 1 0
10 1 0
11 1 0
12 1 0
13 1 0
14 1 0
15 1 0
16 1 0
> apoai.contrasts
ApoAI - Control
ApoAI 1
Control -1
> apoai.design %*% apoai.contrasts
ApoAI - Control
1 -1
2 -1
3 -1
4 -1
5 -1
6 -1
7 -1
8 -1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
So I still don't see how multiplying those two matrices relates to the
ApoAI design matrix given in the documentation, which is:
Control-Ref KO-Control
c1 1 0
c2 1 0
c3 1 0
c4 1 0
c5 1 0
c6 1 0
c7 1 0
c8 1 0
k1 1 1
k2 1 1
k3 1 1
k4 1 1
k5 1 1
k6 1 1
k7 1 1
k8 1 1
I have read the updated limma documentation and it is clearer now, but
it is still unclear why the above design matrix is used for the ApoAI
data - there is no explanation as to how it relates to the design matrix
and contrasts matrix I calculated above using modelMatrix() and
makeContrasts().
Mick
-----Original Message-----
From: Gordon Smyth [mailto:smyth at wehi.edu.au]
Sent: 12 November 2004 12:23
To: michael watson (IAH-C)
Cc: bioconductor at stat.math.ethz.ch
Subject: Re: Bioconductor Digest, Vol 21, Issue 12
You are reading the Limma User's Guide written for Bioconductor Release
1.4. Could I encourage you to consider the moving onto Bioconductor 1.5?
Even without upgrading your software, you could read a more recent
User's
Guide at http://bioinf.wehi.edu.au/limma/usersguide.pdf. Section 10
might
help, especially section 10.5.
>Date: Thu, 11 Nov 2004 12:11:34 -0000
>From: "michael watson (IAH-C)" <michael.watson at bbsrc.ac.uk>
>Subject: [BioC] Confusion over limma documentation and design/contrast
> matrices
>To: <bioconductor at stat.math.ethz.ch>
>
>Hi
>
>The confusion comes from the examples given in usersguide.pdf.
>Sections 7.3 and 8.2 both deal with two colour microarray data where a
>common reference has been used.
>
>Section 7.3 advocates the use of designMatrix() and makeContrasts(),
>where lmFit() is first used with the design matrix, and then
>contrasts.fit() is used with the contrasts matrix, and then eBayes()
>applied to the resulting linear model fit.
>
>Section 8.2 gives us the design matrix directly, and does not use a
>contrasts matrix at all.
>
>So my first question is this: with two colour cDNA microarrays which
>use a common reference, do we need both a design matrix and a contrasts
>matrix, or just a design matrix? (I'm assuming it depends on how many
>samples there are in addition to the reference, but I'm not sure).
>
>Looking at section 8.2, the ApoAI data, we have three samples - control
>mice, ApoAI mice and the reference sample. 8 control mice were
>compared to the reference and 8 ApoAI mice were compared to the
>reference, and in all cases the reference was Cy3. Therefore, a
>targets file to describe this experiment can reasonably be expected to
>look like this:
>
> SlideNumber Cy5 Cy3
>1 c1 Control Ref
>2 c2 Control Ref
>3 c3 Control Ref
>4 c4 Control Ref
>5 c5 Control Ref
>6 c6 Control Ref
>7 c7 Control Ref
>8 c8 Control Ref
>9 k1 ApoAI Ref
>10 k2 ApoAI Ref
>11 k3 ApoAI Ref
>12 k4 ApoAI Ref
>13 k5 ApoAI Ref
>14 k6 ApoAI Ref
>15 k7 ApoAI Ref
>16 k8 ApoAI Ref
>
>If we run modelMatrix() on this, we get this:
>
> ApoAI Control
>1 0 1
>2 0 1
>3 0 1
>4 0 1
>5 0 1
>6 0 1
>7 0 1
>8 0 1
>9 1 0
>10 1 0
>11 1 0
>12 1 0
>13 1 0
>14 1 0
>15 1 0
>16 1 0
>
>If we then carry on the example in 7.3, and create a contrasts matrix,
>then I assume we are interested in the comparison of ApoAI knockout
>mice to Control mice, so I run:
>
> > makeContrasts(ApoAI-Control, levels=apoai.design)
>
>And get this
>
> ApoAI - Control
>ApoAI 1
>Control -1
>
>So, just to take a breath here, I am using the documentation from
>section 7.3 to run against the data in section 8.2. I now have a
>design matrix and a contrasts matrix for the ApoAI data. The only
>problem is that they look completely different to the example design
>matrix given in section 8.2. The design matrix there is:
>
> Control-Ref KO-Control
>c1 1 0
>c2 1 0
>c3 1 0
>c4 1 0
>c5 1 0
>c6 1 0
>c7 1 0
>c8 1 0
>k1 1 1
>k2 1 1
>k3 1 1
>k4 1 1
>k5 1 1
>k6 1 1
>k7 1 1
>k8 1 1
>
>And there is no contrasts matrix.
>
>So, my question 2: is the design matrix given in section 8.2 the
>equivalent of using the design and contrasts matrices that I calculated
>above?
Yes it is. This has been said many, many times on this list.
Do you know how to multiply a vector by a matrix? If you do, then I
think
the best way to figure out what the design matrix is doing for you is
just
to sit down with a piece of paper and a pencil for a few minutes, and
multiply the design matrix by the coefficient vector.
Gordon
>Question 3: does the fact that the ApoAI data only has one contrast of
>interest mean that I don't need a contrasts matrix, I only need a
>design matrix? (albeit a DIFFERENT design matrix to one that would be
>given by modelMatrix()).
>
>Question 4: can anyone recommend a good book which I can go and read
>and learn all about design and contrast matrices and their relation to
>linear models? Everything I have read so far just says something like
>"... The design matrix is therefore this... and the contrast matrix is
>therefore this..." and doesn't actually explain how exactly the
>structure of the matrices was arrived at...
>
>Thanks and sorry for the long mail!
>
>Mick
More information about the Bioconductor
mailing list