Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSP_Rank/plot_structure_similarity_metrics_AF3.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (54 sloc)
2.38 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from util import * | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from matplotlib.gridspec import GridSpec | |
from mpl_toolkits.axes_grid1 import make_axes_locatable | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from matplotlib.gridspec import GridSpec | |
import os | |
csv_file = './CSPRANK.csv' | |
x_col = 'AF3_DockQ_top_rank' | |
y_col = 'AF3_TM' | |
# Read data from CSV | |
df = pd.read_csv(csv_file) | |
fig = plt.figure(figsize=(8, 8)) | |
gs = GridSpec(4, 4, figure=fig) | |
# Axes definitions | |
ax_scatter = fig.add_subplot(gs[1:4, 0:3]) | |
ax_histx = fig.add_subplot(gs[0, 0:3], sharex=ax_scatter) | |
ax_histy = fig.add_subplot(gs[1:4, 3], sharey=ax_scatter) | |
# Scatter plot | |
ax_scatter.scatter(df[x_col], df[y_col], alpha=0.6, edgecolors='k') | |
ax_scatter.set_xlabel('AF3 DockQ') | |
ax_scatter.set_ylabel('AF3 TM') | |
ax_scatter.set_xlim(0, 1) | |
ax_scatter.set_ylim(0, 1) | |
# Add dashed red lines | |
ax_scatter.axhline(y=0.8, color='red', linestyle='--') | |
ax_scatter.axvline(x=0.4, color='red', linestyle='--') | |
# Shade the region x > 0.4 and y > 0.8 a light gray | |
ax_scatter.fill_betweenx(y=[0.8, 1], x1=0.4, x2=1, color='gray', alpha=0.3) | |
# Histograms | |
ax_histx.hist(df[x_col], bins=30, alpha=0.7, color='blue') | |
ax_histy.hist(df[y_col], bins=30, orientation='horizontal', alpha=0.7, color='blue') | |
# Turn off tick labels on hist plots for clarity | |
plt.setp(ax_histx.get_xticklabels(), visible=False) | |
plt.setp(ax_histy.get_yticklabels(), visible=False) | |
# Adjust spacing around subplots to make space for labels | |
plt.subplots_adjust(hspace=0.05, wspace=0.05) | |
# Save the plot | |
output_dir = './Figures' | |
os.makedirs(output_dir, exist_ok=True) | |
output_file = os.path.join(output_dir, 'structure_similarity_metrics_plot.png') | |
plt.savefig(output_file) | |
# Calculate the percentage of entries with AF3_TM > 0.8 | |
percent_AF3_TM_gt_0_8 = (df['AF3_TM'] > 0.8).mean() * 100 | |
print(f"Percentage of entries with AF3_TM > 0.8: {percent_AF3_TM_gt_0_8:.2f}%") | |
# Calculate the percentage of entries with AF3_DockQ_top_rank > 0.4 | |
percent_AF3_DockQ_gt_0_4 = (df['AF3_DockQ_top_rank'] > 0.4).mean() * 100 | |
print(f"Percentage of entries with AF3_DockQ_top_rank > 0.4: {percent_AF3_DockQ_gt_0_4:.2f}%") | |
# Calculate the percentage of entries with both conditions | |
percent_both_conditions = ((df['AF3_TM'] > 0.8) & (df['AF3_DockQ_top_rank'] > 0.4)).mean() * 100 | |
print(f"Percentage of entries with both AF3_TM > 0.8 and AF3_DockQ_top_rank > 0.4: {percent_both_conditions:.2f}%") |