d3heatmap icon indicating copy to clipboard operation
d3heatmap copied to clipboard

Extra labels for Heatmap

Open bhive01 opened this issue 9 years ago • 1 comments

I work with field data where blocks effectively represent data, but in many cases the Row and Column isn't terribly helpful since these are little more than coordinates (1, 3). I hacked the functions to allow adding an extra label that is input as a matrix or data.frame or similar, of the same dimensions as the data.

## un-comment to install my version
#devtools::install_github("bhive01/d3heatmap")

require(d3heatmap)

#create fake data
df1 <- data.frame(matrix(runif(300), 30, 10))

#create fake, but unique labels
df2 <- NA
for (i in 1:300) {
    df2[i] <- paste0(sample(LETTERS, size=5), collapse="")
    }

df2 <- data.frame(matrix(df2, 30, 10))

#plot without dendrogram or scaling
d3hmplot <- function(data, labels = NULL) {
    d3heatmap(data, labels , Rowv = FALSE, Colv = FALSE, dendrogram = "none", scale="none", distfun = NULL)
}

#without extra labels
d3hmplot(data=df1)

#with extra labels
d3hmplot(data=df1, labels = df2)

I have not tested this with the dendrogram or scaling. It probably breaks when you do that, and labeling wouldn't make much sense then anyway.

bhive01 avatar Sep 10 '15 22:09 bhive01

Hey there, I'm planning to merge https://github.com/talgalili/d3heatmap/pull/86 into the package.

Could you verify if your PR adds to it or not?

Thanks!

(sorry for responding 4 years later :D I just took over maintaining the package)

talgalili avatar Jan 29 '21 10:01 talgalili