Dear all,
I have a question regarding random effects in DESeq2.
I am doing differential expression analysis (disease type A vs. disease type B) with a clinical dataset (50 samples for each disease type).
I want to adjust for sex and a continuous variable telling where the sample was taken and known to affect gene expression (I will call this variable "depth").
So the formula would be ~sex+depth+diseasetype...
BUT some of the patients (NOT ALL) are represented by several samples, each with a different depth (but of course the same sex and same disease type). Collapsing is not an option, since the "depth" information is relevant.
In lme-synthax I would consider the formula:
gene~sex+depth+diseaseoutcome, random=1|idpat,
where idpat stands for the patient's ID.
I tried ~idpat+sex+depth+diseaseoutcome in DESeq2 but get the error message that the model matrix is not full rank (not surprising). If I remove sex or idpat from the formula, it works fine (not surprising either). But I do need both.
idpat is actually a random effect. Is there any way to include such a random effect in DESeq2?
Many thanks in advance!
Best wishes,
Anne

Dear Michael,
Thanks a lot for your helpful answer! PCA is a good idea, we will try it.
We have tried limma-voom but had problems with it for other reasons.
Our pheno data essentially looks like this:
PatID diseasetype sex depth
1 A f 12
1 A f 16
2 A m 10
3 B m 11
3 B m 15
4 A f 14
....
diseasetype and sex are the same for all samples of the same patients, but depth varies.
Thanks!
Anne
Yes, you can't compare across disease type and control for patient using fixed effects, because these variables are confounded. You can control for sex and depth but not patient here using fixed effects. DESeq2 doesn't have support for random effects.