Clustermap
Genomic Variant Light Theme
Mutation impact across gene regions with neon colors on white background
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)
variants = ['Missense', 'Nonsense', 'Frameshift', 'Splice', 'Synonymous',
'UTR_5', 'UTR_3', 'Intronic', 'Promoter', 'Enhancer']
genes = ['TP53', 'BRCA1', 'EGFR', 'KRAS', 'PIK3CA', 'PTEN', 'APC', 'MYC']
data = np.random.rand(10, 8) * 3
data[0, 0] += 4 # TP53 missense
data[1, 1] += 3 # BRCA1 nonsense
data[2, 2] += 3 # EGFR frameshift
data[3, 3] += 4 # KRAS splice
df = pd.DataFrame(data, index=variants, columns=genes)
# Gene function
gene_func = ['Tumor Suppressor']*4 + ['Oncogene']*4
func_palette = {'Tumor Suppressor': '#4927F5', 'Oncogene': '#F54927'}
col_colors = pd.Series(gene_func, index=genes).map(func_palette)
# Neon orange-yellow on light
neon_cmap = LinearSegmentedColormap.from_list('genomic', ['#f8fafc', '#4927F5', '#F54927', '#F5B027'])
g = sns.clustermap(df, cmap=neon_cmap, col_colors=col_colors,
method='average', metric='euclidean',
linewidths=0.4, linecolor='#e5e7eb',
figsize=(9, 8), dendrogram_ratio=(0.12, 0.12),
cbar_pos=(0.01, 0.08, 0.008, 0.12),
annot=True, fmt='.1f', annot_kws={'size': 8, 'color': '#1f2937'})
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('Genomic Variant Impact', color='#1f2937', fontsize=13, fontweight='bold', y=1.02)
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Clustermap examples
☕