Answers.Body: <p>You can't figure out how to adapt this to your data?</p>
  <p><a href="http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts" rel="nofollow noreferrer">http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts</a></p>
  <p>Ignore resultsNames.  You don't need them for simple comparisons like you want to do.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-08T17:26:01.543Z
Answers.Text: Sorry even by ignoring resultsNames, I don't know what to put into this formula. For instance what I should put instead of time_4_vs_0 ?   This gave me error  > results(dds, contrast=list(c("time_48_vs_24", "conditionIT.time24")), test="Wald")
  Error in checkContrast(contrast, resNames) : 
    all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'
  >
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-08T17:54:48.660Z
Answers.Text: Where have you looked?  Did you read the link I posted?  Did you look at the entry for deseq2 results?  https://rdrr.io/bioc/DESeq2/man/results.html   Can you not find a single tutorial anywhere which shows you how to use specify the contrast?
Answers.UserDisplayName: swbarnes2
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-08T17:09:24.410Z
Answers.LastActivityDate: 2021-10-08T17:09:24.410Z
Answers.UserDisplayName: swbarnes2
Answers.Body: <p>you can do:</p>
  <pre><code>data<span class="math-container">$condition_new &lt;- as.factor(paste0(data$</span>condition, &quot; - &quot;, data$time))
  dds &lt;- DESeqDataSetFromMatrix(countData=count, 
                               colData=design, 
                               design=~condition_new
                               , tidy = FALSE)
  enter code here
  results(dds, contrast=c(&quot;condition_new&quot;, &quot;control - 24&quot;, &quot;condition - 4&quot;))
  </code></pre>
  <p>I hope it helps.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-26T15:31:12.243Z
Answers.Text: You can find here: http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts
   the tip as pointed from @swbarnes2
Answers.UserDisplayName: flavinsky
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-26T15:29:31.317Z
Answers.LastActivityDate: 2021-11-26T15:29:31.317Z
Answers.UserDisplayName: flavinsky
Body: <p>I need help with some clarifications please</p>
  <p>I have control versus treatment in two time points like</p>
  <pre><code>&gt; y
                               X condition time
  1       CTRL_24_hrs_replicate1   control   24
  2       CTRL_24_hrs_replicate2   control   24
  3       CTRL_24_hrs_replicate3   control   24
  4  treatment_24_hrs_replicate1        t   24
  5  treatment_24_hrs_replicate2        t   24
  6  treatment_24_hrs_replicate3        t   24
  7       CTRL_48_hrs_replicate1   control   48
  8       CTRL_48_hrs_replicate2   control   48
  9       CTRL_48_hrs_replicate3   control   48
  10 treatment_48_hrs_replicate1        t   48
  11 treatment_48_hrs_replicate2        t   48
  12 treatment_48_hrs_replicate3        t   48
  &gt; 
  </code></pre>
  <p>I want to see the difference of treatment versus control from 24 hours to 48 hours, so this is not just the difference of treatment versus control or difference between 24 versus 48 hours rather the treatment versus control from 24 hours to 48 hours</p>
  <p>This is what I have done so far</p>
  <pre><code>&gt;  dds &lt;- DESeqDataSetFromMatrix(countData=count, 
  +                                 colData=design, 
  +                                 design=~condition, tidy = FALSE)
  Warning message:
  In DESeqDataSet(se, design = design, ignoreRank) :
    some variables in design formula are characters, converting to factors
  &gt;   dds<span class="math-container">$group &lt;- factor(paste0(dds$</span>time, dds$condition))
  &gt;   design(dds) &lt;- ~ group
  &gt;   dds &lt;- DESeq(dds)
  estimating size factors
  estimating dispersions
  gene-wise dispersion estimates
  mean-dispersion relationship
  final dispersion estimates
  fitting model and testing
  &gt;   resultsNames(dds)
  &quot;Intercept&quot;                    &quot;group_24IT_vs_24control&quot;         &quot;group_48control_vs_24control&quot; &quot;group_48IT_vs_24control&quot;     
  &gt; 
  </code></pre>
  <p>How to find the difference at time point 24 vs 48 in condition ?</p>
  <p>I searched and I found a similar thing but I don't know how to adopt that to my data</p>
  <pre><code>results(dds, contrast=list(c(&quot;time_4_vs_0&quot;, &quot;conditionLD.time4&quot;)), test=&quot;Wald&quot;)
  </code></pre>
  <p>I tried this and I got error</p>
  <pre><code>&gt; results(dds, contrast=list(c(&quot;time_48_vs_24&quot;, &quot;conditionIT.time24&quot;)), test=&quot;Wald&quot;)
  Error in checkContrast(contrast, resNames) : 
    all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'
  &gt; 
  </code></pre>
  <p>Can you help me in adopting this to my data please?</p>
  
