I'm trying to plot an interactive dendrogram with an unequal heatmap on jupyter notebook using Plotly package that would look like this one.

My example data called dataHeat_arr is numpy.ndarray, which has 75 rows (samples called S0 till S74) and 100 columns (Metabolites called M0 till M99) and available in the link.
In the link there are 3 csv files.
- dataHeat_arr.csv - the numpy.ndarray 75*100
- name_molec.csv - list of metbolite named M0, M1,... till M99
- Samplenum.csv - list of samples named S0, S1,... till S74
I based my code on the example from her and made some changes since my the heatmat is unequale.
Also tried questoins Plotly clustered heatmap (with dendrogram)/Python
I do not know what I'm doning worng by the finale figure is missig the heat map. only when ploting with equale heatmap I manage to plot the heatmap with the dendrogram.
her is my code.
Import packges:
import plotly.figure_factory as ff
import numpy as np
np.random.seed(1)
import pandas as pd
import numpy as np
import string
from itables import init_notebook_mode
from itables import show
import cimcb_lite as cb
import plotly.graph_objects as go
init_notebook_mode(all_interactive=True)
Initialize figure by creating upper dendrogram:
# name the samples S0 till S74
# Samplenum & name_molec are csv files in the link of Github and should be treated as lists
labels = Samplenum
dataHeat_arr_t= np.transpose(dataHeat_arr)
# Initialize figure by creating upper dendrogram
fig = ff.create_dendrogram(dataHeat_arr, orientation='bottom', labels=labels)
# fig = ff.create_dendrogram(dataHeat_arr_t, orientation='bottom', labels=name_molec[:100] ) ,labels=name_molec[:100]
for i in range(len(fig['data'])):
fig['data'][i]['yaxis'] = 'y2'
Then Create Side Dendrogram:
# Create Side Dendrogram
dendro_side = ff.create_dendrogram(dataHeat_arr_t, orientation='right' ,labels=name_molec[:100])
# dendro_side = ff.create_dendrogram(dataHeat_arr, orientation='right', labels=labels)
for i in range(len(dendro_side['data'])):
dendro_side['data'][i]['xaxis'] = 'x2'
# Add Side Dendrogram Data to Figure
for data in dendro_side['data']:
fig.add_trace(data)
Create Heatmap:
heatmap = [
go.Heatmap(
x = name_molec[:100],
y =labels ,
z = dataHeat_arr,
colorscale = 'Cividis'
)
]
Add Heatmap Data to Figure:
for data in heatmap:
fig.add_trace(data)
Now layout:
# Edit Layout
fig.update_layout({'width':1500, 'height':750,
'showlegend':False, 'hovermode': 'closest',
})
# Edit xaxis
fig.update_layout(xaxis={'domain': [.15, 1],
'mirror': False,
'showgrid': False,
'showline': False,
'zeroline': False,
'ticks':""})
# Edit xaxis2
fig.update_layout(xaxis2={'domain': [0, .15],
'mirror': False,
'showgrid': False,
'showline': False,
'zeroline': False,
'showticklabels': False,
'ticks':""})
# Edit yaxis
fig.update_layout(yaxis={'domain': [0, .85],
'mirror': False,
'showgrid': False,
'showline': False,
'zeroline': False,
'showticklabels': False,
'ticks': ""
})
# Edit yaxis2
fig.update_layout(yaxis2={'domain':[0.852, 0.975],
'mirror': False,
'showgrid': False,
'showline': False,
'zeroline': False,
'showticklabels': False,
'ticks':""})
fig.show()
for some reason the plot looks like that:
Any idea/ hint will be usfull and appriciated!

