Question: Contrasts & coefficients in limma
0
gravatar for prathap1708
22 months ago by
Duke NUS medical school, Singapore
prathap17080 wrote:

Hi, I have a doubt regarding contrasts. In my case, i understood,the 1st coefficient is comparison of MHO with MHNW, 2nd coefficient is comparison of MAO with MHNW and 3rd coefficient is comparison of MAO with MHW . Please let me know, if I understood wrong. Please find my code below.

design.adipose = model.matrix(~0+AdiposeCPMCountGT1_min20percentsamples$samples$group.1+AdiposeCPMCountGT1_min20percentsamples$samples$Gender)

# To rename column names
colnames(design.adipose)[1] = "MAO"
colnames(design.adipose)[2] = "MHNW"
colnames(design.adipose)[3] = "MHO"
colnames(design.adipose)[4] = "Gender"
# To do comparisons between groups
contr.matrix.Adipose = makeContrasts(MHOvsMHNW = MHO-MHNW,MAOvsMHNW = MAO-MHNW,MAOvsMHO = MAO-MHO,levels = colnames(design.adipose)[1:4])
# Voom function v = voom(AdiposeDGE,design.adipose,lib.size = colSums(AdiposeDGE$counts)*AdiposeDGE$samples$norm.factors,normalize.method="quantile",plot = TRUE)
ADD COMMENTlink modified 22 months ago by Gordon Smyth39k • written 22 months ago by prathap17080
Answer: Contrasts & coefficients in limma
0
gravatar for Gordon Smyth
22 months ago by
Gordon Smyth39k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth39k wrote:

Have you looked at the limma User's Guide, for example Sections 9.1-9.3? You have to fit a linear model and then use contrasts.fit before your contrast matrix will have any effect.

At the moment, you don't yet have any coefficients and you haven't yet made any comparisons.

To make the comparisons you want, code might go like this:

design.adipose <- model.matrix(~0+group.1+Gender,
                  data=AdiposeDGE$samples)
colnames(design.adipose) <- c("MAO","MHNW","MHO","Gender")
contr.matrix.Adipose = makeContrasts(
       MHOvsMHNW = MHO-MHNW,
       MAOvsMHNW = MAO-MHNW,
       MAOvsMHO = MAO-MHO,
       levels = design.adipose)
v <- voom(AdiposeDGE,design.adipose, normalize.method="quantile", plot = TRUE)
vfit <- lmFit(v, design.adipose)
vfitAdipose <- contrasts.fit(vfit, contr.matrix.Adipose)
efit <- eBayes(vfitAdipose)
voom.Results_MHO.vs.MHNW <- topTable(efit,coef="MHOvsMHNW", n=Inf)

and so on.

ADD COMMENTlink modified 22 months ago • written 22 months ago by Gordon Smyth39k

 I did linear modeling fitting and then the contrast was done.I didn't post the last few lines of code in the previous question. Sorry for that. Please see the remaining code here. Thanks for your spontaneous reply.

# Usual limma pipeline
vfit <- lmFit(v, design.adipose)
vfitAdipose <- contrasts.fit(vfit, contrasts=contr.matrix.Adipose)
efit = eBayes(vfitAdipose)
plotSA(efit)
summary(decideTests(efit))


## Access Results
# Examining individual genes from top to bottom
voom.Results_MHO.vs.MHNW = toptable(efit,coef = 1,adjust="BH",number = nrow(Adipose.Dataset))
voom.Results_MAO.vs.MHNW = toptable(efit,coef = 2,adjust="BH",number = nrow(Adipose.Dataset))
voom.Results_MAO.vs.MHO = toptable(efit,coef = 3,adjust="BH",number = nrow(Adipose.Dataset))

 

ADD REPLYlink modified 22 months ago • written 22 months ago by prathap17080

You should use topTable instead of toptable.

Also, you seem to be using two different DGEList data objects, one called AdiposeDGE and the other called AdiposeCPMCountGT1_min20percentsamples. I can't check whether these two datasets match up in terms of sample information. You obviously need to be consistent.

Otherwise your code looks correct.

Your code is longer than it needs to be in some respects, but it should work ok.

ADD REPLYlink modified 22 months ago • written 22 months ago by Gordon Smyth39k

Thanks prof. The two DGE list objects are same but we removed genes which were expressed very low in the 2nd DGE object.

 

ADD REPLYlink written 22 months ago by prathap17080
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 269 users visited in the last hour