0
$\begingroup$

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)?

$\endgroup$
3
  • 1
    $\begingroup$ 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. $\endgroup$
    – llrs
    May 5, 2018 at 10:35
  • $\begingroup$ And which one to choose if you want to represent the average of the group? $\endgroup$
    – benn
    May 5, 2018 at 14:04
  • $\begingroup$ I usually use mean(log2(, as the log2CPM are the normalized values, so the "important" ones. $\endgroup$
    – llrs
    May 5, 2018 at 15:52

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.