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!
1 answer
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
Log in to answer this question.
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.