I would like to be able to use a Clustergram dendrogram and select a leaf or cluster interactively, so I can use it to filter the heatmap to a smaller subset of data in my app.
I am able to create the Clustergram and i set generate_curves_dict and return_computed_traces to True, but I cannot figure out how I can match the curve number to a set of row and col indices.
When I select one of the leave (clusters), I get this payload
{
"payload": [
{
"curveNumber": 11,
"pointNumber": 1,
"x": 112.5,
"y": 417.22277677874365,
"xaxis": {
"anchor": "y9"
},
"yaxis": {
"anchor": "x3"
}
}
]
}
curveNumber corresponds to the cluster number I see in the UI (βCol Cluster 11β) and x corresponds to the distance metric value, but I cannot figure out how to use the curves_dict or the computed_traces to retrieve the index of the rows and column in my heatmapβ¦
The curves_dict just seems to be a list of all my rows, but not the clusters:
{0: ['col', 0],
1: ['col', 1],
2: ['col', 2],
3: ['col', 3],
4: ['col', 4],
5: ['col', 5],
6: ['col', 6],
7: ['col', 7],
.
.
And the computed_traces are just the lines of the dendrogram AFAICTβ¦
{'dendro_traces': {'col': [{'x': array([ 48.75 , 48.75 , 183.32490444, 183.32490444]),
'y': array([335.84263007, 753.16300727, 753.16300727, 417.22277678]),
'mode': 'lines',
'marker': {'color': 'rgb(0,116,217)'},
'text': None,
'hoverinfo': 'y+name',
'xaxis': 'x',
'yaxis': 'y',
'name': 'Col Cluster 0',
'line': {'width': 2},
'type': 'scatter'},
{'x': array([112.5 , 112.5 , 254.14980888, 254.14980888]),
'y': array([287.55355256, 417.22277678, 417.22277678, 353.95645073]),
'mode': 'lines',
'marker': {'color': 'rgb(0,116,217)'},
'text': None,
'hoverinfo': 'y+name',
'xaxis': 'x',
'yaxis': 'y',
'name': 'Col Cluster 11',
'line': {'width': 2},
'type': 'scatter'},
{'x': array([163.125 , 163.125 , 345.17461777, 345.17461777]),
.
.
Is there a way to match the cluster number to the original row and col indices? I could construct the dendrogram using the original scipy code, but surely there must be a way to use the plotly diata directly?