Body: <p>I have two samples A and B and I do have an RNAseq for both of them. Inside each file (for A and B) I do have a set of FPKMs that give me a fold change for each gene (sample vs control). It looks somewhat like that:</p>
  <pre><code>gen_name grp01 grp02 grp03 grp04 fold_change
  gene1    10    10    5     5     2
  gene2    11    11    11    11    1
  gene3    5     5     10    10    0.5
  gene4    ... 
  </code></pre>
  <p>for sample A
  and, say</p>
  <pre><code>gen_name grp05 grp06 grp07 grp08 fold_change
  gene1    100   100   5     5     20
  gene2    110   110   110   110   1
  gene3    5     5     100   100   0.05
  gene4    ... 
  </code></pre>
  <p>for sample B</p>
  <p>I need to show with PCA that, foe example, gene1 is sample B is much more overexpressed than in sample A, same for gene3, but it looks like gene2 is not very interesting.</p>
  <p>What data must be put in PCA analysis?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-10T01:36:57.697Z
Comments.Text: Using a package is the best approach. Scanpy is popular right now. I do this stuff via first principles, so my advice isn't cool here. Anyway, I'd combine all data into one dataframe, minus log-fold change. I assume log fold change is the opposing sample? The data must have a column to identify A genes from B genes, or denoted within the gene name. PCA does not give gene by gene comparisons, it will be cluster by cluster. Interpreting each clusters is done independently (by mapping the log-fold-change), i.e. what is clustering together and that cluster represents a cohesive expression group.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-10T01:50:29.630Z
Comments.Text: The alternative is DEG analysis, gene by gene - which you've already done.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-10T03:43:54.700Z
Comments.Text: Thank you. I want to show that A is different from B based on an expression of gene1 and gene3 (in this test experiment). I want to do this in R but scanpy is a python package. Is there any way to use ```prcomp()``` ?
Comments.UserDisplayName: Lara
Tags: <r><differential-expression><pca>
Title: What is the best approach to do a PCA analysis to distinguish between two groups?
ThreadText: # What is the best approach to do a PCA analysis to distinguish between two groups?
  
  (Asked by: username_0 on 2023-03-10)
  
  I have two samples A and B and I do have an RNAseq for both of them. Inside each file (for A and B) I do have a set of FPKMs that give me a fold change for each gene (sample vs control). It looks somewhat like that:
  
  ```
  gen_name grp01 grp02 grp03 grp04 fold_change
  gene1    10    10    5     5     2
  gene2    11    11    11    11    1
  gene3    5     5     10    10    0.5
  gene4    ... 
  
  ```
  
  for sample A
  and, say
  
  ```
  gen_name grp05 grp06 grp07 grp08 fold_change
  gene1    100   100   5     5     20
  gene2    110   110   110   110   1
  gene3    5     5     100   100   0.05
  gene4    ... 
  
  ```
  
  for sample B
  
  I need to show with PCA that, foe example, gene1 is sample B is much more overexpressed than in sample A, same for gene3, but it looks like gene2 is not very interesting.
  
  What data must be put in PCA analysis?
  
  **Tags:** r, differential-expression, pca
  
  > **Comments:**
  > **username_1**: Using a package is the best approach. Scanpy is popular right now. I do this stuff via first principles, so my advice isn't cool here. Anyway, I'd combine all data into one dataframe, minus log-fold change. I assume log fold change is the opposing sample? The data must have a column to identify A genes from B genes, or denoted within the gene name. PCA does not give gene by gene comparisons, it will be cluster by cluster. Interpreting each clusters is done independently (by mapping the log-fold-change), i.e. what is clustering together and that cluster represents a cohesive expression group.  
  > **username_1**: The alternative is DEG analysis, gene by gene - which you've already done.  
  > **username_0**: Thank you. I want to show that A is different from B based on an expression of gene1 and gene3 (in this test experiment). I want to do this in R but scanpy is a python package. Is there any way to use ```prcomp()``` ?  
  
  ---
  
  ## 0 answers
  
  