Question: Limma package: explanation makeContrasts examples
gravatar for elisa.micarelli
3.8 years ago by
European Union
elisa.micarelli30 wrote:


even at this stage, I want to thank anyone will can help me.

I'm using the Limma package in order to anlayse the gene expression in different tissues(Sample). For each tissue I want to know which genes are overexpressed and underexpressed; for example I would be able to say that the gene_x is more expressed in tissue A than B (and C) but less expressed than D.

I read the manual of Limma package and I understood that the makeContrasts function defines the type of comparison among tissues, but I did't understand the comparison of following examples and their difference:

1) makeContrasts(B-A,C-B,C-A,levels=c("A","B","C"))

in this case the outuput is:

Levels B- A C - B C - A
    A      -1       0      -1
    B       1      -1       0
    C       0       1       1

 after fit2 and eBayes command, Which tissue is the output of topTable function?

2) makeContrasts(contrasts="A-(B+C)/2",levels=c("A","B","C"))

Levels A-(B+C)/2
    A              1.0
    B             -0.5
    C             -0.5

This case compare the tissue(Sample) A with B and C, it's  right? What is the reason of division by two? 

The output of topTable is the expression level of tissue A, it hasn't?

What is the difference beteween

makeContrasts(contrasts="A-(B+C)/2",levels=c("A","B","C")) and  makeContrasts(A-(B+C)/2,levels=c("A","B","C")) ?

3)   x <- c("B-A","C-B","C-A")
     makeContrasts(contrasts=x, levels=c("A","B","C"))

Levels B-A
    A    -1
    B     0
    C     1

I don't understand this output and the difference with makeContrasts(C-A,levels=design).


I think that the example 2) is suitable for my analysis but I'm not sure and I wont understand the division by the number of tissue(sample), is always necessary? and What do it means from the scientific point of view?

In the even that the second example is suitable for my analysis, I should to do an iterative procedure that compare one tissue at a time with all others; For example

the first comparison is:


the second is


the third is:


and so on, if there are over three tissues. It's right? If this approach is wrong, How should I proceed?

Thank you very much!




R gene • 7.8k views
ADD COMMENTlink modified 3.8 years ago • written 3.8 years ago by elisa.micarelli30

Thank for the answer.

I don't understand when should I specify the argument contrast in makeContrasts? Maybe I didn't unterstand the meaning of contrats.

2) the output in last part is the same, but in one case the makeContrasts returns (near Levels) the word contrast in the other one returns the specific combination of sample.

However the purpose of my analysis is to obtain for each gene a ranked list of expression level in tissues, sorting in decreasing way in according to expression level; so I think that I must to compare the first group  with all others but I don't know if  the comparison must to do one tissue at a time or together; for example:

contrast.matrix<-makeContrasts(A-B, A-C,levels=design)

Levels A-B, A-C
    A       1       1
    B      -1       0  
    C       0      -1

contrast.matrix<-makeContrasts(A- (B+C)/2, levels=design)

Levels A - (B + C)/2
   A             1.0
   B            -0.5
   C            -0.5

the results are different, but I didn't understand the scientific difference. What could be the correct approach for my analysis?

Thanks a lot again!



ADD REPLYlink written 3.8 years ago by elisa.micarelli30

next time you probably want to comment on my answer not on the original question.

A very simple way is to think of it as a see-saw where expression of each of your conditions is on one side, you want to know if the see-saw is significantly up or down for each gene so you know that gene expression is higher or lower when comparing between your conditions. When  you have two conditions, then you have two things sitting on one side of the see-saw. To make the weight even on both sides, you could take the average of the two conditions. However, taking the average expression of two very diverse conditions does not really make any sense, thats why the A-B, A-C, B-C comparisons makes more sense. If you want to ask the question of is A different from anything else (B and C) then that type of analysis is more like anova, the limma manual also goes over this I believe. The limma manual does a decent job at explaining different types of analysis, I would go over it again and try and pick out the example that most closely matches your biological question.

ADD REPLYlink written 3.8 years ago by Ying W3.9k

I'm sorry, I wanted comment your answer but I was mistaken.

However, I understood that for my analysis is necessary an anova analysis. So, thanks a lot for your advices and answers, now I'm going to read better the manual and understand the analysis that I should do. If I had any possible questions (about this discussion) I would try to ask you.

Thanks a lot again.


ADD REPLYlink written 3.8 years ago by elisa.micarelli30
gravatar for Ying W
3.8 years ago by
Ying W3.9k
South San Francisco, CA
Ying W3.9k wrote:

For future bioconductor related questions, this would probably be the better place to ask:

Off the top of my head

1. topTable by default takes the first contrast (B-A), do a ?topTable to see what options can be chosen

2. what you're doing here is saying you wish to compare condition A to condition B and C, however, you want to model B&C separately and make sure B&C together are the same weight as A (reason for division by 2, otherwise the combined B&C would have more weight in model). I've used this before when A is condition and B&C are two separate controls. Not sure what is the difference in the last part, do they output the same thing?

3. seems like when you set contrasts=x it only expects one contrast (maybe it assumes contrasts is a list not a vector?)

I'm not sure if 1 tissue vs all others is the kind of biological question you want to answer, the variability between tissues could be high. The comparison you made in 1. is very typical of what is done. the last one makes me think anova might be what you are looking for

ADD COMMENTlink written 3.8 years ago by Ying W3.9k
Please log in to add an answer.


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