"""SCI Figure Hub — Differential Expression Volcano Plot (CC0-1.0)""" PALETTE = ["#E64B35", "#3C5488", "#CBD5E1"] import numpy as np import matplotlib.pyplot as plt UP_COL, DOWN_COL, NS_COL = PALETTE[0], PALETTE[1], PALETTE[2] plt.rcParams.update({"font.sans-serif": ["Arial", "DejaVu Sans"], "font.size": 8, "axes.spines.top": False, "axes.spines.right": False, "pdf.fonttype": 42}) rng = np.random.default_rng(31) n = 600 lfc = rng.normal(0, 1.4, n) nlp = -np.log10(np.clip(10 ** (-np.abs(lfc) * rng.uniform(0.4, 2.2, n) - rng.uniform(0, 1.2, n)), 1e-12, 1)) up = (lfc >= 1.0) & (nlp >= 1.301) down = (lfc <= -1.0) & (nlp >= 1.301) ns = ~(up | down) fig, ax = plt.subplots(figsize=(3.5, 2.75), dpi=300) ax.scatter(lfc[ns], nlp[ns], s=8, color=NS_COL, alpha=0.65, edgecolors="none", label=f"NS ({ns.sum()})") ax.scatter(lfc[down], nlp[down], s=11, color=DOWN_COL, alpha=0.85, edgecolors="none", label=f"Down ({down.sum()})") ax.scatter(lfc[up], nlp[up], s=11, color=UP_COL, alpha=0.85, edgecolors="none", label=f"Up ({up.sum()})") ax.axvline(-1.0, ls="--", lw=0.75, color="#64748B") ax.axvline(1.0, ls="--", lw=0.75, color="#64748B") ax.axhline(1.301, ls="--", lw=0.75, color="#64748B") for gx, gy, name in [(3.1, 7.2, "CXCL10"), (2.5, 5.8, "ISG15"), (-2.9, 6.4, "KRT14")]: ax.annotate(name, (gx, gy), xytext=(4, 4), textcoords="offset points", fontsize=6.5, fontweight="bold") ax.set_xlabel("log2(Fold Change)") ax.set_ylabel("-log10(Adjusted P-value)") ax.legend(frameon=False, loc="upper left", markerscale=1.4) fig.tight_layout() fig.savefig("volcano_plot.pdf", bbox_inches="tight")