talgalili / d3heatmap

A D3.js-based heatmap htmlwidget for R
Other
237 stars 95 forks source link

Add an option to add a heatmap legend #17

Open MySchizoBuddy opened 9 years ago

MySchizoBuddy commented 9 years ago

A heatmap legend shows the relationship between the colors used and the values. heatmap

Brendan-McWalters commented 9 years ago

Option to add a legend would be great. Please add this feature.

flaneuse commented 9 years ago

+1.

kmakat commented 9 years ago

+1

sonali-bioc commented 9 years ago

+1

daroczig commented 9 years ago

+1

mattjmorris commented 8 years ago

+1

scheckley commented 8 years ago

+1 this is essential for the viewer to interpret the scale for the colour scheme used in the plot.

res88 commented 8 years ago

+1 would transform the utility of this for use in publications.

zji90 commented 8 years ago

+1

aemoor commented 8 years ago

+1

mlist commented 8 years ago

+1

CharlesJB commented 8 years ago

+1

warnes commented 8 years ago

+1

alanocallaghan commented 8 years ago

Currently implements a color key and histogram and allows the passage of factors/characters/numbers as RowSideColors and ColSideColors. Will soon add labels for ColSideColors and RowSideColors. Issues welcome https://github.com/Alanocallaghan/d3heatmap

DataStrategist commented 7 years ago

I thought I was clever... I thought use another heatmap as the legend of the heatmap! And in the process discovered that you can't make a heatmap out of a 1-row matrix (or df):

legendDF <- data.frame(a=3,b=2,c=1,d=0)
rownames(legendDF) <- "Legend"
d3heatmap(legendDF, dendrogram = 'none', 
                colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))

doesn't plot anything... but if I add another row:

legendDF <- data.frame(a=c(3,2),b=c(2,2),c=c(1,2),d=c(0,2))
rownames(legendDF) <- c("Legend","s")
d3heatmap(legendDF, dendrogram = 'none', 
                colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))

That works. OK, so lemme be sneaky:

d3heatmap(legendDF[1,], dendrogram = 'none', 
                colors = c("#A8A8A8","#F9F200","#F40E00","#1FAE00"))

Nope... fail.

alanocallaghan commented 7 years ago

The problem is due to how R treats 1-dimensional data.frames or matrices (no surprise there!).

The bug is in d3heatmap.R line 243: x <- x[rowInd, colInd] should be x <- x[rowInd, colInd, drop = FALSE]

I've resolved this in my fork (linked above)

talgalili commented 7 years ago

Hello all,

The heatmaply R package is a new implementation of interactive cluster heatmaps in R which relies on the plotly R package. This is based on a fork of my work in d3heatmap.

The package is availabale from CRAN: https://cran.r-project.org/package=heatmaply

The feature you've requested is now available (as default) by using the following code:

library(heatmaply)
heatmaply(mtcars)

image