Answers.Body: <p>In the DESeq2 <a href="http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#how-can-i-include-a-continuous-covariate-in-the-design-formula" rel="nofollow noreferrer">manual</a> there is a section titled "How can I include a continuous covariate in the design formula?" that deals with your question.<br>
  Basically the process is no different from using a discrete covariate.</p>
  
  <pre><code>DESeq &lt;- DESeqDataSetFromMatrix(countData = counts, colData = metadata, design = ~ RIN + condition)
  </code></pre>
  
  <p>In this example condition is the experimental groups and RIN is the continuous covariate for the RNA-integrity.  </p>
  
  <p>For this to work properly there has to be a linear relationship between the RNA integrity and the gene expression values. As stated in the manual: "Continuous covariates might make sense in certain experiments, where a constant fold change might be expected for each unit of the covariate."<br>
  Therefore, it may be better to code the RIN variable as a factor like <code>RIN_high</code> or <code>RIN_low</code>. This is more robust than using the absolute values of the variable itself.</p>
  
  <p>However, from your desription I get the impession that the RIN values are generally lower in the treatment group compared to the control group. If this is the case, using RIN as a covariate will by of limited use. DESeq2 will not be able to discriminate if a expression difference is due to a difference in RNA integrity or due to your treatment. Also, in this case coding RIN into high and low would result in an error because the RIN and treatment variable would define the same groups.  </p>
  
  <p>Generally, covariates work best when they are evenly distributed across the experimental groups.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-21T08:56:28.717Z
Answers.Text: Thank you so much for your explanation. It makes a lot of sense. I think the dataset I have to work with is going to be very difficult to safe (or at least it will need a lot of biological validation lol). I was trying to use the theory behind this paper: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4071332/                                                                              But they use a controlled RNA damage (with a time course) to model how it affects. I only can include rin as a covariate. I think I will go with your advice and do ~rin+condition and that's it...
Answers.UserDisplayName: FrAoJm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-20T12:09:48.090Z
Answers.LastActivityDate: 2020-05-20T12:09:48.090Z
Answers.UserDisplayName: PPK
Body: <p>I have been following the last DESeq2 pipeline to perform an RNAseq analysis with a dataset with low rin samples in the experimental (or treated) and high rin on the control ones. </p>
  
  <p>I read <a href="https://ncbi.nlm.nih.gov/pmc/articles/PMC4071332" rel="nofollow noreferrer">a paper</a> in which they perform RNAseq analysis with time-course RNA degradation and conclude that including RIN value as a covariate can mitigate some of the effects of low RIN in samples.</p>
  
  <p>My question is how I should construct the design in the DESeq2 object:</p>
  
  <pre><code>~conditions+rin
  ~conditions*rin
  ~conditions:rin
  </code></pre>
  
  <p>none of them... :)</p>
  
  <p>I cannot find proper resources where explain how to construct these models (I am new to the field...) and I recognise I crashed against a wall with these kinds of things. <strong>I would appreciate also some links to good resources to be able to understand which one is correct and why</strong>.</p>
  
  <p>Thank you in advance! </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-20T19:52:10.013Z
Comments.Text: Hi please edit your question to summarise the problem more clearly and include a summary of the paper in question.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-21T09:05:52.740Z
Comments.Text: hope now is more clear... :)
Comments.UserDisplayName: FrAoJm
Tags: <rna-seq><deseq2><edger><design>
Title: How to incorportate RIN values as covariate in the design matrix?
ThreadText: # How to incorportate RIN values as covariate in the design matrix?
  
  (Asked by: username_0 on 2020-05-20)
  
  I have been following the last DESeq2 pipeline to perform an RNAseq analysis with a dataset with low rin samples in the experimental (or treated) and high rin on the control ones.
  
  I read [a paper](https://ncbi.nlm.nih.gov/pmc/articles/PMC4071332) in which they perform RNAseq analysis with time-course RNA degradation and conclude that including RIN value as a covariate can mitigate some of the effects of low RIN in samples.
  
  My question is how I should construct the design in the DESeq2 object:
  
  ```
  ~conditions+rin
  ~conditions*rin
  ~conditions:rin
  
  ```
  
  none of them... :)
  
  I cannot find proper resources where explain how to construct these models (I am new to the field...) and I recognise I crashed against a wall with these kinds of things. **I would appreciate also some links to good resources to be able to understand which one is correct and why**.
  
  Thank you in advance!
  
  **Tags:** rna-seq, deseq2, edger, design
  
  > **Comments:**
  > **username_1**: Hi please edit your question to summarise the problem more clearly and include a summary of the paper in question.  
  > **username_0**: hope now is more clear... :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-05-20. Score: 4 | Accepted answer
  
  In the DESeq2 [manual](http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#how-can-i-include-a-continuous-covariate-in-the-design-formula) there is a section titled "How can I include a continuous covariate in the design formula?" that deals with your question.  
  Basically the process is no different from using a discrete covariate.
  
  ```
  DESeq <- DESeqDataSetFromMatrix(countData = counts, colData = metadata, design = ~ RIN + condition)
  
  ```
  
  In this example condition is the experimental groups and RIN is the continuous covariate for the RNA-integrity.
  
  For this to work properly there has to be a linear relationship between the RNA integrity and the gene expression values. As stated in the manual: "Continuous covariates might make sense in certain experiments, where a constant fold change might be expected for each unit of the covariate."  
  Therefore, it may be better to code the RIN variable as a factor like `RIN_high` or `RIN_low`. This is more robust than using the absolute values of the variable itself.
  
  However, from your desription I get the impession that the RIN values are generally lower in the treatment group compared to the control group. If this is the case, using RIN as a covariate will by of limited use. DESeq2 will not be able to discriminate if a expression difference is due to a difference in RNA integrity or due to your treatment. Also, in this case coding RIN into high and low would result in an error because the RIN and treatment variable would define the same groups.
  
  Generally, covariates work best when they are evenly distributed across the experimental groups.
  
  > **Comments:**
  > **username_0**: Thank you so much for your explanation. It makes a lot of sense. I think the dataset I have to work with is going to be very difficult to safe (or at least it will need a lot of biological validation lol). I was trying to use the theory behind this paper: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4071332/                                                                              But they use a controlled RNA damage (with a time course) to model how it affects. I only can include rin as a covariate. I think I will go with your advice and do ~rin+condition and that's it...  
  
  ---
  
  