Pass Clustering.Hclust to Makie.dendrogram

Hello,

I would like to know how to convert the HClust object to a data format that can be processed by the dendrogram recipe for Makie.

There is a quite long pull-request history for the dendrogram recipe, and it seems it was in the initial design to have compatibility with Clustering.jl, but then it s not clear how to do it…

Maybe @kescobo knows :slight_smile:
Thanks!

1 Like

I do! But will need to review to be 100% certain. I can look again later this week, but the short version is that the hclust object has a “merges” property, which is an ordered list of tuples of integers. Each merge represents a node.

The integers inside merges either represent a leaf (negative numbers) or a previous intersection (positive numbers).

In the makie recipe, you have leaves and intersections, but off the top of my head I don’t remember how they relate… I think there’s an example somewhere in one of the issues, but I’ll dig through and try to PR with a package extension this week

1 Like

it’s something like:

hcl = hclust(...)
nodes = Makie.hcl_nodes(hcl)   # this is an undocumented internal function
dendrogram(nodes)
1 Like

Ah yes, I think @ffreyer added that from my example code in the initial PR (see https://github.com/MakieOrg/Makie.jl/pull/2755#discussion_r2091628231).

I see there that I offered to make a PR there nearly a year ago :person_facepalming:

1 Like