Dendrogram

Gene Expression Dendrogram

Biological data clustering visualization

Output
Gene Expression Dendrogram
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage, set_link_color_palette

np.random.seed(123)

# Simulated gene expression data
genes = ['BRCA1', 'TP53', 'EGFR', 'MYC', 'KRAS', 'PIK3CA', 'PTEN', 'APC',
         'RB1', 'CDK4', 'BRAF', 'NRAS', 'ATM', 'ERBB2', 'JAK2']
data = np.random.randn(len(genes), 8)

Z = linkage(data, method='average')

fig, ax = plt.subplots(figsize=(12, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

set_link_color_palette(['#F5276C', '#27D3F5', '#6CF527', '#F5B027'])

dn = dendrogram(Z, labels=genes, leaf_rotation=45, leaf_font_size=10,
                color_threshold=3.5, above_threshold_color='#555555', ax=ax)

ax.axhline(y=3.5, color='#F5276C', linestyle='--', linewidth=1.5, alpha=0.7)
ax.text(0.5, 3.7, 'Cluster Threshold', color='#F5276C', fontsize=9)

ax.set_title('Gene Expression Clustering', color='white', fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Genes', color='#888888', fontsize=11)
ax.set_ylabel('Euclidean Distance', color='#888888', fontsize=11)

ax.tick_params(axis='both', colors='white', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support