6
$\begingroup$

I'm trying to run a differential gene expression analysis using DESeq2, with counts coming from kallisto. I have imported them using tximport and I'm creating the DESeqDataSet (dds) using the DESeqDataSetFromMatrix function.

> dds <- DESeqDataSetFromMatrix(counts,
                                samples,
                                ~ strain + batch)

And I get the following error, expected given my experimental design:

Error in checkFullRank(modelMatrix) :
  the model matrix is not full rank, so the model cannot be fit as specified.
  One or more variables or interaction terms in the design formula are linear
  combinations of the others and must be removed.

Now, I know that I can just remove one column from the design matrix to make it work, but is there a way to supply my own design matrix to DESeq2? The following code raises an error:

> design <- model.matrix(~strain+batch, s2c)
> design = design[, -9] # removing a column to avoid full-rank
> dds <- DESeqDataSetFromMatrix(counts, s2c, design=design)
converting counts to integer mode
Error: $ operator is invalid for atomic vectors

Is there a way to provide my own model.matrix?

p.s. the modified model works in sleuth, but I would like to use DESeq2 for this particular analysis.

$\endgroup$

2 Answers 2

4
$\begingroup$

Provide rank sufficient design to DESeqDataSetFromMatrix and then use your custom model matrix in DESeq. In essence:

dds = DESeqDataSetFromMatric(counts, s2c, design=~batch)
design <- model.matrix(~strain+batch, s2c)
design = design[, -9]
DESeq(dds, full=design)

See this thread on the bioconductor site for details.

$\endgroup$
1
$\begingroup$

If your strain and batch are confounded, (like you did all of strain one on one day, and all of strain two on another), then there is no clever way to fix that. Just use one column, and inform whomever designed the experiment that you can't separate batch effect from strain difference.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.