hERG Cardiotoxicity (10-30 μM) Prediction Dashboard

DrugBank database
MolPort database
Python script number 62 to build the frequency distribution graph of the hERG_10_30uM parameter on DrugBank molecules.
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import numpy as np
from scipy.interpolate import make_interp_spline

# 1. Original Data (hERG Blocker Probability, hERG_10_30uM)
bin_centers = np.array([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1])
frequencies = np.array([4.54, 10.28, 10.53, 7.35, 3.18, 2.55, 2.34, 2.59, 2.00, 1.95, 2.25, 1.61, 1.83, 3.10, 2.34, 2.76, 2.68, 4.42,
                       5.90, 11.59, 14.23])

# 2. Generate the smoothed curve (Spline)
x_smooth = np.linspace(min(bin_centers), max(bin_centers), 300)
spl = make_interp_spline(bin_centers, frequencies, k=3)
y_smooth = spl(x_smooth)
y_smooth = np.clip(y_smooth, 0, None)

# 3. Hexadecimal Colors
color_safe = '#008000'
color_warn = '#FFD700'
color_danger = '#B22222'

colors = []
for val in bin_centers:
    if val < 0.3:
        colors.append(color_safe)
    elif val < 0.7:
        colors.append(color_warn)
    else:
        colors.append(color_danger)

# 4. Create the graph (7x6 Style)
plt.figure(figsize=(7, 6))

# Bars
plt.bar(bin_centers, frequencies, width=0.04, color=colors, edgecolor='black', alpha=0.7, label='Observed Data')

# 5. Tags and Titles
plt.xlabel('Probability of hERG Blockade', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('hERG Cardiotoxicity 10-30 uM Distribution', fontsize=14)

# Axle settings
plt.xticks(np.arange(0.0, 1.05, 0.1))
plt.xlim(-0.05, 1.05)
plt.ylim(0, 42)

# 6. Legend
legend_elements = [
    Patch(facecolor=color_safe, edgecolor='black', label='Low Risk (Acceptable)'),
    Patch(facecolor=color_warn, edgecolor='black', label='Moderate Risk (Monitor)'),
    Patch(facecolor=color_danger, edgecolor='black', label='High Risk (Arrhythmia)'),
]

plt.legend(handles=legend_elements, loc='upper right', framealpha=0.95, fontsize=10)

plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()

plt.show()