I encountered a problem using DESeq2 adding variables created with RUVSeq aiming to remove unwanted variation in my dataset. I set up my DESeq dataset like this:
dds <- DESeqDataSetFromMatrix(countData = counts, colData = sample_info, design = ~Batch+Condition)
Batch is a factor with 3 levels (1,2,3), Condition is a factor with 4 levels (Ctrl, trt1, trt2, trt3). Each Condition has one sample per batch. In total there are 12 samples.
When I call
DESeq(DESeq.ds) on this, I don't get any error.
RUVSeq I generated now some variables and want to use the first 7 to take care of the unwanted variation.
I added those 7 numeric variables (W_1 - W_7) to the
colData slot, and updated the design of the DESeq dataset.
design(dds) <- ~ W_1+W_2+W_3+W_4+W_5+W_6+W_7+Batch+Condition `
When I run now:
dds <- DESeq(dds) an error is returned:
Error in designAndArgChecker(object, betaPrior) : full model matrix is less than full rank
When I remove W_7 from the design, the following error is returned:
Error in checkForExperimentalReplicates(object, modelMatrix) : The design matrix has the same number of samples and coefficients to fit, so estimation of dispersion is not possible. Treating samples as replicates was deprecated in v1.20 and no longer supported since v1.22. `
When I remove W_7 and W_6 from the design, I can run
DESeq() without an error.
Is there a maximum amount of variables that can be added to the design, depending on sample number? Or how can these errors be explained?