Correlogram

Genomic Expression Patterns

Gene expression correlogram across tissue types with KDE distributions

Output
Genomic Expression Patterns
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(789)

n = 140
tissues = np.random.choice(['Brain', 'Liver', 'Heart'], n)
data = {
    'Gene A': np.where(tissues == 'Brain', np.random.normal(8, 2, n),
                      np.where(tissues == 'Liver', np.random.normal(4, 1.5, n), np.random.normal(6, 1.8, n))),
    'Gene B': np.where(tissues == 'Brain', np.random.normal(5, 1.5, n),
                      np.where(tissues == 'Liver', np.random.normal(9, 2, n), np.random.normal(3, 1, n))),
    'Gene C': np.random.normal(6, 2, n) + np.random.uniform(-1, 1, n),
    'Gene D': np.random.normal(7, 1.8, n),
    'Tissue': tissues
}
df = pd.DataFrame(data)

plt.style.use('dark_background')
sns.set_style("darkgrid", {'axes.facecolor': '#0a0a0f', 'figure.facecolor': '#0a0a0f', 'grid.color': '#333333'})

palette = {'Brain': '#5314E6', 'Liver': '#C82909', 'Heart': '#F5276C'}

g = sns.pairplot(
    df,
    hue='Tissue',
    palette=palette,
    height=2,
    kind='kde',
    diag_kind='kde',
    plot_kws={'alpha': 0.6, 'levels': 5, 'linewidths': 1.5},
    diag_kws={'alpha': 0.5, 'linewidth': 2.5, 'fill': True}
)

g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
    if ax:
        ax.set_facecolor('#0a0a0f')
        for spine in ax.spines.values():
            spine.set_color('#333333')
        ax.tick_params(colors='#888888')
        ax.xaxis.label.set_color('white')
        ax.yaxis.label.set_color('white')

g.fig.suptitle('Tissue-Specific Gene Expression', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.setp(g._legend.get_title(), color='white')
plt.setp(g._legend.get_texts(), color='white')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support