text: user123: 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.
  
  user2388: 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.
  
  user77: 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.
  
original_text: 123: <p>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 <code>DESeqDataSet</code> (dds) using the <code>DESeqDataSetFromMatrix</code> function.</p>
  
  <pre><code>&gt; dds &lt;- DESeqDataSetFromMatrix(counts,
                                  samples,
                                  ~ strain + batch)
  </code></pre>
  
  <p>And I get the following error, expected given my experimental design:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>&gt; design &lt;- model.matrix(~strain+batch, s2c)
  &gt; design = design[, -9] # removing a column to avoid full-rank
  &gt; dds &lt;- DESeqDataSetFromMatrix(counts, s2c, design=design)
  converting counts to integer mode
  Error: $ operator is invalid for atomic vectors
  </code></pre>
  
  <p>Is there a way to provide my own <code>model.matrix</code>?</p>
  
  <p>p.s. the modified model works in sleuth, but I would like to use DESeq2 for this particular analysis.</p>
   2388: <p>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.</p>
   77: <p>Provide rank sufficient design to <code>DESeqDataSetFromMatrix</code> and then use your custom model matrix in <code>DESeq</code>. In essence:</p>
  
  <pre><code>dds = DESeqDataSetFromMatric(counts, s2c, design=~batch)
  design &lt;- model.matrix(~strain+batch, s2c)
  design = design[, -9]
  DESeq(dds, full=design)
  </code></pre>
  
  <p>See <a href="https://support.bioconductor.org/p/64480/" rel="nofollow noreferrer">this thread</a> on the bioconductor site for details.</p>
  