Answers.Body: <p>If you don't tell DESeq what contrast to make, it just does the default contrast.  Which is your reference versus the last other one alphabetically.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T17:17:59.530Z
Answers.Text: Oh understood, Thanks! I thought I was doing that with the factor command, can you please let me know ow should I do that, is there a tutorial you recommend for it?
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T17:44:55.203Z
Answers.Text: You need `results(dds, contrast = c("species", "human", "canine"))` if you're looking to compare human vs canine. Three params, first is the variable (column) name, 2 and 3 are the conditions you're comparing. See: https://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#note-on-factor-levels
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T17:49:07.873Z
Answers.Text: Thank you Ram RS.
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T19:02:23.240Z
Answers.Text: I just noticed that in contrast there are juts humans and canines still, I want the three species to be there, human, canine, and mouse. Since I have three different species and want to compare the expression among them. I added the mouse to the contrast but I got an error "contrast', as a character vector of length 3, should have the form: contrast = c('factorName','numeratorLevel','denominatorLevel'),
  see the manual page of ?results for more information" is it even possible to do this for more than two categories?
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T21:06:24.473Z
Answers.Text: You can only compare two conditions. You can of course run the `results` multiple times with different pairs of conditions but you cannot compare 3 groups using a 2-group statistical test.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-21T18:58:34.330Z
Answers.Text: Thanks, Ram RS!
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-21T22:00:25.053Z
Answers.Text: Wouldn't it be better to run the DESeqDataSetFromMatrix on a matrix that has only samples of two conditions then? instead of giving all the categories in the same input matrix? I mean I can give the count table of mouse and human, human and canine, and canine and mouse separately if it's not considering them all, would that make a change? Thanks for helping!
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-22T15:39:08.307Z
Answers.Text: In general, it is better not to subset the data.  Keep it all together, use contrasts to specify what to compare to what.
Answers.UserDisplayName: swbarnes2
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-23T13:11:09.580Z
Answers.Text: Thanks for your answer! Just out of curiosity do you know the main reason behind it?
Answers.UserDisplayName: ToTheMoon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-23T18:21:43.147Z
Answers.Text: Better dispersion estimates. Part of the issue was the RNA-Seq is that people generally don't have the money to do all the replicates that are really required for robust results.  Part of what DESeq does is to squeeze as much statistical information out as possible of the data you do have.  Removing real sample data hurts that effort, usually.
Answers.UserDisplayName: swbarnes2
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T16:04:56.950Z
Answers.LastActivityDate: 2024-02-20T16:04:56.950Z
Answers.UserDisplayName: swbarnes2
Body: <p>I want to see how the gene expression differs in breast cancer between three species, and I am using <code>DESeqDataSetFromMatrix</code> on my count table.</p>
  <pre class="lang-r prettyprint-override"><code>dds &lt;- DESeqDataSetFromMatrix(countData = whole_data, colData = whole_col_data, design = ~ species)
  dds$species &lt;- factor(dds$species, levels=c(&quot;human&quot;,&quot;canine&quot;,&quot;mouse&quot;))
  dds$species &lt;- relevel(dds$species, ref = &quot;human&quot;) 
  dds &lt;- DESeq(dds)
  </code></pre>
  <p>Although I specified my levels for all three species my results are still as follows and only compare between two species:</p>
  <pre class="lang-r prettyprint-override"><code>log2 fold change (MLE): species **mouse vs human** 
  Wald test p-value: species **mouse vs human** 
  DataFrame with 13556 rows and 6 columns
          baseMean log2FoldChange     lfcSE      stat      pvalue       
  </code></pre>
  <p>Can someone please explain to me why that is happening?</p>
  
Tags: <sequence-analysis><deseq2><gene-expression><go-enrichment>
Title: Multi Factor in Deseq2 Gene enrichment analysis
ThreadText: # Multi Factor in Deseq2 Gene enrichment analysis
  
  (Asked by: username_0 on 2024-02-20)
  
  I want to see how the gene expression differs in breast cancer between three species, and I am using `DESeqDataSetFromMatrix` on my count table.
  
  ```r
  dds <- DESeqDataSetFromMatrix(countData = whole_data, colData = whole_col_data, design = ~ species)
  dds$species <- factor(dds$species, levels=c("human","canine","mouse"))
  dds$species <- relevel(dds$species, ref = "human") 
  dds <- DESeq(dds)
  
  ```
  
  Although I specified my levels for all three species my results are still as follows and only compare between two species:
  
  ```r
  log2 fold change (MLE): species **mouse vs human** 
  Wald test p-value: species **mouse vs human** 
  DataFrame with 13556 rows and 6 columns
          baseMean log2FoldChange     lfcSE      stat      pvalue       
  
  ```
  
  Can someone please explain to me why that is happening?
  
  **Tags:** sequence-analysis, deseq2, gene-expression, go-enrichment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-20. Score: 3 | Accepted answer
  
  If you don't tell DESeq what contrast to make, it just does the default contrast. Which is your reference versus the last other one alphabetically.
  
  > **Comments:**
  > **username_0**: Oh understood, Thanks! I thought I was doing that with the factor command, can you please let me know ow should I do that, is there a tutorial you recommend for it?  
  > **username_2**: You need `results(dds, contrast = c("species", "human", "canine"))` if you're looking to compare human vs canine. Three params, first is the variable (column) name, 2 and 3 are the conditions you're comparing. See: https://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#note-on-factor-levels  
  > **username_0**: Thank you username_2.  
  > **username_0**: I just noticed that in contrast there are juts humans and canines still, I want the three species to be there, human, canine, and mouse. Since I have three different species and want to compare the expression among them. I added the mouse to the contrast but I got an error "contrast', as a character vector of length 3, should have the form: contrast = c('factorName','numeratorLevel','denominatorLevel'), see the manual page of ?results for more information" is it even possible to do this for more than two categories?  
  > **username_2**: You can only compare two conditions. You can of course run the `results` multiple times with different pairs of conditions but you cannot compare 3 groups using a 2-group statistical test.  
  > **username_0**: Thanks, username_2!  
  > **username_0**: Wouldn't it be better to run the DESeqDataSetFromMatrix on a matrix that has only samples of two conditions then? instead of giving all the categories in the same input matrix? I mean I can give the count table of mouse and human, human and canine, and canine and mouse separately if it's not considering them all, would that make a change? Thanks for helping!  
  > **username_1**: In general, it is better not to subset the data.  Keep it all together, use contrasts to specify what to compare to what.  
  > **username_0**: Thanks for your answer! Just out of curiosity do you know the main reason behind it?  
  > **username_1**: Better dispersion estimates. Part of the issue was the RNA-Seq is that people generally don't have the money to do all the replicates that are really required for robust results.  Part of what DESeq does is to squeeze as much statistical information out as possible of the data you do have.  Removing real sample data hurts that effort, usually.  
  
  ---
  
  