Closed welyt closed 1 year ago
I don't think this is an issue when you used a tight layout, if the real legend width of color_dict legend was smaller than the given legend_width=50
, then there would be no influence.
Minor suggestion, you can decrease the width/height of the row/col dendrogram to make the figure looks better.
I have set the tight parameter, I tried setting row_ dendrogram=False, But the legend still has cover。
plt.figure(figsize=(16, 10), dpi=300)
cm = ph.ClusterMapPlotter(
data=df_corr,
label='pearson', show_rownames=False, row_names_side='left', top_annotation=col_ha,left_annotation=row_ha,
show_colnames=True, col_cluster=True, row_cluster=True,
col_dendrogram=True, row_dendrogram=False, row_dendrogram_size=20, col_dendrogram_size=20,legend_width=20,
linewidths=0.001,linecolor='white',
col_split_gap=2, row_split_gap=2)
cm.ax.set_title(f"{prefix}-相关性热图—聚类", y=1.03, fontdict={'fontweight':'bold'})
if debug:
plt.show()
else:
plt.savefig(f"{out_dir}/{prefix}_相关性热图_聚类.png", bbox_inches = 'tight')
Please give me the dataset you used in this example, so that I can debug it.
Please give me the dataset you used in this example, so that I can debug it. data_frame_in.csv sample_info.csv
data_frame_in = pd.read_csv("data_frame_in.csv", sep="\t", index_col=0)
sample_info = pd.read_csv('sample_info.csv', sep="\t", index_col=0)
plt.figure(figsize=(16, 10), dpi=300)
col_ha = ph.HeatmapAnnotation(
志愿者=ph.anno_simple(sample_info['志愿者编号'], cmap='Paired'),
类别=ph.anno_simple(sample_info['类别'], cmap='Set1'), wspace=2,
axis=1)
cm = ph.ClusterMapPlotter(
data=data_frame_in,
label='test', show_rownames=False, row_names_side='left', top_annotation=col_ha,
show_colnames=True, col_cluster=True, row_cluster=True,
col_dendrogram=True, row_dendrogram=True, row_dendrogram_size=20, col_dendrogram_size=20,legend_width=20)
cm.ax.set_title("热图—聚类", y=1.03, fontdict={'fontweight':'bold'})
plt.show()
Please give me the dataset you used in this example, so that I can debug it.
sorry, it may my fault(reboot jupyter), now it works fine!
when set *_dendrogram=True
cm = ph.ClusterMapPlotter( data=z_df, top_annotation=col_ha, left_annotation=row_annotation, label='z-score', show_rownames=False, show_colnames=True, col_cluster=True, row_cluster=True, col_split_gap=3, col_dendrogram=True, row_dendrogram=True, legend_width=50, verbose=0)
when set *_dendrogram=False