Question: order of factors
gravatar for adam
3.1 years ago by
adam0 wrote:

Hi Micheal,

I am trying to understand the directionality of the log2 fold change that is reported by DESeq2.  

I see in the manual that it says that the first level of the factor will be taken as the dominator for calculations by DESeq2.  I also see that the order of the factor levels matters when results() is called.  Can you elaborate on how those two work together. For example, lets suppose I am testing between level A and level B, would the results be wrong if in the DESeq() call level A was first, but in the results() call level B was first?




deseq2 • 1.3k views
ADD COMMENTlink modified 3.1 years ago by Michael Love25k • written 3.1 years ago by adam0
Answer: order of factors
gravatar for Michael Love
3.1 years ago by
Michael Love25k
United States
Michael Love25k wrote:

In the vignette we have:

"By default, R will choose a reference level for factors based on alphabetical order. Then, if you never tell the DESeq2 functions which level you want to compare against (e.g. which level represents the control group), the comparisons will be based on the alphabetical order of the levels. There are two solutions: you can either explicitly tell results which comparison to make using the contrast argument (this will be shown later), or you can explicitly set the factors levels."

To restate:

You don't have to specify factor levels in the beginning, but instead you would have to specify which level should be the numerator and which the denominator of the fold change when you call results() by using the contrast argument, e.g.:

results(dds, contrast=("cond","B","A"))

Another option is that you can set the factor levels manually, before you run DESeq(), and then you don't have to use the contrast argument:


Either way, when you print results() in the console you will see which is the numerator and which is the denominator printed above the results table.

ADD COMMENTlink written 3.1 years ago by Michael Love25k


results(dds, contrast=("cond","B","A"))

returns log2(B/A)?

ADD REPLYlink modified 16 months ago • written 16 months ago by mbk0asis0

Yes, this should be printed at the top of the table also when you print it in R.

ADD REPLYlink written 16 months ago by Michael Love25k
Please log in to add an answer.


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