<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/"></div></div><div><a data-url="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/" data-counturl="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/" data-count="horizontal" data-text="heatmaply: interactive heat maps (with R)" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-statistics.com/2016/05/heatmaply-interactive-heat-maps/"> R – R-statistics blog</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I am pleased to announce <a target="_blank" href="https://github.com/talgalili/heatmaply"><strong>heatmaply</strong></a>, my new R package for generating interactive heat maps, based on the <a target="_blank" href="https://github.com/ropensci/plotly">plotly</a> R package.</p>
<h3>tl;dr</h3>
<p>By running the following 3 lines of code:</p>
<div>
<table>
<tr>
<td>
<pre><span>install.<span>packages</span></span><span>(</span><span>&quot;heatmaply&quot;</span><span>)</span>
<span>library</span><span>(</span>heatmaply<span>)</span>
heatmaply<span>(</span><span>mtcars</span>, k_col <span>=</span> <span>2</span>, k_row <span>=</span> <span>3</span><span>)</span> <span>%>%</span> <span>layout</span><span>(</span>margin <span>=</span> <span>list</span><span>(</span>l <span>=</span> <span>130</span>, b <span>=</span> <span>40</span><span>)</span><span>)</span></pre>
</td>
</tr>
</table>
</div>
<p>You will get this output in your browser (or RStudio console):</p>
<p><iframe height="400" width="450" src="https://plot.ly/~talgalili/23.embed"></iframe></p>
<p>You can see more example in the <a target="_blank" href="https://cran.r-project.org/web/packages/heatmaply/vignettes/heatmaply.html">online vignette on CRAN</a>. <strong>For <a target="_blank" href="https://github.com/talgalili/heatmaply/issues">issue reports</a> or feature requests, please visit the <a target="_blank" href="https://github.com/talgalili/heatmaply">GitHub repo</a>.</strong></p>
<p><span></span></p>
<h3>Introduction</h3>
<p>A <a target="_blank" href="https://en.wikipedia.org/wiki/Heat_map">heatmap</a> is a popular graphical method for visualizing high-dimensional data, in which a table of numbers are encoded as a grid of colored cells. The rows and columns of the matrix are ordered to highlight patterns and are often accompanied by dendrograms. Heatmaps are used in many fields for visualizing observations, correlations, missing values patterns, and more.</p>
<p>Interactive heatmaps allow the inspection of specific value by hovering the mouse over a cell, as well as zooming into a region of the heatmap by draging a rectangle around the relevant area.</p>
<p>This work is based on the <a target="_blank" href="https://cran.r-project.org/web/packages/ggplot2/index.html">ggplot2</a> and <a target="_blank" href="https://github.com/plotly/plotly.js/">plotly.js</a> engine. It produces similar heatmaps as <a target="_blank" href="https://github.com/rstudio/d3heatmap">d3heatmap</a>, with the advantage of speed (plotly.js is able to handle larger size matrix), the ability to zoom from the dendrogram (thanks to the <a target="_blank" href="https://cran.r-project.org/web/packages/dendextend/">dendextend R package</a>), and the possibility of seeing new features in the future (such as sidebar bars).</p>
<h3>Why heatmaply</h3>
<p>The <a target="_blank" href="https://cran.r-project.org/web/packages/heatmaply/index.html">heatmaply package</a> is designed to have a familiar features and user interface as <a target="_blank" href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/heatmap.html">heatmap</a>, <a target="_blank" href="https://cran.r-project.org/web/packages/gplots/index.html">gplots</a>::<a target="_blank" href="http://www.rdocumentation.org/packages/gplots/functions/heatmap.2">heatmap.2</a> and other functions for static heatmaps. You can specify <a target="_blank" href="http://www.r-statistics.com/2015/08/dendextend-a-package-for-visualizing-adjusting-and-comparing-dendrograms-from-the-journal-bioinformatics/">dendrogram</a>, clustering, and scaling options in the same way. heatmaply includes the following features:</p>
<ul>
<li>Shows the row/column/value under the mouse cursor (and includes a legend on the side)</li>
<li>Drag a rectangle over the heatmap image, or the dendrograms, in order to zoom in (the dendrogram coloring relies on integration with the <a target="_blank" href="https://github.com/talgalili/dendextend">dendextend </a>package)</li>
<li>Works from the R console, in RStudio, with <a target="_blank" href="http://rmarkdown.rstudio.com/">R Markdown</a>, and with <a target="_blank" href="http://shiny.rstudio.com/">Shiny</a></li>
</ul>
<p>The package is similar to the <a target="_blank" href="https://cran.r-project.org/web/packages/d3heatmap/">d3heatmap</a> package (developed by the brilliant <a target="_blank" href="https://github.com/jcheng5">Joe Cheng</a>), but is based on the <a target="_blank" href="https://github.com/ropensci/plotly">plotly</a> R package. Performance-wise it can handle larger matrices. Furthermore, since it is based on <a target="_blank" href="https://cran.r-project.org/web/packages/ggplot2/index.html">ggplot2</a>+<a target="_blank" href="https://github.com/ropensci/plotly">plotly</a>, it is expected to have more features in the future (as it is more easily extendable by also non-JavaScript experts). I choose to build heatmaply on top of <a target="_blank" href="https://github.com/plotly/plotly.js/">plotly.js</a> since it is a free, open source, JavaScript library that can translate ggplot2 figures into self-contained interactive JavaScript objects (which can be viewed in your browser or RStudio).</p>
<p>The default color palette for the heatmap is based on the beautiful <a target="_blank" href="https://cran.r-project.org/web/packages/viridis/index.html">viridis package</a>. Also, by using the <a target="_blank" href="https://github.com/talgalili/dendextend">dendextend </a>package (see the open-access two-page <a target="_blank" href="http://bioinformatics.oxfordjournals.org/content/31/22/3718">bioinformatics paper</a>), you can customize dendrograms before sending them to heatmaply (via Rowv and Colv).</p>
<p>You can see some more eye-candy in the <a target="_blank" href="https://cran.r-project.org/web/packages/heatmaply/vignettes/heatmaply.html">online Vignette on CRAN</a>, for example:</p>
<p><a target="_blank" href="https://cran.r-project.org/web/packages/heatmaply/vignettes/heatmaply.html"><img sizes="(max-width: 450px) 85vw, 450px" srcset="http://i0.wp.com/www.r-statistics.com/wp-content/uploads/2016/05/2016-05-31-23_21_46-Clipboard-1.png?w=450 450w, http://i0.wp.com/www.r-statistics.com/wp-content/uploads/2016/05/2016-05-31-23_21_46-Clipboard-1.png?resize=300%2C207 300w" alt="2016-05-31 23_21_46-Clipboard" class="wp-image-61401" src="http://i0.wp.com/www.r-statistics.com/wp-content/uploads/2016/05/2016-05-31-23_21_46-Clipboard-1.png?resize=450%2C310" data-recalc-dims="1"></a></p>
<p><strong>For <a target="_blank" href="https://github.com/talgalili/heatmaply/issues">issue reports</a> or feature requests, please visit the <a target="_blank" href="https://github.com/talgalili/heatmaply">GitHub repo</a>.</strong></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/"></div></div><div><a data-url="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/" data-counturl="http://www.r-bloggers.com/heatmaply-interactive-heat-maps/" data-count="vertical" data-text="heatmaply: interactive heat maps (with R)" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-statistics.com/2016/05/heatmaply-interactive-heat-maps/"> R – R-statistics blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/NhbM0iUe3i0"></a></div>