text: user939: 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)?
  
  user77: 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.
  
original_text: 939: <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>
   77: <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>
  