Tags: <deseq2>
Title: DEseq2 contrast in two time points
ThreadText: # DEseq2 contrast in two time points
  
  (Asked by: username_0 on 2021-10-08)
  
  I need help with some clarifications please
  
  I have control versus treatment in two time points like
  
  ```
  > y
                               X condition time
  1       CTRL_24_hrs_replicate1   control   24
  2       CTRL_24_hrs_replicate2   control   24
  3       CTRL_24_hrs_replicate3   control   24
  4  treatment_24_hrs_replicate1        t   24
  5  treatment_24_hrs_replicate2        t   24
  6  treatment_24_hrs_replicate3        t   24
  7       CTRL_48_hrs_replicate1   control   48
  8       CTRL_48_hrs_replicate2   control   48
  9       CTRL_48_hrs_replicate3   control   48
  10 treatment_48_hrs_replicate1        t   48
  11 treatment_48_hrs_replicate2        t   48
  12 treatment_48_hrs_replicate3        t   48
  > 
  
  ```
  
  I want to see the difference of treatment versus control from 24 hours to 48 hours, so this is not just the difference of treatment versus control or difference between 24 versus 48 hours rather the treatment versus control from 24 hours to 48 hours
  
  This is what I have done so far
  
  ```
  >  dds <- DESeqDataSetFromMatrix(countData=count, 
  +                                 colData=design, 
  +                                 design=~condition, tidy = FALSE)
  Warning message:
  In DESeqDataSet(se, design = design, ignoreRank) :
    some variables in design formula are characters, converting to factors
  >   dds$group <- factor(paste0(dds$time, dds$condition))
  >   design(dds) <- ~ group
  >   dds <- DESeq(dds)
  estimating size factors
  estimating dispersions
  gene-wise dispersion estimates
  mean-dispersion relationship
  final dispersion estimates
  fitting model and testing
  >   resultsNames(dds)
  "Intercept"                    "group_24IT_vs_24control"         "group_48control_vs_24control" "group_48IT_vs_24control"     
  > 
  
  ```
  
  How to find the difference at time point 24 vs 48 in condition ?
  
  I searched and I found a similar thing but I don't know how to adopt that to my data
  
  ```
  results(dds, contrast=list(c("time_4_vs_0", "conditionLD.time4")), test="Wald")
  
  ```
  
  I tried this and I got error
  
  ```
  > results(dds, contrast=list(c("time_48_vs_24", "conditionIT.time24")), test="Wald")
  Error in checkContrast(contrast, resNames) : 
    all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'
  > 
  
  ```
  
  Can you help me in adopting this to my data please?
  
  **Tags:** deseq2
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-10-08. Score: 1
  
  You can't figure out how to adapt this to your data?
  
  <http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts>
  
  Ignore resultsNames. You don't need them for simple comparisons like you want to do.
  
  > **Comments:**
  > **username_0**: Sorry even by ignoring resultsNames, I don't know what to put into this formula. For instance what I should put instead of time_4_vs_0 ?   This gave me error  > results(dds, contrast=list(c("time_48_vs_24", "conditionIT.time24")), test="Wald") Error in checkContrast(contrast, resNames) :    all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)' >  
  > **username_1**: Where have you looked?  Did you read the link I posted?  Did you look at the entry for deseq2 results?  https://rdrr.io/bioc/DESeq2/man/results.html   Can you not find a single tutorial anywhere which shows you how to use specify the contrast?  
  
  ---
  
  ### Answer by username_2 on 2021-11-26. Score: 1
  
  you can do:
  
  ```
  data$condition_new <- as.factor(paste0(data$condition, " - ", data$time))
  dds <- DESeqDataSetFromMatrix(countData=count, 
                               colData=design, 
                               design=~condition_new
                               , tidy = FALSE)
  enter code here
  results(dds, contrast=c("condition_new", "control - 24", "condition - 4"))
  
  ```
  
  I hope it helps.
  
  > **Comments:**
  > **username_2**: You can find here: http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts  the tip as pointed from @username_1  
  
  ---
  
  