Plasma Protein Binding (PPB) Ratio Dashboard

DrugBank database
MolPort database
Python script number 35 to build the frequency distribution graph of the PPB 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. PPB data
x = [-0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 
     0.6, 0.7, 0.8, 0.9, 1, 1.1]

y = [0.12, 0.77, 2.06, 2.79, 3.32, 5.50, 4.98, 5.02, 6.92, 5.91, 
     6.88, 8.17, 13.59, 20.99, 11.85, 1.13]

# 2. Smoothing
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. Colors
colors = []
for val in x:
    if val >= 0.7:
        colors.append('green')
    elif val <= 0.2:
        colors.append('firebrick')
    else:
        colors.append('gold')

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

# Bars and Line
plt.bar(x, y, width=0.08, color=colors, edgecolor='black', alpha=0.7, label='Data Frequency')

# 5. Tags
plt.xlabel('Plasma Protein Binding (PPB) Ratio', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('PPB Distribution', fontsize=14)

# Axle settings
plt.xticks(np.arange(-0.4, 1.2, 0.1))
plt.xlim(-0.5, 1.2)
plt.ylim(0, 23)

# 6. LEGEND (Top left)
legend_elements = [
    Patch(facecolor='green', edgecolor='black', alpha=0.7, label='High Binding (> 70%) - Depot Effect'),
    Patch(facecolor='gold', edgecolor='black', alpha=0.7, label='Moderate Binding (20% - 70%)'),
    Patch(facecolor='firebrick', edgecolor='black', alpha=0.7, label='Low Binding (< 20%) - Rapid Clearance')
]

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

# 7. EXPLANATORY TEXT
plt.text(-0.45, 17.5, '* Values < 0 and > 1 are regression model artifacts\nrepresenting 0% and 100% extremes.', 
         fontsize=9, style='italic', bbox=dict(facecolor='white', alpha=0.8, edgecolor='gray'))

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

plt.show()