# Help with log2 transformation of normalized data

I have a dataset that I normalize so that the average equals 1. If I then log2 transform the dataset, should the average of the log2 data equal 0?

For example:

1, 1, 1. The average of the dataset is equal to 1. If I log2 transform the data, the new set is: 0; 0; 0;. The new average is 0.

So, why does this not work when I start using different numbers? For example:

Data set: 1, 2, 3. Average = 2. I normalize the data set by dividing by the mean (2).

Normalized data set: 0.5, 1, 1.5. Average = 1. I then log2 transform the dataset.

Log2 transformed: -1, 0, 0.58496. Average = -0.13835.

Why does the average of the log2 dataset not equal 0 if the normalized average equals 1? I feel like I'm losing my mind in my inability to understand why this does not work.

Can someone explain to me how to transform my data so that the mean of the log2 transformed data equals zero? I could graph the log2 of the ratio, but I want to plot individual values for a control and experimental group in log2(ratio) format.

Regards, Jacob

The logarithm is a non-linear function, and only linear transformations, that is ones that can be written $$f(x) = ax + b$$, will preserve the mean.

As you observed for log the large values aren't as far above the middle as the lower values are below it. Speaking roughly, this is what is meant by log being a concave function. Like all concave functions, the average of the logs will always be lower than the log of the average.

The log function is monotonic however (only every increasing), which means that while the mean is not preserved, the median will be preserved.

This means you have to simple options;

• Transform the data first, then normalise it to be centred on zero. This directly answers your question of how to get the mean of the logs to be zero. You don't explain why you want this property, so I can't comment if this is a good idea.It is worth noting that demeaning logged data is equivalent to dividing all the original data by a constant, rather than shifting the original data. This may or may not be sensible.
• Work with the median of the data instead of the mean, then you set the median to 1 before the transform and it will be zero after the transform.

A more sophisticated approach would be to not transform your data but simply model the log of the mean

$$\log_2(E[Y|X]) = \beta X$$

This would be a Generalized Linear Model and can be found in most statistical packages. This is usually better than transforming the data, but a little more involved to use.

Centering Log Transformed Data

One of the suggestions I make above, is simply take logs, then centre the data. It is worth noting that is equivalent to diving the original data by the geometric mean.

$$\log(X_i) - \frac{1}{N}\sum_k{\log(X_k)} = \log(X_i)-\log\left(\prod_k{X_k^{1/N}}\right)$$

$$=\log\left(\frac{X_i}{\prod_k{X_k^{1/N}}}\right)$$

Thinking about whether this concept seems sane and meaningful migth guide whether or not this is a sensible transformation to make.

• Thank you for your explanation and response. --- I am plotting relative gene expression data that was referenced to an external standard. In other words, the mean of our control group did not necessarily equal 1. In instances where my data for specific genes were skewed and didn't pass tests of normality for subsequent analysis, I log2 transformed them and plotted the log2 transformed data. However, my reviewer wants me to normalize all of my data and plot the fold change. This is easily done for the non log2 transformed data, but I don't know how to get the log2 mean = 0. – Jacob Bumgarner Mar 8 '20 at 23:45
• @JacobBumgarner ok so it sounds like you are only standardising in order to make it comparible to a control group. I don't know much about gene expression data or what exactly you'd be plotting/trying to show (or even what you are talking the mean of). If you switch back and forth between log and non-log data, then median instead of mean will be nice and consistent throughout. If you don't switch back and forth much, then standardising AFTER taking logs would probably do the trick. – Corvus Mar 8 '20 at 23:51
• Is it RNA sequencing data? Are you normalising using size factors/TMM as well, or simply trying to standardise to a set mean? – alan ocallaghan Mar 8 '20 at 23:52
• @JacobBumgarner to standardise after taking logs, I literally mean just subtract the mean of the logs from the logs. – Corvus Mar 8 '20 at 23:56
• If the data are from sequencing, naive normalisation like this really isn't appropriate, see for example academic.oup.com/bib/article/14/6/671/189645 – alan ocallaghan Mar 9 '20 at 0:07