Dealing with Log(0) when drawing heat map
1
2
Entering edit mode
9.2 years ago
therealybq ▴ 20

Hi guys,

Recently, a colleague of mine used the Trinity Assembly pipeline to produce a heat map, using a table of the expression levels of many genes for a few samples as the raw input data.

The output was actually a heat map of the logs of the expression levels.

Since some of the expression levels were 0, the logs of these entries would be negative infinity.

When using the heatmap.2() function in R to draw the heat map, an error was returned saying that NA/NaN/inf values were not acceptable.

So I'm just curious: how does the program in Trinity Assembly deal with log(0) entries?

I have asked my colleague, and he does not know either.

Thank you for your replies in advance!

log(0) heat map • 6.4k views
ADD COMMENT
3
Entering edit mode

Don't know about Trinity, but a popular way to address log(x) with x >= 0 is to add a small number to x so that log(0) never happens. Adding +1 has the nice feature that log(x+1) = 0 if x=0. The underlying assumption is that the increment (e.g. +1) doesn't skew the data too much, i.e. most of the non-zero values are >>0.

ADD REPLY
4
Entering edit mode
9.2 years ago
mxs ▴ 530

Hi,

Well, generally there are two way to handle this, and both cases depend what you expect to see as the final result. If negative values are not expected, then adding a pseudo count is one way to go. Pseudo-count can be a value of 1 in this case there is already a build-in function in R (log1p(x) computes log(1+x) accurately also for |x| << 1 (and less accurately when x is approximately -1).) or sometimes people use average(mean) as a correction value. Another way is to "round up" log(0) to log(0.001) which will give a "high" negative value indicating that you are dealing with an non-existing data point but then latter you need to account for that in your post processing.

Hope this helps

mxs

ADD COMMENT

Login before adding your answer.

Traffic: 2640 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6