color_branches from dendextend package retrieving overlapping subdendrograms

48 views Asked by At

I am trying to use the color_branches function from dendextend package to color the dendrogram branches of my heatmap create with complexheatmap.

I bumped into a strange behaviour, as you can see in the image:

heatmap example.

as you can see some leaves have mixed colors. This heatmap results from the following code

column_dend = hclust(dist(t(data)))
row_dend = hclust(dist((data)))
row_dend = color_branches(row_dend, k = 2)

ht<-Heatmap(as.matrix(data),
            name = "legend",
            cluster_rows = row_dend,
            cluster_columns = column_dend,
            na_col = 'black',
            column_names_rot = 45,
            col = circlize::colorRamp2(c(-1, 0, 1), c("#56B4E9", "#FFFFFF", "#FF7400")),
            show_row_names = F,
            show_column_names = F,
            use_raster = F,
            heatmap_width = unit(1.5, "cm")*ncol(data),
            column_names_gp = grid::gpar(fontsize = 13),
            row_names_gp = grid::gpar(fontsize = 1))

ht = draw(ht)

Any guess about what is going on ? thanks a lot

0

There are 0 answers