<p>The mean of log-transformed values is the log-transformed geometric mean of the untransformed values (i.e., $log_{2}(geometric~mean)$). This can be useful when the values you want to summarize have vastly different ranges (so one doesn't dominate the average). I would expect that to generally <strong>NOT</strong> be the case for CPMs of the same gene, so it's unclear to me what the point of that would be. It can also be difficult to interpret these results due to the geometric mean being dependent upon the variance:</p>

<pre class="lang-r prettyprint-override"><code>&gt; originalValues = rnorm(1000, mean=10, sd=c(rep(1, 500), rep(2, 500)))
&gt; mean(originalValues[1:500])
[1] 9.991464
&gt; mean(originalValues[501:1000])
[1] 10.04407
&gt; log2(mean(originalValues[1:500]))
[1] 3.320696
&gt; log2(mean(originalValues[501:1000]))
[1] 3.328272
&gt; mean(log2(originalValues[1:500]))
[1] 3.313263
&gt; mean(log2(originalValues[501:1000]))
[1] 3.300103
</code></pre>

<p>Above I created two groups of 500 values each. Each group has approximately the same mean (10) but with different variance (1 vs 2). As you can see, the second group of 500 values randomly has a slightly higher average. The log2(mean) preserves this difference, but the log2(geometric mean) inverts the relationship such that group 2 now appears to have a lower mean value. This isn't really wrong, it's the difference between mean and geometric mean, but it's something that needs to be kept in mind.</p>

<p>This has implications if your want to compare values between genes, since your comparison metric is then not just dependent upon the mean, but also the variability of the data (such that more variable genes will have systematically lower geometric means).</p>

<p>In short, the geometric mean is useful when values are on different scales (such as CPM values of all genes in a sample, but probably not CPM values of the same gene between samples). If that's not the case, then you're mostly removing interpretability from the results.</p>

CC BY-SA 4.0
2018-05-06T08:34:32.710Z
2018-05-06T21:56:07.830Z
2018-05-06T21:56:07.830Z
Devon Ryan
<p>I am a bit in doubt how to calculate correctly the mean (average) in the logarithmic scale. I know e.g., that a division in the normal scale becomes a subtraction in the logarithmic scale, and so forth, that's why I was wondering what the correct way is to calculate the mean (since the mean is calculated by additions and divisions in the normal scale).</p>

<p>So for example, if I have in RNAseq data a group with 3 samples, and have log2 CPM values for each sample. How can I calculate the mean of the group correctly?</p>

<p>Do I first need to get CPM (without log2), calculate the mean and then apply log2? Or can I just ignore the fact that the log2 CPM values are in the log scale, and just calculate the mean as if it was the normal scale (add all up and divide by <em>n</em>)?</p>

CC BY-SA 4.0
2018-05-05T10:35:23.503Z
You can calculate the mean of a value that is a log2 of another value as you would normally. However mean(log2(CPM), log2(CPM), ...) != log2(mean(CPM, )), choosing one or another depends on what do you want to do.
llrs
CC BY-SA 4.0
2018-05-05T14:04:19.490Z
And which one to choose if you want to represent the average of the group?
benn
CC BY-SA 4.0
2018-05-05T15:52:06.557Z
I usually use `mean(log2(`, as the log2CPM are the normalized values, so the "important" ones.
llrs
<rna-seq>
Average of logCPM
# Average of logCPM

(Asked by: username_0 on 2018-05-05)

I am a bit in doubt how to calculate correctly the mean (average) in the logarithmic scale. I know e.g., that a division in the normal scale becomes a subtraction in the logarithmic scale, and so forth, that's why I was wondering what the correct way is to calculate the mean (since the mean is calculated by additions and divisions in the normal scale).

So for example, if I have in RNAseq data a group with 3 samples, and have log2 CPM values for each sample. How can I calculate the mean of the group correctly?

Do I first need to get CPM (without log2), calculate the mean and then apply log2? Or can I just ignore the fact that the log2 CPM values are in the log scale, and just calculate the mean as if it was the normal scale (add all up and divide by *n*)?

**Tags:** rna-seq
> **Comments:**
> **username_1**: You can calculate the mean of a value that is a log2 of another value as you would normally. However mean(log2(CPM), log2(CPM), ...) != log2(mean(CPM, )), choosing one or another depends on what do you want to do.  
> **username_0**: And which one to choose if you want to represent the average of the group?  
> **username_1**: I usually use `mean(log2(`, as the log2CPM are the normalized values, so the "important" ones.  

---

## 1 answers

### Answer by username_2 on 2018-05-06. Score: 2 | Accepted answer

The mean of log-transformed values is the log-transformed geometric mean of the untransformed values (i.e., $log_{2}(geometric~mean)$). This can be useful when the values you want to summarize have vastly different ranges (so one doesn't dominate the average). I would expect that to generally NOT be the case for CPMs of the same gene, so it's unclear to me what the point of that would be. It can also be difficult to interpret these results due to the geometric mean being dependent upon the variance:
> originalValues = rnorm(1000, mean=10, sd=c(rep(1, 500), rep(2, 500)))
> mean(originalValues[1:500])
[1] 9.991464
> mean(originalValues[501:1000])
[1] 10.04407
> log2(mean(originalValues[1:500]))
[1] 3.320696
> log2(mean(originalValues[501:1000]))
[1] 3.328272
> mean(log2(originalValues[1:500]))
[1] 3.313263
> mean(log2(originalValues[501:1000]))
[1] 3.300103

Above I created two groups of 500 values each. Each group has approximately the same mean (10) but with different variance (1 vs 2). As you can see, the second group of 500 values randomly has a slightly higher average. The log2(mean) preserves this difference, but the log2(geometric mean) inverts the relationship such that group 2 now appears to have a lower mean value. This isn't really wrong, it's the difference between mean and geometric mean, but it's something that needs to be kept in mind.
This has implications if your want to compare values between genes, since your comparison metric is then not just dependent upon the mean, but also the variability of the data (such that more variable genes will have systematically lower geometric means).
In short, the geometric mean is useful when values are on different scales (such as CPM values of all genes in a sample, but probably not CPM values of the same gene between samples). If that's not the case, then you're mostly removing interpretability from the results.


---

