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/suplfig4.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
100 lines (84 sloc)
5.51 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
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
import numpy as np | |
# Load data for the other plots | |
CSmethod = "UCBShift" | |
data_source_file = './csp_stats_' + CSmethod + '.csv' | |
df = pd.read_csv(data_source_file) | |
# Setting up the figure and subplots | |
fig, axs = plt.subplots(2, 2, figsize=(20, 20), gridspec_kw={'height_ratios': [1, 1], 'width_ratios': [1, 1]}) | |
plt.subplots_adjust(hspace=0.4, wspace=0.4) # Increase spacing between subplots | |
# Calculate residuals for each pair | |
df['residual_2'] = df['F1_AF2'] - df['F1'] | |
sns.scatterplot(ax=axs[0, 0], x=df['F1'], y=df['F1_AF2']) | |
axs[0, 0].plot([0, 1], [0, 1], color='red') # y=x line | |
axs[0, 0].set_title('NMR vs AF2 F1 Scores', fontsize=20) | |
axs[0, 0].set_xlabel('PDB F1 Score', fontsize=20) | |
axs[0, 0].set_ylabel('AF2 F1 Score', fontsize=20) | |
axs[0, 0].text(0.7, 0.1, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[0, 0].transAxes) | |
axs[0, 0].text(0.1, 0.9, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[0, 0].transAxes) | |
# Histogram of residuals for consensus_AF2 | |
data = df['residual_2'] | |
max_abs_value = max(abs(data.min()), abs(data.max())) | |
symmetric_range = (-max_abs_value, max_abs_value) | |
bin_width = (symmetric_range[1] - symmetric_range[0]) / 20 | |
bins = np.arange(symmetric_range[0], symmetric_range[1] + bin_width, bin_width) | |
sns.histplot(ax=axs[0, 1], data=data, kde=True, bins=bins) | |
axs[0, 1].set_title('Histogram of Residuals for F1 Scores', fontsize=20) | |
axs[0, 1].set_xlabel('Residual', fontsize=20) | |
axs[0, 1].set_ylabel('Frequency', fontsize=20) | |
axs[0, 1].axvline(x=0.0, color='red', linestyle='-', linewidth=2) | |
axs[0, 1].text(0.7, 0.7, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[0, 1].transAxes) | |
axs[0, 1].text(0.05, 0.7, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[0, 1].transAxes) | |
# Load data for the other plots | |
# Calculate residuals for each pair | |
df['residual_2'] = df['MCC_AF2'] - df['MCC'] | |
sns.scatterplot(ax=axs[1, 0], x=df['MCC'], y=df['MCC_AF2']) | |
axs[1, 0].plot([-1, 1], [-1, 1], color='red') # y=x line | |
axs[1, 0].set_title('NMR vs AF2 MCCs', fontsize=20) | |
axs[1, 0].set_xlabel('PDB MCCs', fontsize=20) | |
axs[1, 0].set_ylabel('AF2 MCCs', fontsize=20) | |
axs[1,0].set_xlim((-1,1)) | |
axs[1,0].set_ylim((-1,1)) | |
axs[1, 0].text(0.7, 0.1, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[1, 0].transAxes) | |
axs[1, 0].text(0.1, 0.9, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[1, 0].transAxes) | |
# Histogram of residuals for consensus_AF2 | |
data = df['residual_2'] | |
max_abs_value = max(abs(data.min()), abs(data.max())) | |
symmetric_range = (-max_abs_value, max_abs_value) | |
bin_width = (symmetric_range[1] - symmetric_range[0]) / 20 | |
bins = np.arange(symmetric_range[0], symmetric_range[1] + bin_width, bin_width) | |
sns.histplot(ax=axs[1, 1], data=data, kde=True, bins=bins) | |
axs[1, 1].set_title('Histogram of Residuals for MCCs', fontsize=20) | |
axs[1, 1].set_xlabel('Residual', fontsize=20) | |
axs[1, 1].set_ylabel('Frequency', fontsize=20) | |
axs[1, 1].axvline(x=0.0, color='red', linestyle='-', linewidth=2) | |
axs[1, 1].text(0.7, 0.7, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[1, 1].transAxes) | |
axs[1, 1].text(0.05, 0.7, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[1, 1].transAxes) | |
if False: | |
# Calculate residuals for each pair | |
df['residual_2'] = df['consensus_AF2'] - df['consensus'] | |
sns.scatterplot(ax=axs[2, 0], x=df['consensus'], y=df['consensus_AF2']) | |
axs[2, 0].plot([0, 1], [0, 1], color='red') # y=x line | |
axs[2, 0].set_title('NMR vs AF2 CSP_Rank_Scores', fontsize=20) | |
axs[2, 0].set_xlabel('PDB CSP_Rank_Score', fontsize=20) | |
axs[2, 0].set_ylabel('AF2 CSP_Rank_Score', fontsize=20) | |
axs[2, 0].text(0.7, 0.1, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[2, 0].transAxes) | |
axs[2, 0].text(0.1, 0.9, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[2, 0].transAxes) | |
# Histogram of residuals for consensus_AF2 | |
data = df['residual_2'] | |
max_abs_value = max(abs(data.min()), abs(data.max())) | |
symmetric_range = (-max_abs_value, max_abs_value) | |
bin_width = (symmetric_range[1] - symmetric_range[0]) / 20 | |
bins = np.arange(symmetric_range[0], symmetric_range[1] + bin_width, bin_width) | |
sns.histplot(ax=axs[2, 1], data=data, kde=True, bins=bins) | |
axs[2, 1].set_title('Histogram of Residuals for CSP_Rank_Score', fontsize=20) | |
axs[2, 1].set_xlabel('Residual', fontsize=20) | |
axs[2, 1].set_ylabel('Frequency', fontsize=20) | |
axs[2, 1].axvline(x=0.0, color='red', linestyle='-', linewidth=2) | |
axs[2, 1].text(0.7, 0.7, 'AF2>PDB', color='red', fontweight='bold', fontsize=16, verticalalignment='bottom', horizontalalignment='left', transform=axs[2, 1].transAxes) | |
axs[2, 1].text(0.05, 0.7, 'PDB>AF2', color='red', fontweight='bold', fontsize=16, verticalalignment='top', horizontalalignment='left', transform=axs[2, 1].transAxes) | |
# Adjust spacing between subplots | |
plt.subplots_adjust(hspace=0.45, wspace=0.15) | |
plt.show() |