Hi,
I'm a student and I have doubts about how use Limma to contrast the differencial gene expression evaluating my three variables: disease (case/control), gender(male/female) and age.
My data is like this: (three columns with the gender, age and the disease)
> head(pData(gse))
gender age disease
GSM311511_jrs_U201u5_AR2_31_B112_R12558.CEL.gz female 88 control
GSM311528_jrs_U201u5_AR2_33_B112_R92737.CEL.gz male 53 control
GSM311511_jrs_U201u5_AR2_31_B112_R97522.CEL.gz male 94 control
GSM311530_jrs_U201u5_AR2_55_B013_R97210.CEL.gz female 40 control
GSM311511_jrs_U201u5_AR2_31_B110_R95417.CEL.gz male 35 control
GSM311511_jrs_U201u5_AR2_31_B012_R97841.CEL.gz female 89 control
I know build my experiment over my variable disease:
design= model.matrix(~ pData(gse)[,"disease"])
colnames(design)= c("control", "case")
fit= lmFit(gse, fesign)
fit1= eBayes(fit)
topTable(fit1, coef=2, adjust="BH", number= as.numeric(dim(gse)[1]))
But, How I can do a contrast Limma with my 3 variables? Thank for your help!
age= pData(gse)[,"age"]
gender= pData(gse)[,"gender"]
disease= pData(gse)[,"disease"]
age.group= ifelse(age>40,"over40", "under40")
design = model.matrix(~0 + disease + gender + gender:age)
contr.matrix <- makeContrasts(

Thanks a lot for for your answer and helping me!!!!
However, I tried to follow your instructions, but I don't know how to build it well :-S
age= pData(gse)[,"age"] gender= pData(gse)[,"gender"] disease= pData(gse)[,"disease"] age.group= ifelse(age>40,"over40", "under40") design = model.matrix(~0 + disease + gender + gender:age.group) colnames(design) = c("diseasecontrol", "diseasecase","gendermale", "gendermale_age", "genderfemale_age") fit.plus = lmFit(gse, design) # 1. Compare by age: contrast.matrix <- makeContrasts(genderfemale_age, gendermale_age, levels=design) fit2 <- contrasts.fit(fit, contrast.matrix) fit2 <- eBayes(fit2) topTable(fit2, coef = 2, adjust = "BH") (results= decideTests(fit2, adjust.method ="BH", p.value=0.005)) summary(results)Error in contrasts.fit(fit, contrast.matrix) : Number of rows of contrast matrix must match number of coefficients More: Warning message: In contrasts.fit(fit, contrast.matrix) : row names of contrasts don't match col names of coefficients# 2. Compare by gender:contrast.matrix <- makeContrasts(gendermale, genderfemale_age - gendermale_age, levels=design) > topTable(fit2, coef = NULL, adjust = "BH")You're using a different design matrix from what you had in your original post, with a
gender:age.groupterm rather thangender:age. This results in more coefficients in your design matrix, which probably causes the error and warning that you've observed. Why not just use the original design matrix? A threshold of 40 seems arbitrary anyway.Again, many thanks for your useful help. I achieved results, and I understood and learned to do something else.
Problem solved!