I have a question about how DEseq2 handles batch effects/ multiple factors. This is covered in the manual, but I just want to be certain I am doing it correctly.
Say I have an experiment with this design:
Sample Age Sex
1 Young F
2 Young F
3 Old F
4 Old F
5 Old F
6 Old F
7 Old F
8 Young M
9 Young M
10 Young M
11 Young M
12 Young M
13 Old M
14 Old M
Where age and sex both, independently, impact RNA expression. The proper way to see the impact of sex alone would be to run DEseq2 like so:
design(ddsMF) <- formula(~ Age + Sex)
ddsMF <- DESeq(ddsMF)
and then just view the results using:
resMF <- results(ddsMF)
Likewise, if I wanted to see the impact of age alone, I could just look at the results of the same DEseq2 run using the contrast parameter:
resMFType <- results(ddsMF,
contrast=c("Age", "F", "M"))
Am I correct in my understanding that this will make DEseq2 control for the effects of Sex/Age when looking at the other, and thus the Age comparison will not be impacted by the fact that most of the young samples are male (likewise, the Sex comparison will not be impacted by the fact that most of the female samples are old)? If this is correct, could someone please point me a mathematical description of how this control is implemented?
Thank you very much!