Skip to content
Permalink
b9fe25bf2d
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
56 lines (48 sloc) 2.33 KB
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# Load the updated CSV file
df = pd.read_csv('./csp_stats.csv')
# List of columns to plot for histograms
columns_to_plot_af2 = ["AF2_Most_favoured", "AF2_Allowed", "AF2_Disallowed"]
columns_to_plot_nmr = ["NMR_Most_favoured", "NMR_Allowed", "NMR_Disallowed"]
suffix = '_trim'
fontsize_t = 16
# List of columns to plot for histograms
columns_to_plot = columns_to_plot_nmr + columns_to_plot_af2
# Setting up the figure and subplots in a 2x2 grid
fig, axs = plt.subplots(3, 3, figsize=(10, 10))
# Flatten the axs array for easier indexing
axs = axs.flatten()
for idx, column in enumerate(columns_to_plot):
axs[idx].hist(df[column+suffix].dropna(), bins=15, color='blue', alpha=0.7)
#axs[idx].set_title(f'Histogram of {column}', fontsize=14)
axs[idx].set_xlabel(column.replace('NMR','PDB').replace('_',' '), fontsize=fontsize_t)
axs[idx].set_ylabel('Frequency', fontsize=fontsize_t)
if 'Disallowed' in column:
axs[idx].set_xlim(0,12)
elif 'Allowed' in column:
axs[idx].set_xlim(0,30)
elif 'favoured' in column:
axs[idx].set_xlim(65,100)
#axs[idx].set_xlim(-10, 3)
# Creating scatter plots comparing AF2 and NMR data
for idx, (nmr_col, af2_col) in enumerate(zip(columns_to_plot_nmr, columns_to_plot_af2)):
scatter_idx = idx + 6 # Scatter plots will be the last two plots in the grid
sns.scatterplot(ax=axs[scatter_idx], x=df[nmr_col+suffix], y=df[af2_col+suffix])
#axs[scatter_idx].set_title(f'Scatter plot of {af2_col} vs {nmr_col}', fontsize=14)
axs[scatter_idx].set_xlabel(nmr_col.replace('NMR', 'PDB').replace('_', ' '), fontsize=fontsize_t)
axs[scatter_idx].set_ylabel(af2_col.replace('_',' '), fontsize=fontsize_t)
axs[scatter_idx].plot([df[nmr_col+suffix].min(), df[nmr_col+suffix].max()], [df[nmr_col+suffix].min(), df[nmr_col+suffix].max()], color='red', linestyle='--') # y=x line for reference
if 'Disallowed' in nmr_col:
axs[scatter_idx].set_xlim(0,12)
axs[scatter_idx].set_ylim(0,12)
elif 'Allowed' in nmr_col:
axs[scatter_idx].set_xlim(0,30)
axs[scatter_idx].set_ylim(0,30)
elif 'favoured' in nmr_col:
axs[scatter_idx].set_xlim(65,100)
axs[scatter_idx].set_ylim(65,100)
# Adjust the layout to add more space between the plots
plt.tight_layout()
plt.show()