Clustermap
Drug Sensitivity Profile
Cancer cell line response to treatment panel
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
np.random.seed(42)
# Cell lines and drugs
cell_lines = [f'CL_{i:02d}' for i in range(1, 21)]
drugs = ['Drug_A', 'Drug_B', 'Drug_C', 'Drug_D', 'Drug_E',
'Drug_F', 'Drug_G', 'Drug_H', 'Drug_I', 'Drug_J']
# IC50 values (log-transformed, lower = more sensitive)
ic50 = np.random.randn(len(cell_lines), len(drugs))
# Add drug class sensitivity patterns
ic50[:7, :3] -= 1.5 # Group 1 sensitive to drugs A-C
ic50[7:14, 3:6] -= 1.5 # Group 2 sensitive to drugs D-F
ic50[14:, 6:] -= 1 # Group 3 sensitive to drugs G-J
df = pd.DataFrame(ic50, index=cell_lines, columns=drugs)
# Cancer type annotations
cancer_type = ['Breast']*7 + ['Lung']*7 + ['Colon']*6
type_palette = {'Breast': '#F5276C', 'Lung': '#27D3F5', 'Colon': '#6CF527'}
row_colors = pd.Series(cancer_type, index=cell_lines).map(type_palette)
# NEON sensitivity colormap (red=resistant, blue=sensitive)
neon_sens = LinearSegmentedColormap.from_list('neon_sens', ['#F5276C', '#0a0a0f', '#27D3F5'])
g = sns.clustermap(df, cmap=neon_sens, center=0, row_colors=row_colors,
method='average', metric='euclidean',
linewidths=0.3, linecolor='#1a1a2e',
figsize=(9, 7), dendrogram_ratio=(0.1, 0.15),
cbar_pos=(0.01, 0.08, 0.008, 0.12),
tree_kws={'linewidths': 1.5, 'colors': '#27D3F5'})
g.fig.patch.set_facecolor('#0a0a0f')
g.ax_heatmap.set_facecolor('#0a0a0f')
g.ax_heatmap.tick_params(colors='white', labelsize=8)
for ax in [g.ax_row_dendrogram, g.ax_col_dendrogram]:
ax.set_facecolor('#0a0a0f')
g.fig.suptitle('Drug Sensitivity Profiling', color='white', fontsize=14, fontweight='bold', y=1.02)
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Clustermap examples
☕