jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.29k stars 224 forks source link

How to use the same Kmeans clusters on both original and scaled datasets #1039

Closed adil-mohamed closed 1 year ago

adil-mohamed commented 1 year ago

I have used a scaled RNAseq dataset to generate a heatmap and used kmeans clustering to split the rows (genes). Is there a quick and easy way of generating another heatmap using the same kmeans clusters but run on the original non-scaled dataset? ** Thanks for this amazing resource!

jokergoo commented 1 year ago

You can apply k-means before making the heatmap:

km = kmeans(your_matrix, centers = 4)$cluster

Then you can use km to split whatever heatmap:

Heatmap(mat1, row_split = km)
Heatmap(mat2, row_split = km)
adil-mohamed commented 1 year ago

Perfect, thank you!