[BioC] Limma makeContrasts - incorporating known confounder

Bernd Klaus bernd.klaus at embl.de
Mon Dec 9 13:56:36 CET 2013


Dear Ed,

I think you are on the right track and your example
is treated in section 9.4. of the limma user guide.
It is essentially the same as the paired samples example:

####

SibShip <- as.factor(c(1,1,2,2,3,3))
Treat <- as.factor(rep(c("T","C"),3))
model.matrix(~ SibShip+Treat)

####

But instead of 3 subgroups you only have two (male / female).
using

####
design <- model.matrix(~gender + condition)
colnames(design) <- c("female", "male", "mu")
####

the design matrix will block the subjects per sex. Then, you can simply 
extract the coefficient corresponding to the treatment: 

####
topTable(fit, coef = "conditionmu")
####

Note that the first levels of the two factors are absorbed in the intercept:
The intercept corresponds to the expression level for female and wildtype.
 
Thus you do not need to fit contrasts here, since your contrast of interest
is already present as the third coefficient in the original design matrix. 

Hope that helps!

Best wishes,

Bernd


On Mon, 9 Dec 2013 12:06:06 +0000
Ed Mountjoy <emountjoy at gmail.com> wrote:

> Hi all,
> 
> I have used limma before for differential analysis but only for very simple
> experiments comparing two conditions. I am helping a colleague make the
> most out of an old dataset and wanted some advice. We have:
> 
>    - 8 affymetrix mouse4302 arrays
>    - 2 conditions: wildtype and mutant
>    - Samples were prepared at post-natal day 6 and were originally un-sexed
> 
> A principle components analysis showed samples weren't grouping by their
> condition and but samples were separated along PC1 by their sex (obvious
> because of Xist and a number of Y-linked genes). So:
> 
> 1) Is it possible to incorporate the gender of the samples into the
> analysis now that they are known?
> 
> The current design and contrast matrices I am using are as follows:
> 
> # Design matrix
> condition <- factor(c("wt", "mu", "wt", "mu", "wt", "mu", "wt", "mu"))
> condition <- relevel(condition, "wt")
> design <- model.matrix(~0 + condition)
> colnames(design) <- c("wt", "mu")
> # Contrast matrix
> cont.matrix <- makeContrasts(wtVmt = mu - wt, levels=design)
> 
> Using this simple design I get a very small number of significant results
> (2). So if I wanted to incorporate gender I think I know about the design
> matrix but am unsure about the contrast matrix.
> 
> # Design matrix
> condition <- factor(c("wt", "mu", "wt", "mu", "wt", "mu", "wt", "mu"))
> condition <- relevel(condition, "wt")
> gender <- factor(c('male', 'male', 'female', 'male', 'female', 'female',
> 'male', 'female'))
> design <- model.matrix(~0 + gender + condition)
> colnames(design) <- c("female", "male", "mu")
> # Contrast matrix
> cont.matrix <- ???
> 
> 2) What should the cont.matrix look like if I want to compare wildtype vs
> mutant using the levels "female" "male" "mu"?
> 
> I have read through the examples in the limma user guide but the answer is
> not obvious. Thanks for any help.
> 
> Ed
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list