3D Scatter

DNA Methylation vs Gene Expression

Genomic visualization of DNA methylation sites and their correlation with gene expression.

Output
DNA Methylation vs Gene Expression
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(654)

# Methylation sites on chromosome
n_sites = 200

# Position along chromosome
position = np.sort(np.random.uniform(0, 100, n_sites))  # Mbp

# Methylation level (beta value 0-1)
methylation = np.random.beta(2, 5, n_sites)

# Expression correlation
expression = -0.5 * methylation + np.random.normal(0, 0.2, n_sites) + 0.5

fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')

scatter = ax.scatter(position, methylation, expression, c=methylation, 
                     cmap='RdYlGn_r', s=40, alpha=0.7, edgecolors='none')

ax.set_xlabel('Position (Mbp)', color='white', fontsize=10)
ax.set_ylabel('Methylation (β)', color='white', fontsize=10)
ax.set_zlabel('Expression', color='white', fontsize=10)
ax.set_title('DNA Methylation vs Gene Expression', color='white', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')

ax.view_init(elev=20, azim=35)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support