I am trying to create a genus level heatmap for microbial community identified in my samples. The abundance ranges from 0 to 1. I would like to log-transform the abundance for better visualizing. However, I concern that the log(0), which indicates the absence of bacteria, will not be able to be visualized. I am trying to color these blanks (undefined log values or Inf values) on my heatmap, but I struggle to figure out how to do it.
My data frame is:
Gene Sample Abundance Log10.abundance
A 1 0.0186 -1.7306
B 2 0 -Inf
C 3 7.79E-06 -5.108
D 4 0.0031 -2.5103
E 5 0 -Inf
... ... ... ...
My code was:
ggplot(data=heatmap, mapping=aes(x= Sample, y= Gene,fill= Log10.abundance)) +
geom_tile() +
xlab(label = "Sample") +
scale_fill_distiller(name = "Log10(Abundance)", palette = "RdYlGn")
I greatly appreciate if you could have any help to resolve this problem!