Answers.Body: <p>I strongly suggest that you take your normalized counts, get the averages of different groups, and compare those ratios to the different designs.</p>
  <p>That said, you might not be able to replicate the fold changes from ~ genotype + time well in Excel.  What that design does is basically say &quot;Lots of the variance within each genotype/time point is due to the time point/genotype.  Model that so that those differences are taken into account.&quot;  Whereas a design of just ~ time, the software will go &quot;Oh, there's a lot of variance within each time point&quot;.  You won't be able to replicate that well in Excel...but that's why you are using DESeq.</p>
  <p>That design is probably better than just time or genotype alone, if you want to look at all the KO versus all the WT</p>
  <blockquote>
  <p>Does that mean results(obj3, name=&quot;genotype_KO_vs_WT&quot;) give
  differences in genotypes by comparing samples 4-6 vs 10-12 ?</p>
  </blockquote>
  <p>No.  The simplest way to do that comparison, and comparisons like it is to make a third data column that's genotype_time, and use contrasts to specify what subgroup to compare to what subgroup.</p>
  <blockquote>
  <p>Here I understand results(obj4, name=&quot;genotype_KO_vs_WT&quot;) gives the
  differences in genotypes at reference levels ie, samples 1-3 vs 7-9</p>
  </blockquote>
  <p>Yes.  But since that's super confusing, I'd recommend against it.  The way I outlined above is far more readable, and should work the same.</p>
  <p>The interaction design is best used when you want to see of the changes caused by time are different in the KO than the WT.  In theory, you could just generate the two timepoint fold changes, and subtract one from the other, but you'd have no p-value.  Using a design with interactions will get you that fold change difference with a p-value.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-13T21:46:03.380Z
Answers.Text: Thank you very much for the detailed reply. I want to make sure if I am understanding it correctly.  So in the (obj3, name="genotype_KO_vs_WT") from ~genotype+time model, time differences are included  as well, is that correct? Also, how is (obj3, name="timeT2vs_T1) in this model is different from just ~time model?
Answers.UserDisplayName: yathrakaaran
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-13T22:12:47.363Z
Answers.Text: In the same way.  Remember that the order of the elements in the design does not matter at all if you specify what you want in the results command.
Answers.UserDisplayName: swbarnes2
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-13T17:16:38.440Z
Answers.LastActivityDate: 2021-10-13T17:16:38.440Z
Answers.UserDisplayName: swbarnes2
Body: <p>I am using DEseq2 and trying to understand the results obtained using different models.</p>
  <p>I have a data design with 2 genotypes and 2 time points.</p>
  <pre><code>    sample genotype time
  1   WT_S1       WT   T1
  2   WT_S2       WT   T1
  3   WT_S3       WT   T1
  4   WT_S4       WT   T2
  5   WT_S5       WT   T2
  6   WT_S6       WT   T2
  7   KO_S1       KO   T1
  8   KO_S2       KO   T1
  9   KO_S3       KO   T1
  10  KO_S4       KO   T2
  11  KO_S5       KO   T2
  12  KO_S6       KO   T2
  </code></pre>
  <p><strong>I want to know the differences in results obtained from genotype coefficient and time coefficient when using different models.</strong></p>
  <p>Model1) ~ genotype</p>
  <p>Since it is comparing the differences in genotype regardless of time , samples 1-6 vs 7-12 are being compared.</p>
  <p>Model2) ~ time</p>
  <p>This model compares time T2 vs T1 regardless of genotypes. So it is comparing samples (1-3 + 7-9) vs (4-6 +10-12), <strong>is this correct?</strong></p>
  <p>Model3) ~ genotype + time</p>
  <p>My understanding is that this model assumes the genotype effect is the same at both time points and so it adds a time effect to both genotypes.</p>
  <p><strong>Does that mean results(obj3, name=&quot;genotype_KO_vs_WT&quot;) give differences in genotypes by comparing samples 4-6 vs 10-12 ?</strong></p>
  <p><strong>What samples are being compared in the results obtained from results(obj3, name=&quot;time_T2_vs_T1&quot;)? How is it different from model 2?</strong></p>
  <p>Model 4) ~ genotype + time + genotype:time</p>
  <p>Here I understand results(obj4, name=&quot;genotype_KO_vs_WT&quot;) gives the differences in genotypes at reference levels ie, samples 1-3 vs 7-9</p>
  <p><strong>results(obj4, name=&quot;time_T2_vs_T1&quot;). What samples are compared here? How is it different from ‘time_T2_vs_T1’ results in model 2 or model3?</strong></p>
  <p>The interaction term as I understand is giving the specific effect due to KO at time T2 controlling for the baseline differences in genotypes.
  results(obj5, name=&quot;genotypeKO.timeT2&quot;)</p>
  <p><strong>What samples are being compared from the model matrix?</strong></p>
  
