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?
"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."
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.:
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.