Answers.Body: <p>This shouldn't be surprising that you see different correlations between gene expression data when expressed in different units.
  To see why, let's look at how these units are defined.</p>
  <p>Let's denote the absolute number of fragments we sequence from an RNA-seq measurement as <span class="math-container">$X_{gi}$</span> for gene <span class="math-container">$g$</span> in sample <span class="math-container">$i$</span>, and <span class="math-container">$l_g$</span> as the length of gene <span class="math-container">$g$</span> in kilobases.
  Then our different expression values will be:</p>
  <p><span class="math-container">$$
  f_{gi} = \frac{ X_{gi} \cdot 10^6 }{ l_g \cdot \sum_h X_{hi} } \text{ in FPKM}
  $$</span></p>
  <p>or</p>
  <p><span class="math-container">$$
  t_{gi} = \frac{ X_{gi} \cdot 10^6 }{ l_g \cdot \sum_h \frac{ X_{hi} }{ l_h } } \text{ in TPM}
  $$</span></p>
  <p>You convert from FPKM to TPM units like so:</p>
  <p><span class="math-container">$$
  t_{gi} = 10^6 \cdot \frac{ f_{gi} }{ \sum_h f_{hi} }
  $$</span></p>
  <p>As you can see, <em>within</em> any single sample, <span class="math-container">$i$</span>, this last denominator is fixed.
  But it is not fixed <em>across</em> samples (i.e. <span class="math-container">$\sum_h f_{hi} \ne \sum_h f_{hj}$</span> if <span class="math-container">$i \ne j$</span>).
  This means that the ordering for a single gene's expression across samples is not preserved when you switch between units (i.e. if <span class="math-container">$f_{gi} &gt; f_{gj}$</span>, it is <strong>not</strong> guaranteed that <span class="math-container">$t_{gi} &gt; t_{gj}$</span>).</p>
  <p>Because Spearman correlation is based on the order of each gene across samples in your dataset, and the order of genes in FPKM will be somewhat different from the order of genes in TPM, you will find different correlations between HIF1A and other genes when using the different units.</p>
  <p>Here's a simplified, concrete example.
  Imagine that your transcriptome is made of up 3 genes (A, B, and C) with lengths 1 kb, 2 kb, and 3 kb, respectively.
  And imagine you're doing RNA-seq in 4 samples.
  If your absolute count matrix is this</p>
  <p><span class="math-container">$$
  X = 10^6 \cdot \begin{bmatrix}
    1 &amp; 2 &amp; 9 &amp; 7 \\
    2 &amp; 2 &amp; 6 &amp; 5 \\
    3 &amp; 2 &amp; 2 &amp; 5
  \end{bmatrix}
  $$</span></p>
  <p>Then the expression matrix in FPKM is</p>
  <p><span class="math-container">$$
  F = \begin{bmatrix}
    166\,666.7 &amp; 333\,333.3 &amp; 529\,411.76 &amp; 411\,764 \\
    166\,666.7 &amp; 166\,666.7 &amp; 176\,470.59 &amp; 147\,058.82 \\
    166\,666.7 &amp; 111\,111.1 &amp; 39\,215.69 &amp; 98\,039.22
  \end{bmatrix}
  $$</span></p>
  <p>and in TPM its</p>
  <p><span class="math-container">$$
  T = \begin{bmatrix}
    333\,333.3 &amp; 545\,454.5 &amp; 710\,526.32 &amp; 626\,865.7 \\
    333\,333.3 &amp; 272\,727.3 &amp; 236\,842.11 &amp; 223\,880.6 \\
    333\,333.3 &amp; 181\,818.2 &amp; 52\,631.58 &amp; 149\,253.7
  \end{bmatrix}
  $$</span></p>
  <p>If you calculate the Spearman correlation for genes B and C against A, then you get these values.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Gene</th>
  <th>Correlation with A (FPKM)</th>
  <th>Correlation with A (TPM)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>B</td>
  <td>0.316</td>
  <td>-0.8</td>
  </tr>
  <tr>
  <td>C</td>
  <td>-1</td>
  <td>-1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>You can see that gene C is anti-correlated with A, but B actually switches signs and goes from moderately correlated in FPKM to strongly anti-correlated in TPM.</p>
  <p>So your observation that the same comparison on the different units gives pretty different results is expected.
  If you made a scatter plot with Spearman's <span class="math-container">$\rho$</span> from TPM along the x-axis and Spearman's <span class="math-container">$\rho$</span> from FPKM along the y-axis for all the genes that had a correlation p-value &lt; 0.05, you'll probably have a lot of genes that also flip signs like I showed with this toy example.</p>
  <p><a href="https://pubmed.ncbi.nlm.nih.gov/22872506/" rel="nofollow noreferrer">This paper by Wagner <em>et al.</em></a> is probably a good paper to review. It can give some context about RPKM and how to think about count-based sequencing data. Correlation-based analyses on data like this are typically used as a first-pass approach to get an idea about how things are behaving. But it's not very precise, as you've experienced. If you're doing exploratory work, I'd be inclined to pick TPM units, look at the results you have, then try to come up with a differential analysis question that can be handled in a more statistically robust way.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T15:04:55.417Z
Answers.Text: Got that! Thanks so much!
Answers.UserDisplayName: Yang Shi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-16T21:59:43.403Z
Answers.LastActivityDate: 2022-06-18T08:03:39.230Z
Answers.LastEditDate: 2022-06-18T08:03:39.230Z
Answers.UserDisplayName: James Hawley
Body: <p>TPM and FPKM of RNA-Seq data form GDC TCGA calculated based STAR were retrieved, respectively. The correlation between a specific gene, e.g. HIF1A, and other genes were calculated based on TPM and FPKM, respectively. And the significant genes were filtered based on P value &lt; 0.05. Here is the intersection of these two significant gene set shown in venn diagram. IMO, the two gene sets should not be obiviously different. Ang advice for this discrepance would be appreciated!
  <a href="https://i.sstatic.net/hPvRN.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hPvRN.jpg" alt="enter image description here" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-16T12:57:26.917Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Tags: <rna-seq><correlation><fpkm><tpm>
