heatmaply icon indicating copy to clipboard operation
heatmaply copied to clipboard

Clustering using k_col

Open margauxhaering opened this issue 4 years ago • 4 comments

Hi, I really love using heatmaply and I am really happy with the k_col argument. To obtain a list of these clusters I used the hclust and dist functions. But is it possible to obtain some sort of legend to number these clusters as in my dend and cut object ? (I'll note that my data table is transposed before plotting)

library("heatmaply")
data <- mtcars
dend <- hclust(dist(t(data), method = 'euclidean'), method = 'ward.D2')
cut <- cutree(dend, k = 5)


# As my heatmap is : 

heatmaply(
  data,
  colors = RdYlGn(100),
  k_col = 5,
  dist_method = 'euclidean',
  hclust_method = 'ward.D2',
  xlab = "Gene",
  ylab = "Sample",
  margins = c(150, 100, 40, 20),
  scale = "none",
  labCol = colnames(data),
  labRow = rownames(data)
)

Thank you very much! Margaux

margauxhaering avatar Mar 24 '20 14:03 margauxhaering

Do you mean a legend on the heatmap?

alanocallaghan avatar Mar 24 '20 14:03 alanocallaghan

An annotation bar to specify which cluster is the nb1, nb2, nb3..., nb15

margauxhaering avatar Mar 24 '20 14:03 margauxhaering

Ah, yeah legends are a bit tricky with plotly. I'll see if things are easier than before.

alanocallaghan avatar Mar 24 '20 14:03 alanocallaghan

Thank you very much for your time!

margauxhaering avatar Mar 24 '20 14:03 margauxhaering