Skip to content

Reordering parent dendrogram slices in k-means split heatmap #1255

Description

@rbutleriii

Hi @jokergoo, this is very similar to #864 , but instead when using column_km to split groups with k-means clustering. I get 6 groups, and would like the swing the groups on their parent branches to re-order from c(6, 5, 4, 3, 2, 1) to c(6, 1, 2, 4, 3, 5).

Image

In general, to make this reproducible I am setting the seed first, but the issue is related to the structure of the list object I get from column_dend(drawn)

Error: `cluster_columns` should be a logical value, a clustering function or a
clustering object.

Example below

library(ComplexHeatmap)

m = t(USArrests[c(1, 6, 13, 20, 23), ])
# set.seed(3) 
hm <- Heatmap(m, column_km = 2)
drawn <- draw(hm)
#  col_dend <- as.dendrogram(column_dend(drawn))
col_dend <- column_dend(drawn)
# set.seed(3)
hm <- Heatmap(m, cluster_columns = col_dend[c(2, 1)])

It is easy to reorder the list, but I cannot figure out a way to feed it back to the constructor or drawn object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions