Human Intestinal Absorption (HIA) Score Distribution Dashboard

DrugBank database
MolPort database
Python script number 19 to build the frequency distribution graph of the HIA 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. HIA Data (Probability/Fraction)
x = [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 in %
y = [1.33, 2.95, 3.36, 2.31, 1.33, 1.38, 1.54, 1.17, 1.09, 1.33, 
     1.70, 2.22, 2.27, 2.47, 3.16, 3.56, 5.74, 10.56, 24.43, 26.09]

# 2. Curve smoothing (Spline)
# We use a reduced list of points for the spline to avoid oscillations at low values
x_smooth = np.linspace(min(x), max(x), 300)
spl = make_interp_spline(x, y, k=3) 
y_smooth = spl(x_smooth)
y_smooth = [val if val > 0 else 0 for val in y_smooth]

# 3. Define colors (HIA Traffic Light)
colors = []
for val in x:
    # High Absorption (> 0.7) - Zone of Excellence
    if val >= 0.7:
        colors.append('green')
    # Poor Absorption (< 0.3) - Study Criteria
    elif val < 0.3:
        colors.append('firebrick')
    # Intermediate Zone (Meets criteria >30% but it is low)
    else:
        colors.append('gold')

# 4. Create the chart
plt.figure(figsize=(7, 6))

# A. Draw Bars
plt.bar(x, y, width=0.04, color=colors, edgecolor='black', alpha=0.7, label='Data Frequency')

# 5. Tags and Titles
plt.xlabel('Human Intestinal Absorption (HIA) Score [0-1]', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('HIA Distribution', fontsize=14)

# Adjust axes
plt.xticks(np.arange(0, 1.1, 0.1))
plt.xlim(0, 1.05)
plt.ylim(0, 30)

# 6. Custom Legend (Vertical)
legend_elements = [
    Patch(facecolor='green', edgecolor='black', alpha=0.7, label='Excellent Absorption (> 0.7)'),
    Patch(facecolor='gold', edgecolor='black', alpha=0.7, label='Passed Threshold (0.3 - 0.7)'),
    Patch(facecolor='firebrick', edgecolor='black', alpha=0.7, label='Poor Absorption (< 0.3)'),
]

plt.legend(handles=legend_elements, loc='upper left', ncol=1, framealpha=0.9)

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

plt.show()