Answers.Body: <p>Any IDs (e.g. replicate number) don't need to be included in the design formula if it's not a repeated factor in multiple samples.</p>
  
  <p>In this case, you have said that mouse number is related to the number of mice used in the pool (and is a variable factor that is consistent across multiple samples), in which case it should be included in the design matrix. This would also be the case if the <em>same</em> mouse were being used for multiple RNASeq experiments. Converting an integer value to a factor is done by the <code>factor</code> method:</p>
  
  <pre><code>sampleTable$MiceUsed &lt;- factor(sampleTable$MiceUsed);
  </code></pre>
  
  <p>Other examples of things that might be useful in the design formula would be sex, age, and sequencing run batch (assuming these are not consistent across samples).</p>
  
  <p>With a design formula of something like <code>~Groups + Mouse</code>, it will also be comparing Groups, it's just hidden in the results. The <a href="https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#interactions" rel="nofollow noreferrer">DESeq2 vignette</a> is really great at explaining what's going on, but as a quick answer you can pull out the <code>Groups</code> results with the <code>contrast</code> function. This will pull out group differences that are independent of mouse number:</p>
  
  <pre><code>results(dds, contrast=c("Groups", "GF", "Wld"))
  </code></pre>
  
  <p>[first value is the variable name, second value is the numerator condition, third is the denominator condition]</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-12T00:24:24.813Z
Answers.LastActivityDate: 2018-04-12T22:35:44.753Z
Answers.LastEditDate: 2018-04-12T22:35:44.753Z
Answers.UserDisplayName: gringer
Body: <p>I am creating <code>DeSeqDataSet</code> and I am unsure whether I need to include the number of mice into the design formula. Basically, the samples look like this:</p>
  <p><a href="https://i.sstatic.net/ayyrm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ayyrm.png" alt="enter image description here" /></a></p>
  <p>I have 4 different groups: <code>GF</code>, <code>B6</code>, <code>ET</code> and <code>Wld</code>. It is obvious that these should go into the design formula, but I am not sure about the mice number. Basically for each group, e.g. <code>GF</code>, there are 4 experiments with <code>1</code>, <code>2</code>, <code>3</code> and <code>4</code> mice each. When I am trying to use both <code>Groups</code> and <code>Mouse</code> columns as a design formula, <code>R</code> is telling that I need to convert <code>Mouse</code> to <code>factor</code>:</p>
  <p><a href="https://i.sstatic.net/3qc1w.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3qc1w.png" alt="enter image description here" /></a></p>
  <p>I am a bit confused about two things here: first, as I told already, should I include this <code>Mouse</code> column at all in the design formula of <code>DeSeqDataSet</code> and second, if I do need it, how to convert it to factor? Any suggestions would be greatly appreciated.</p>
  <p><strong>Update</strong></p>
  <p>It turned out that I was wrong in my initial assumptions: <code>Mouse#</code> really was an ‘id’ which I did not include in the design formula. There were 4 groups of 16 mice in each for 4 trials.</p>
  <p>What concerns me also is that if I specify design formula as <code>~ Groups + Mouse</code>, the DeSeq() function starts comparing the <code>Mouse</code> but not the <code>Groups</code> which is the most interesting for me.</p>
  
Tags: <rna-seq><deseq2>
Title: DeSeqDataSet experimental design: column with integer values
ThreadText: # DeSeqDataSet experimental design: column with integer values
  
  (Asked by: username_0 on 2018-04-11)
  
  I am creating `DeSeqDataSet` and I am unsure whether I need to include the number of mice into the design formula. Basically, the samples look like this:
  
  [![enter image description here](https://i.sstatic.net/ayyrm.png)](https://i.sstatic.net/ayyrm.png)
  
  I have 4 different groups: `GF`, `B6`, `ET` and `Wld`. It is obvious that these should go into the design formula, but I am not sure about the mice number. Basically for each group, e.g. `GF`, there are 4 experiments with `1`, `2`, `3` and `4` mice each. When I am trying to use both `Groups` and `Mouse` columns as a design formula, `R` is telling that I need to convert `Mouse` to `factor`:
  
  [![enter image description here](https://i.sstatic.net/3qc1w.png)](https://i.sstatic.net/3qc1w.png)
  
  I am a bit confused about two things here: first, as I told already, should I include this `Mouse` column at all in the design formula of `DeSeqDataSet` and second, if I do need it, how to convert it to factor? Any suggestions would be greatly appreciated.
  
  **Update**
  
  It turned out that I was wrong in my initial assumptions: `Mouse#` really was an ‘id’ which I did not include in the design formula. There were 4 groups of 16 mice in each for 4 trials.
  
  What concerns me also is that if I specify design formula as `~ Groups + Mouse`, the DeSeq() function starts comparing the `Mouse` but not the `Groups` which is the most interesting for me.
  
  **Tags:** rna-seq, deseq2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-04-12. Score: 5 | Accepted answer
  
  Any IDs (e.g. replicate number) don't need to be included in the design formula if it's not a repeated factor in multiple samples.
  
  In this case, you have said that mouse number is related to the number of mice used in the pool (and is a variable factor that is consistent across multiple samples), in which case it should be included in the design matrix. This would also be the case if the *same* mouse were being used for multiple RNASeq experiments. Converting an integer value to a factor is done by the `factor` method:
  
  ```
  sampleTable$MiceUsed <- factor(sampleTable$MiceUsed);
  
  ```
  
  Other examples of things that might be useful in the design formula would be sex, age, and sequencing run batch (assuming these are not consistent across samples).
  
  With a design formula of something like `~Groups + Mouse`, it will also be comparing Groups, it's just hidden in the results. The [DESeq2 vignette](https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#interactions) is really great at explaining what's going on, but as a quick answer you can pull out the `Groups` results with the `contrast` function. This will pull out group differences that are independent of mouse number:
  
  ```
  results(dds, contrast=c("Groups", "GF", "Wld"))
  
  ```
  
  [first value is the variable name, second value is the numerator condition, third is the denominator condition]
  
  
  ---
  
  