Skin Irritation (H315) Profile Dashboard

DrugBank database
MolPort database
Python script number 68 to build the frequency distribution graph of the Skin_irritation parameter on DrugBank molecules.
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import numpy as np

# 1. Original Data (Skin Irritation H315)
bin_centers = [0.0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40,0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95]
frequencies = [0.12, 3.44, 6.88, 7.28, 6.96, 7.77, 8.05, 7.69, 7.93,6.80, 7.85, 5.91, 4.53, 4.69, 3.40, 3.40, 2.35, 1.90, 2.02, 1.05]

# 2. Gaussian parameters
amp = 8.122
mean = 0.3617
std_dev = 0.2664

# 3. Generate Gaussian curve
x_fit = np.linspace(0, 1, 500)
y_fit = amp * np.exp(-((x_fit - mean)**2) / (2 * std_dev**2))

# 4. Colors
colors = []
for val in bin_centers:
    if val < 0.3:
        colors.append('green')
    elif val < 0.7:
        colors.append('gold')
    else:
        colors.append('firebrick')

# 5. Create figure
plt.figure(figsize=(7, 6))

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

# Gaussian fit (FIX aplicado aquí)
plt.plot(
    x_fit,
    y_fit,
    color='orange',
    linewidth=2,
    label=rf'Gaussian Fit\n($\mu$={mean:.4f}, $\sigma$={std_dev:.4f})'
)

# 6. Labels and title
plt.xlabel('Probability of Skin Irritation (H315)', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('Skin Irritation Distribution', fontsize=14)

# Axes
plt.xticks(np.arange(0.0, 1.05, 0.1))
plt.xlim(0.0, 1.0)
plt.ylim(0, 10)

# 7. Legend
legend_elements = [
    Patch(facecolor='green', edgecolor='black', label='Safe'),
    Patch(facecolor='gold', edgecolor='black', label='Mild Irritation'),
    Patch(facecolor='firebrick', edgecolor='black', label='Irritant Hazard'),
    plt.Line2D([0], [0], color='orange', lw=2.5, label=f'Fit (Mean={mean}, SD={std_dev})')]

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

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

plt.show()