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/suplfig1.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (40 sloc)
2.5 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 | |
# Define the list of methods | |
CSmethods = [ 'UCBShift', 'SPARTA','ShiftX'] | |
# Setting up the figure and subplots | |
fig, axs = plt.subplots(len(CSmethods), 2, figsize=(10, 3 * len(CSmethods)), gridspec_kw={'height_ratios': [1] * len(CSmethods), 'width_ratios': [1, 1]}) | |
for idx, CSmethod in enumerate(CSmethods): | |
data_source_file = f'./csp_stats_{CSmethod}.csv' | |
df = pd.read_csv(data_source_file) | |
# Calculate residuals for each pair | |
df['residual_1'] = df['F1_AF2'] - df['F1'] | |
df['residual_2'] = df['MCC_AF2'] - df['MCC'] | |
df['residual_3'] = df['consensus_AF2'] - df['consensus'] | |
# Scatter plot for consensus vs consensus_AF2 | |
sns.scatterplot(ax=axs[idx, 0], x=df['consensus'], y=df['consensus_AF2']) | |
axs[idx, 0].plot([0, 1], [0, 1], color='red') # y=x line | |
axs[idx, 0].set_title(f'PDB vs AF2 {CSmethod} CSP_Rank_Scores', fontsize=14) | |
axs[idx, 0].set_xlabel('PDB Score', fontsize=12) | |
axs[idx, 0].set_ylabel('AF2 Score', fontsize=12) | |
axs[idx, 0].text(0.7, 0.1, 'PDB>AF2', color='red', fontweight='bold', fontsize=12, verticalalignment='bottom', horizontalalignment='left', transform=axs[idx, 0].transAxes) | |
axs[idx, 0].text(0.1, 0.9, 'AF2>PDB', color='red', fontweight='bold', fontsize=12, verticalalignment='top', horizontalalignment='left', transform=axs[idx, 0].transAxes) | |
# Histogram of residuals for consensus_AF2 | |
data = df['residual_3'] | |
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[idx, 1], data=data, kde=True, bins=bins) | |
axs[idx, 1].set_title(f'Histogram of Residuals for {CSmethod} CSP_Rank_Score', fontsize=14) | |
axs[idx, 1].set_xlabel('Residual', fontsize=12) | |
axs[idx, 1].set_ylabel('Frequency', fontsize=12) | |
axs[idx, 1].axvline(x=0.0, color='red', linestyle='-', linewidth=2) | |
axs[idx, 1].text(0.7, 0.7, 'AF2>PDB', color='red', fontweight='bold', fontsize=12, verticalalignment='bottom', horizontalalignment='left', transform=axs[idx, 1].transAxes) | |
axs[idx, 1].text(0.05, 0.7, 'PDB>AF2', color='red', fontweight='bold', fontsize=12, verticalalignment='top', horizontalalignment='left', transform=axs[idx, 1].transAxes) | |
# Adjust the layout to add more space between the plots | |
plt.subplots_adjust(hspace=0.5) | |
plt.tight_layout() | |
plt.show() |