0

When using seaborn clustermap method, the resulting plot has less columns that the input dataframe. Does anyone know when this can happen?

The input data is a 70x64 dataframe ofcounts, filled mostly with 0s. No row or column is ever all 0s As can be seen here: https://pastebin.com/v5D8MRTP

import seaborn as sns
import pandas as pd
import scipy

cluster_df = pd.read_csv("some/path/to.csv)")
 
 # Generate clustering on binary data
 row_clus = scipy.cluster.hierarchy.linkage(np.where(cluster_df > 0, 1, 0), method = "ward")
 col_clus = scipy.cluster.hierarchy.linkage(np.where(cluster_df.transpose() > 0, 1, 0), method = "ward")
 
 # Clustering heatmap
 plot_clus = sns.clustermap(cluster_df, standard_scale = None, 
                row_linkage = row_clus, 
                col_linkage = col_clus)

This results in the following, which I get even if just calling sns.clustermap(cluster_df):

enter image description here

Lamma
  • 895
  • 1
  • 12
  • 26
  • 1
    Use `sns.clustermap(...., xticklabels=1, yticklabels=1)` to force seaborn to show all tick labels. – JohanC Feb 03 '23 at 14:25
  • You can add `sns.clustermap(...., figsize=...)` if you need a larger figure. `plot_clus.ax_heatmap.tick_params(axis='both', labelsize=8)` would use a smaller font for the labels. – JohanC Feb 03 '23 at 14:37

0 Answers0