How to add a second covariate in the analysis? age is the covariate in my design. I would also like to add sex to it. I looked at some of the answers but I am not sure they exactly explain what I am looking for? Would just adding it after age solve this?
Code should be placed in three backticks as shown below
The formula for DESeq2 works in the same way as any formula that we specify in R. The y variable is essentially the gene's expression, with predictors / covariates as x variables:
gene ~ age + condition
Thus, if you want to adjust for more covariates, just use something like:
~ age + sex + smoking + condition
Then, when deriving test statistics, check the coefficient names via resultsNames(dds) in order to ensure that you extrapolate the correct stats.
thank you! Will try that.