我正在处理一堆患者的肿瘤图像表达数据,对于每个患者,我都有其肿瘤的提取图像特征列表。我使用Hierarchical Agglomerative Clustering对患者和特征进行了聚类,并使用.clustermap with Seaborn对其进行了绘制。这是我到目前为止所拥有的:
[现在,每个患者都有一堆与之相关的分类信息,这些信息是癌症亚型(A,B,C,D),T期(1,2,3,4),N期(0,1,2 ,3),M stage(0,1)以及它们属于HAC(1,2,3,...)的簇。而且,每个图像特征也属于不同的类别。我想在每个轴上显示此分类信息(我知道{row,col} _colors。本质上,我正在尝试重新创建下面的图,我想知道用matplotlib / seaborn在Python中是否完全有可能。] >
[此外,您认为此图的作者是用来生成它的,是在2014年完成的。R?
我的代码中包含一些随机数据:
# 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}')
我正在处理一堆患者的肿瘤图像表达数据,对于每个患者,我都有其肿瘤的提取图像特征列表。我使用...
[您将需要手工进行绘制,我认为尝试用Seaborn的ClusterGrid
获得所需的结果是不值得的。您可以使用scipy
生成树状图,并使用imshow()