3D Scatter

Differential Gene Expression Analysis

RNA-Seq differential expression comparing two treatments with significance highlighting in neon coral.

Output
Differential Gene Expression Analysis
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Gene expression data
n_genes = 250

# Three conditions
log2fc_1 = np.random.normal(0, 2, n_genes)
log2fc_2 = np.random.normal(0.5, 2, n_genes)
pvalue = np.random.exponential(0.1, n_genes)
pvalue = np.clip(pvalue, 0.0001, 1)

# Significance coloring
significant = (np.abs(log2fc_1) > 1.5) & (pvalue < 0.05)
colors = ['#F5276C' if s else '#94a3b8' for s in significant]
sizes = [60 if s else 25 for s in significant]

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

ax.scatter(log2fc_1, log2fc_2, -np.log10(pvalue), c=colors, s=sizes, 
           alpha=0.7, edgecolors='white', linewidths=0.3)

ax.set_xlabel('log₂FC (Treatment A)', color='#1f2937', fontsize=10)
ax.set_ylabel('log₂FC (Treatment B)', color='#1f2937', fontsize=10)
ax.set_zlabel('-log₁₀(p-value)', color='#1f2937', fontsize=10)
ax.set_title('Differential Gene Expression Analysis', color='#1f2937', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')

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

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support