Estimated Read Time: Under 5 minutes

This is a quick post about a quick little experiment I tried lately. I saw a recent post about how red and blue color scales on political heat maps can be misleading--primarily because human perception is not very good at discriminating between shades of purple in the presented scenario.

Since gene expression heat maps are virtually a right of passage in bioinformatics, I thought I'd try and rescale the colors on a gene expression heat map to a properly divergent color scale and visualize the results. Results Below:



At the top is a plot (green and blue) generated using the code available on Peter Cock's website (but modified to only use 10 colors on the scale). Below that is the plot (red and blue) generated with my modified version.

And of course, code for your consumption:

Thanks to Kenneth Moreland's research on color scales, and José Gama's implementation in R (now part of Rgnuplot), all it took was a one line modification of Peter's code to switch to the new divergent color scale!

The new scale does seem to help us visually discriminate between the elements in the "muddy" area of the left plot. However, since the use of the heat map in bioinformatics is more aesthetic than functional, I'm afraid the fruits seem to stop there. Although this is paints a prettier picture, the hierarchical clustering results remain unchanged. Fun to try though! And now we know a divergent color scale function implementation exists in R!

It always takes a while to write a blog post. In return, all I ask is that you share. Also, if you are a Python or R coder and would like to learn to use D3.js, please check out my O'Reilly Media product, D3 and Coffeescript: A Python Programmer's Introduction to Web Visualizations.