MDCK Permeability Probability Distribution Dashboard

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

# 1. MDCK Data (Probability)
bin_centers = [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]

frequencies = [0.04, 1.05, 2.95, 4.98, 6.76, 8.98, 9.83, 9.22, 7.56, 6.27, 
               6.63, 6.51, 6.19, 5.50, 6.84, 7.12, 2.51, 0.97, 0.08]

# 2. Gaussian Fit Parameters
amplitude = 8.547
mean = 0.4717
sd = 0.2530

# Generate smooth X data for the curve
x_smooth = np.linspace(0, 1, 300)

# Calculate Y using the Gaussian equation
y_smooth = amplitude * np.exp(-0.5 * ((x_smooth - mean) / sd)**2)

# 3. Define colors (MDCK Traffic Light - Probability)
colors = []
for x in bin_centers:
    # High Permeability (Probability > 0.6)
    if x >= 0.6:
        colors.append('green')
    # Low Permeability (Probability < 0.4)
    elif x <= 0.4:
        colors.append('firebrick')
    # Middle/Uncertain Zone (0.4 - 0.6) - Where the average falls
    else:
        colors.append('gold')

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

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

# B. Draw Trend Line
plt.plot(x_smooth, y_smooth, color='darkorange', linewidth=2, label='Gaussian Fit')

# 5. Tags and Titles
plt.xlabel('MDCK Permeability Probability (0=Low, 1=High)', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('MDCK Permeability Distribution', fontsize=14)

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

# 6. Custom Legend (Vertical)
legend_elements = [
    Line2D([0], [0], color='darkorange', lw=2, label=f'Fit (Mean={mean}, SD={sd})'),
    Patch(facecolor='green', edgecolor='black', alpha=0.7, label='High Permeability Prob (> 0.6)'),
    Patch(facecolor='gold', edgecolor='black', alpha=0.7, label='Intermediate/Uncertain (0.4 - 0.6)'),
    Patch(facecolor='firebrick', edgecolor='black', alpha=0.7, label='Low/Medium Permeability Prob (< 0.4)')
]

plt.legend(handles=legend_elements, loc='upper right', ncol=1)
plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()

plt.show()