I am working with tumour image expression data for a bunch of patients, for each patient I have a list of extracted image features of their tumour. I have clustered the patients and features using Hierarchical Agglomerative Clustering, and plotted it with .clustermap with Seaborn. This is what I have so far:
Now, each patient has a bunch of categorical information associated with it, these are cancer subtype(A,B,C,D), T stage (1,2,3,4), N stage(0,1,2,3), M stage(0,1) and well, the cluster they belong to from HAC(1,2,3,...). Moreover, each image feature belongs to a different class as well. I would like to display this categorical information on each axis (I am aware of {row, col}_colors. Essentially I am trying to recreate the below plot and I am wondering if it is at all possible with matplotlib/seaborn in Python.
Also, what do you think the authors of this figure used to generate it, was done back in 2014. R?
My code with some random data:
# Random dummy data
np_zfeatures = np.random.random((420, 1218)) # example matrix of z-scored features [patients, features]
patient_T_stage = np.random.randint(low=1, high=5, size=(420,))
patient_N_stage = np.random.randint(low=0, high=4, size=(420,))
patient_M_stage = np.random.randint(low=0, high=2, size=(420,))
patient_O_stage = np.random.randint(low=0, high=5, size=(420,))
patient_subtype = np.random.randint(low=0, high=5, size=(420,))
feature_class = np.random.randint(low=0, high=5, size=(1218,)) # There's 5 categories of features (first order, shape, textural, wavelet, LoG)
# HAC clustering (compute linkage matrices)
method = 'ward'
feature_links = scipy.cluster.hierarchy.linkage(np_zfeatures, method=method, metric='euclidean')
patient_links = scipy.cluster.hierarchy.linkage(np_zfeatures.transpose(), method=method, metric='euclidean')
# plot the re-ordered cluster map
cbar_kws={'orientation': 'vertical',
'label': 'feature Z-score',
'extend': 'both',
'extendrect':True
}
arguments = {
'row_cluster': True,
'col_cluster': True,
'row_linkage': patient_links,
'col_linkage': feature_links
}
cmap = 'Spectral_r'
cg = sns.clustermap(np_zfeatures.transpose(), **arguments, cmap=cmap, vmin=-2, vmax=2, cbar_pos=(0.155,0.644,0.04, 0.15), cbar_kws=cbar_kws)
cg.ax_row_dendrogram.set_visible(False)
cg.ax_col_dendrogram.set_visible(True)
ax = cg.ax_heatmap
ax.set_xlabel('Patients', fontsize=16)
ax.set_ylabel('Radiomics Features', fontsize=16)
cb_ax = cg.ax_cbar.yaxis.set_ticks_position('left')
cb_ax = cg.ax_cbar.yaxis.set_label_position('left')
cg.savefig(f'hierarchical cluster map - method: {method}')