Can someone explain to me how is the sign of log2FoldChange is set in the results of DEseq2? I was pretty sure that it is calculated as log2(Counts_treatment/Count_reference), where reference is determined alphabetically (unless specified by user).
It does appear to be the case - in most, but not all cases. Sometime the sign is the opposite to what you would expect by just looking at the read counts data. Moreover, sometimes the sign changes depending on whether shrinkage is use or not and logFC vs. LRT tests.
So it seems that under certain circumstances either the estimated fold change can switch signs (seems unlikely?) or the order of what is reference and what is treatment is reversed.
Could someone comment on this?
Thanks!
Well, no, the software isn't going to randomly flip flop. Though maybe shrinkage would change a fold change that was marginally positive to marginally negative. It would probably help if you provided normalized counts and colData for a few genes where you think the software has erred.