Title: Different results of spearman correlation between TPM and FPKM
ThreadText: # Different results of spearman correlation between TPM and FPKM
  
  (Asked by: username_0 on 2022-06-16)
  
  TPM and FPKM of RNA-Seq data form GDC TCGA calculated based STAR were retrieved, respectively. The correlation between a specific gene, e.g. HIF1A, and other genes were calculated based on TPM and FPKM, respectively. And the significant genes were filtered based on P value < 0.05. Here is the intersection of these two significant gene set shown in venn diagram. IMO, the two gene sets should not be obiviously different. Ang advice for this discrepance would be appreciated!
  [![enter image description here](https://i.sstatic.net/hPvRN.jpg)](https://i.sstatic.net/hPvRN.jpg)
  
  **Tags:** rna-seq, correlation, fpkm, tpm
  
  > **Comments:**
  > **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-06-16. Score: 2 | Accepted answer
  
  This shouldn't be surprising that you see different correlations between gene expression data when expressed in different units.
  To see why, let's look at how these units are defined.
  
  Let's denote the absolute number of fragments we sequence from an RNA-seq measurement as $X\_{gi}$ for gene $g$ in sample $i$, and $l\_g$ as the length of gene $g$ in kilobases.
  Then our different expression values will be:
  
  $$
  f\_{gi} = \frac{ X\_{gi} \cdot 10^6 }{ l\_g \cdot \sum\_h X\_{hi} } \text{ in FPKM}
  $$
  
  or
  
  $$
  t\_{gi} = \frac{ X\_{gi} \cdot 10^6 }{ l\_g \cdot \sum\_h \frac{ X\_{hi} }{ l\_h } } \text{ in TPM}
  $$
  
  You convert from FPKM to TPM units like so:
  
  $$
  t\_{gi} = 10^6 \cdot \frac{ f\_{gi} }{ \sum\_h f\_{hi} }
  $$
  
  As you can see, *within* any single sample, $i$, this last denominator is fixed.
  But it is not fixed *across* samples (i.e. $\sum\_h f\_{hi} \ne \sum\_h f\_{hj}$ if $i \ne j$).
  This means that the ordering for a single gene's expression across samples is not preserved when you switch between units (i.e. if $f\_{gi} > f\_{gj}$, it is **not** guaranteed that $t\_{gi} > t\_{gj}$).
  
  Because Spearman correlation is based on the order of each gene across samples in your dataset, and the order of genes in FPKM will be somewhat different from the order of genes in TPM, you will find different correlations between HIF1A and other genes when using the different units.
  
  Here's a simplified, concrete example.
  Imagine that your transcriptome is made of up 3 genes (A, B, and C) with lengths 1 kb, 2 kb, and 3 kb, respectively.
  And imagine you're doing RNA-seq in 4 samples.
  If your absolute count matrix is this
  
  $$
  X = 10^6 \cdot \begin{bmatrix}
  1 & 2 & 9 & 7 \\
  2 & 2 & 6 & 5 \\
  3 & 2 & 2 & 5
  \end{bmatrix}
  $$
  
  Then the expression matrix in FPKM is
  
  $$
  F = \begin{bmatrix}
  166\,666.7 & 333\,333.3 & 529\,411.76 & 411\,764 \\
  166\,666.7 & 166\,666.7 & 176\,470.59 & 147\,058.82 \\
  166\,666.7 & 111\,111.1 & 39\,215.69 & 98\,039.22
  \end{bmatrix}
  $$
  
  and in TPM its
  
  $$
  T = \begin{bmatrix}
  333\,333.3 & 545\,454.5 & 710\,526.32 & 626\,865.7 \\
  333\,333.3 & 272\,727.3 & 236\,842.11 & 223\,880.6 \\
  333\,333.3 & 181\,818.2 & 52\,631.58 & 149\,253.7
  \end{bmatrix}
  $$
  
  If you calculate the Spearman correlation for genes B and C against A, then you get these values.
  
  | Gene | Correlation with A (FPKM) | Correlation with A (TPM) |
  | --- | --- | --- |
  | B | 0.316 | -0.8 |
  | C | -1 | -1 |
  
  You can see that gene C is anti-correlated with A, but B actually switches signs and goes from moderately correlated in FPKM to strongly anti-correlated in TPM.
  
  So your observation that the same comparison on the different units gives pretty different results is expected.
  If you made a scatter plot with Spearman's $\rho$ from TPM along the x-axis and Spearman's $\rho$ from FPKM along the y-axis for all the genes that had a correlation p-value < 0.05, you'll probably have a lot of genes that also flip signs like I showed with this toy example.
  
  [This paper by Wagner *et al.*](https://pubmed.ncbi.nlm.nih.gov/22872506/) is probably a good paper to review. It can give some context about RPKM and how to think about count-based sequencing data. Correlation-based analyses on data like this are typically used as a first-pass approach to get an idea about how things are behaving. But it's not very precise, as you've experienced. If you're doing exploratory work, I'd be inclined to pick TPM units, look at the results you have, then try to come up with a differential analysis question that can be handled in a more statistically robust way.
  
  > **Comments:**
  > **username_0**: Got that! Thanks so much!  
  
  ---
  
  