|
import pandas as pd |
|
import numpy as np |
|
|
|
def combine_csv_files(csv_file_list): |
|
|
|
combined_df = pd.concat([pd.read_csv(file) for file in csv_file_list], ignore_index=True) |
|
|
|
|
|
combined_df = combined_df.drop_duplicates(subset=['seq', 'smiles_can', 'neg_log10_affinity_M']) |
|
|
|
|
|
combined_df = combined_df.groupby(['seq', 'smiles_can']).agg( |
|
neg_log10_affinity_M=('neg_log10_affinity_M', 'mean') |
|
).reset_index() |
|
|
|
np.random.seed(42) |
|
mask_value_5 = combined_df['neg_log10_affinity_M'] == 5 |
|
rows_to_keep = ~mask_value_5 | (mask_value_5 & (np.random.rand(len(combined_df)) < 0.3)) |
|
combined_df = combined_df[rows_to_keep].reset_index(drop=True) |
|
|
|
|
|
combined_df = combined_df.sort_values('neg_log10_affinity_M', ascending=False) |
|
|
|
|
|
affinity_mean = combined_df['neg_log10_affinity_M'].mean() |
|
affinity_std = combined_df['neg_log10_affinity_M'].std() |
|
|
|
|
|
combined_df['affinity_mean'] = affinity_mean |
|
combined_df['affinity_std'] = affinity_std |
|
combined_df['affinity_norm'] = (combined_df['neg_log10_affinity_M'] - affinity_mean) / affinity_std |
|
|
|
return combined_df |
|
|
|
combined_df = combine_csv_files(['glaser.parquet', 'davis-filtered.parquet', 'pdbbind-2020-combined.parquet', 'bindingdb-kd-filtered.parquet', 'bindingdb-ki.parquet', 'bindingdb-ic50.parquet']) |
|
combined_df.to_parquet('affinity-data-combined.parquet', index=False) |