1

I would like to return a specific number of clusters for my interactive heatmap from heatmaply like I can do with pheatmap and the kmeans_k = argument. Is there a way to do this with heatmaply?

If I have a large matrix and do not define the number of clusters to return with heatmaply, it takes too long to calculate the heatmap or I will get the error: 'vector memory exhausted(limit reached?)'.

library(pheatmap)
data(mtcars)
mat <- as.matrix(mtcars)

pheatmap(
  mtcars,
  border_color = "grey20",
  main = "",
  show_rownames = TRUE,
  show_colnames = TRUE,
  kmeans_k = 30,
  cluster_rows = F,
  cluster_cols = F
)
jLuthy
  • 11
  • 2

1 Answers1

0

You want to use the k_col, and or k_row arguments.

You can see examples in the vignette, but just a simple example:

library("heatmaply")
heatmaply(mtcars, k_col = 2, k_row = 4)

Output:

enter image description here

Tal Galili
  • 24,605
  • 44
  • 129
  • 187