Caco-2 Permeability Distribution Dashboard

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

# 1. Caco-2 data (Log Papp cm/s)
bin_centers = [-7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1]
frequencies = [
    0.16, 1.86, 6.80, 12.18, 16.34, 22.01, 31.59, 
    6.51, 1.74, 0.65, 0.08, 0.04, 0.00, 0.04
]

# 2. Gaussian Fit Parameters
amplitude = 26.33
mean = -4.918
sd = 0.7392

# Generate smooth X data for the curve
x_smooth = np.linspace(-8, -0.5, 300)

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

# 3. Define colors (Log Papp Traffic Light)
colors = []
for x in bin_centers:
    # High Permeability (> -5.15)
    # Note: -5 is greater than -5.15, -4.5 is greater, etc.
    if x > -5.15:
        colors.append('green')
    # Low Permeability (< -6.0)
    elif x < -6.0:
        colors.append('firebrick')
    # Moderate (Between -6.0 and -5.15)
    else:
        colors.append('gold')

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

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

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

# 5. Tags and Titles
plt.xlabel('Caco-2 Log Papp (cm/s)', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('Caco-2 Permeability Distribution (Log Papp)', fontsize=14)

# Adjust axes
plt.xticks(np.arange(-8, 0, 0.5)) 
plt.xlim(-8, -0.5)

# 6. Custom Legend (Vertical)
legend_elements = [
    Line2D([0], [0], color='darkorange', lw=2.5, label=f'Fit (Mean={mean}, SD={sd})'),
    Patch(facecolor='green', edgecolor='black', alpha=0.7, label='High Permeability (> -5.15)'),
    Patch(facecolor='gold', edgecolor='black', alpha=0.7, label='Moderate (-6.0 to -5.15)'),
    Patch(facecolor='firebrick', edgecolor='black', alpha=0.7, label='Low Permeability (< -6.0)')
]

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

plt.show()