Tags: <r><differential-expression><deseq2>
Title: Understanding the different designs in DESeq2
ThreadText: # Understanding the different designs in DESeq2
  
  (Asked by: username_0 on 2021-10-12)
  
  I am using DEseq2 and trying to understand the results obtained using different models.
  
  I have a data design with 2 genotypes and 2 time points.
  
  ```
      sample genotype time
  1   WT_S1       WT   T1
  2   WT_S2       WT   T1
  3   WT_S3       WT   T1
  4   WT_S4       WT   T2
  5   WT_S5       WT   T2
  6   WT_S6       WT   T2
  7   KO_S1       KO   T1
  8   KO_S2       KO   T1
  9   KO_S3       KO   T1
  10  KO_S4       KO   T2
  11  KO_S5       KO   T2
  12  KO_S6       KO   T2
  
  ```
  
  **I want to know the differences in results obtained from genotype coefficient and time coefficient when using different models.**
  
  Model1) ~ genotype
  
  Since it is comparing the differences in genotype regardless of time , samples 1-6 vs 7-12 are being compared.
  
  Model2) ~ time
  
  This model compares time T2 vs T1 regardless of genotypes. So it is comparing samples (1-3 + 7-9) vs (4-6 +10-12), **is this correct?**
  
  Model3) ~ genotype + time
  
  My understanding is that this model assumes the genotype effect is the same at both time points and so it adds a time effect to both genotypes.
  
  **Does that mean results(obj3, name="genotype\_KO\_vs\_WT") give differences in genotypes by comparing samples 4-6 vs 10-12 ?**
  
  **What samples are being compared in the results obtained from results(obj3, name="time\_T2\_vs\_T1")? How is it different from model 2?**
  
  Model 4) ~ genotype + time + genotype:time
  
  Here I understand results(obj4, name="genotype\_KO\_vs\_WT") gives the differences in genotypes at reference levels ie, samples 1-3 vs 7-9
  
  **results(obj4, name="time\_T2\_vs\_T1"). What samples are compared here? How is it different from ‘time\_T2\_vs\_T1’ results in model 2 or model3?**
  
  The interaction term as I understand is giving the specific effect due to KO at time T2 controlling for the baseline differences in genotypes.
  results(obj5, name="genotypeKO.timeT2")
  
  **What samples are being compared from the model matrix?**
  
  **Tags:** r, differential-expression, deseq2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-10-13. Score: 0 | Accepted answer
  
  I strongly suggest that you take your normalized counts, get the averages of different groups, and compare those ratios to the different designs.
  
  That said, you might not be able to replicate the fold changes from ~ genotype + time well in Excel. What that design does is basically say "Lots of the variance within each genotype/time point is due to the time point/genotype. Model that so that those differences are taken into account." Whereas a design of just ~ time, the software will go "Oh, there's a lot of variance within each time point". You won't be able to replicate that well in Excel...but that's why you are using DESeq.
  
  That design is probably better than just time or genotype alone, if you want to look at all the KO versus all the WT
  
  > Does that mean results(obj3, name="genotype\_KO\_vs\_WT") give
  > differences in genotypes by comparing samples 4-6 vs 10-12 ?
  
  No. The simplest way to do that comparison, and comparisons like it is to make a third data column that's genotype\_time, and use contrasts to specify what subgroup to compare to what subgroup.
  
  > Here I understand results(obj4, name="genotype\_KO\_vs\_WT") gives the
  > differences in genotypes at reference levels ie, samples 1-3 vs 7-9
  
  Yes. But since that's super confusing, I'd recommend against it. The way I outlined above is far more readable, and should work the same.
  
  The interaction design is best used when you want to see of the changes caused by time are different in the KO than the WT. In theory, you could just generate the two timepoint fold changes, and subtract one from the other, but you'd have no p-value. Using a design with interactions will get you that fold change difference with a p-value.
  
  > **Comments:**
  > **username_0**: Thank you very much for the detailed reply. I want to make sure if I am understanding it correctly.  So in the (obj3, name="genotype_KO_vs_WT") from ~genotype+time model, time differences are included  as well, is that correct? Also, how is (obj3, name="timeT2vs_T1) in this model is different from just ~time model?  
  > **username_1**: In the same way.  Remember that the order of the elements in the design does not matter at all if you specify what you want in the results command.  
  
  ---
  
  