<p>Since Spearman is a rank-based test, it relies on you being able to accurately decide on the ranking of your observations by some metric (usually the magnitude of the numbers). If two observations have identical values (are <em>tied</em>), then they cannot be definitively ranked. Since the ranks are not unique, exact p-values cannot be determined.</p>

<p>e.g. in your data, for gene 2:</p>

<pre><code>                  gene2 rank
TCGA-2Y-A9GS-01A    7.4    1
TCGA-2Y-A9GT-01A    1.0    5
TCGA-2Y-A9GU-01A    2.0   3= 
TCGA-2Y-A9GV-01A    0.5    6
TCGA-2Y-A9GW-01A    2.1    2
TCGA-2Y-A9GX-01A    2.0   3=
</code></pre>

<p>By way of example, it's possible to do the test with either <code>TCGA-2Y-A9GU-01A</code> or <code>TCGA-2Y-A9GX-01A</code> ranked number 3 - meaning a definitive p-value cannot be determined.</p>

<p>If there are only a few ties, you probably don't need to worry too much. If your FPKMs (or better, TPMs) were calculated with greater precision, then ties would be less likely. Is there a reason you only have these numbers to 1 decimal place?</p>

<p>Log or linear scale doesn't make a huge difference (and neither is 'wrong'). If you choose to plot log counts, you need to consider what happens if you have zeroes in your data. </p>

CC BY-SA 4.0
2018-10-01T21:04:00.653Z
The presence of a large number of zeros is often the main drawback with using spearmans on gene expression data I find.
Ian Sudbery
CC BY-SA 4.0
2018-10-01T16:20:10.720Z
2018-10-01T16:44:41.460Z
2018-10-01T16:44:41.460Z
sjcockell
<p>I have FPKM data for three genes like below:</p>

<pre><code>     Samples      gene1 gene2 gene3
TCGA-2Y-A9GS-01A   0.9   7.4  1.0
TCGA-2Y-A9GT-01A   0.8   1.0  0.3
TCGA-2Y-A9GU-01A   0.6   2.0  0.2
TCGA-2Y-A9GV-01A   1.2   0.5  0.1
TCGA-2Y-A9GW-01A   3.8   2.1  0.4
TCGA-2Y-A9GX-01A   2.3   2.0  1.5
</code></pre>

<p>I used <code>cor.test</code></p>

<pre><code>cor.test(~ gene1 + gene2, data = df2, method="spearman", continuity=FALSE, conf.level=0.95)

    Spearman's rank correlation rho

data:  gene1 and gene2
S = 5686100, p-value = 6.083e-09
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.2984045 
</code></pre>

<p>I have a warning message which I didn't see before.</p>

<pre><code>Warning message:
In cor.test.default(x = c(0.9, 0.8, 0.6, 1.2, 3.8, 2.3, 3.8, 0.4,  :
  Cannot compute exact p-value with ties
</code></pre>

<p>Do I need to care about this warning message? Is it good using FPKM data for correlation?</p>

<p>For plotting I used <code>ggscatter</code>.</p>

<pre><code>ggscatter(data, x = "gene1", y = "gene2", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "spearman",
          xlab = "gene1", ylab = "gene2")
</code></pre>

<p>Is this fine or I need to use any <code>log</code> for the scatter plot?</p>

<rna-seq><fpkm><correlation>
Spearman correlation between two genes
# Spearman correlation between two genes

(Asked by: username_0 on 2018-10-01)

I have FPKM data for three genes like below:
     Samples      gene1 gene2 gene3
TCGA-2Y-A9GS-01A   0.9   7.4  1.0
TCGA-2Y-A9GT-01A   0.8   1.0  0.3
TCGA-2Y-A9GU-01A   0.6   2.0  0.2
TCGA-2Y-A9GV-01A   1.2   0.5  0.1
TCGA-2Y-A9GW-01A   3.8   2.1  0.4
TCGA-2Y-A9GX-01A   2.3   2.0  1.5

I used cor.test
cor.test(~ gene1 + gene2, data = df2, method="spearman", continuity=FALSE, conf.level=0.95)

    Spearman's rank correlation rho

data:  gene1 and gene2
S = 5686100, p-value = 6.083e-09
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.2984045 

I have a warning message which I didn't see before.
Warning message:
In cor.test.default(x = c(0.9, 0.8, 0.6, 1.2, 3.8, 2.3, 3.8, 0.4,  :
  Cannot compute exact p-value with ties

Do I need to care about this warning message? Is it good using FPKM data for correlation?
For plotting I used ggscatter.
ggscatter(data, x = "gene1", y = "gene2", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "spearman",
          xlab = "gene1", ylab = "gene2")

Is this fine or I need to use any log for the scatter plot?

**Tags:** rna-seq, fpkm, correlation

---

## 1 answers

### Answer by username_1 on 2018-10-01. Score: 4 | Accepted answer

Since Spearman is a rank-based test, it relies on you being able to accurately decide on the ranking of your observations by some metric (usually the magnitude of the numbers). If two observations have identical values (are tied), then they cannot be definitively ranked. Since the ranks are not unique, exact p-values cannot be determined.
e.g. in your data, for gene 2:
                  gene2 rank
TCGA-2Y-A9GS-01A    7.4    1
TCGA-2Y-A9GT-01A    1.0    5
TCGA-2Y-A9GU-01A    2.0   3= 
TCGA-2Y-A9GV-01A    0.5    6
TCGA-2Y-A9GW-01A    2.1    2
TCGA-2Y-A9GX-01A    2.0   3=

By way of example, it's possible to do the test with either TCGA-2Y-A9GU-01A or TCGA-2Y-A9GX-01A ranked number 3 - meaning a definitive p-value cannot be determined.
If there are only a few ties, you probably don't need to worry too much. If your FPKMs (or better, TPMs) were calculated with greater precision, then ties would be less likely. Is there a reason you only have these numbers to 1 decimal place?
Log or linear scale doesn't make a huge difference (and neither is 'wrong'). If you choose to plot log counts, you need to consider what happens if you have zeroes in your data.

> **Comments:**
> **username_2**: The presence of a large number of zeros is often the main drawback with using spearmans on gene expression data I find.  

---

