Heatmap with dendrograms on both axes

Hi,

Does anyone know if it is possible using Knime to create a heatmap of a matrix where both axes are clustered and displayed as dendrograms?

Any tips appreciated/Evert

That is possible with the help to R. You would have to check the code if the distance and cluster settings fit your needs. You can also export the numbers behind the clustering of the ‘teeth’.

The data is from the ‘cars’ dataset like in your example. I did not check if the heatmap makes sense. The interpretation would have to be done in addition to some column selection and it might be necessary to normalize some data in order for it to make sense in such a display.

edit: there might be a more KNIME-like way although I have not checked it out: Dendrogram with Heatmap (Clustering)

kn_example_r_heatmap_cars.knwf (346.2 KB)

3 Likes

Hey!

This was very helpful. I had in the meantime figured out how to do it using RStudio using the heatmaply package, but with your help I was now able to transfer the code to Knime:

library(heatmaply)

rnames <- knime.in[,1] # assign labels in column 1 to “rnames”
mat_data <- data.matrix(knime.in[,2:ncol(knime.in)]) # transform column 2-5 into a matrix
rownames(mat_data) <- rnames # assign row names

heatmaply(x = (mat_data),
color = viridis,
hclust_method = “average”, k_row = NA)

This snippet is enough to give the following heatmap with dendrograms:

Many thanks/Evert

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.