Applying A Divergent Color Scale to A Gene Expression Heat Map

November 14, 2014
By

(This article was first published on Optinalysis, and kindly contributed to R-bloggers)

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:

old10scale

new

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.



To leave a comment for the author, please follow the link and comment on their blog: Optinalysis.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)