Clustermap
Clinical Trial Biomarkers
Biomarker levels across patient cohorts in clinical study
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(111)
biomarkers = ['CRP', 'IL-6', 'TNF-a', 'WBC', 'Platelets', 'Hemoglobin',
'Creatinine', 'ALT', 'AST', 'Albumin', 'Glucose', 'HbA1c']
patients = [f'P{i:02d}' for i in range(1, 17)]
data = np.random.randn(12, 16)
data[:4, :6] -= 1.5
data[:3, 10:] += 2
df = pd.DataFrame(data, index=biomarkers, columns=patients)
response = ['Responder']*6 + ['Partial']*4 + ['Non-responder']*6
resp_palette = {'Responder': '#22c55e', 'Partial': '#f59e0b', 'Non-responder': '#ef4444'}
col_colors = pd.Series(response, index=patients).map(resp_palette)
light_cmap = LinearSegmentedColormap.from_list('clinical', ['#3b82f6', '#f8fafc', '#ef4444'])
g = sns.clustermap(df, cmap=light_cmap, center=0, col_colors=col_colors,
method='ward', metric='euclidean',
linewidths=0.5, linecolor='#e2e8f0',
figsize=(10, 8), dendrogram_ratio=(0.12, 0.12),
cbar_pos=(0.01, 0.08, 0.008, 0.12))
g.fig.patch.set_facecolor('#ffffff')
g.ax_heatmap.set_facecolor('#ffffff')
g.ax_heatmap.tick_params(colors='#1f2937', labelsize=8)
g.ax_row_dendrogram.set_facecolor('#ffffff')
g.ax_col_dendrogram.set_facecolor('#ffffff')
g.cax.tick_params(colors='#1f2937', labelsize=7)
g.fig.suptitle('Clinical Trial Biomarkers', color='#1f2937', fontsize=13, fontweight='bold', y=1.02)
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Clustermap examples
☕