<jupyter_start><jupyter_text>***Copyright 2021 Novartis Institutes for BioMedical Research Inc.Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.***  Profile-QSAR performance<jupyter_code>import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
pqsar_summary = '../chembl_28/Summary_pQSAR/SummaryPQSAR.csv'
df = pd.read_csv(pqsar_summary, index_col=0, header=0, sep=',')
df.head(2)<jupyter_output><empty_output><jupyter_text>Key columns in the summary file * CDS_ID: Assay ID * Count(molecules): count (should be >50)* Actives(>=6): no. actives 6)* std(pIC50): Standard deviation of assay data, a measure of dynamic range. (should be >0.5)* R^2_RF(ext): correlation with experiment of single-assay random forest regression model based on realistic test sets for comparison to pQSAR* R^2_RF(random): correlation with experiment of single-assay random forest regression model based on random split test sets for comparison to pQSAR* Q2orig: pQSAR 5x cross-validated R2 on random test set. This is good for near analogs of training set (should be >0.3, but less can be OK)* R2ext: pQSAR R2 on realistic test set. This is most important for novel chemistry (best if >0.3)* Stdev_pred:  standard deviation of 5.5M predictions used for Z-scaling* mean_pred:  mean of 5.5M predictions used for Z-scaling<jupyter_code>def rank_order_plot(df):
    colors = ['k', 'r', 'b', 'lime', 'y', 'm', 'g']
    font = {'family': 'normal', 'weight': 'normal', 'size': 20}
    matplotlib.rc('font', **font)
    plt.figure(figsize=(9.0, 6.0))
    plt.style.use('seaborn-whitegrid')
    cols_name = list(df.columns)
    for i, col in enumerate(cols_name):
        plt.plot(range(len(df[col])), df[col].sort_values(ascending=False), lw=1.5, linestyle='-', color=colors[i], label=col)

    plt.grid(which='major', axis='both', linestyle='--')
    axes = plt.gca()
    axes.set_ylim(0, 1)
    axes.set_xlim(0, int(len(df) * 1.02))
    axes.legend(loc='best', prop={'size': 12})

    plt.ylabel('$R^2_{ext}$')
    plt.xlabel('ChEMBL ({} assays)'.format(len(df)))
    plt.tight_layout()
def r2_stats(df):
    cols = list(df.columns)
    num = len(df)
    stat = pd.DataFrame(0.0, index=cols, columns = ['%R2ext>0.30', '#R2ext>0.30','median R2ext'])
    for c in cols:
        stat.loc[c, '#R2ext>0.30'] = sum(df[c] >= 0.30)
        stat.loc[c, '%R2ext>0.30'] = sum(df[c] >= 0.30) / num
        stat.loc[c, 'median R2ext'] = df[c].median()
    return(stat)<jupyter_output><empty_output><jupyter_text>Comparing pQSAR(R2ext) with random forest models<jupyter_code>df_subset = df[['R^2_RF(ext)', 'R^2_RF(random)', 'Q2orig', 'R2ext']]
rank_order_plot(df_subset)
r2_stats(df_subset)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13972689742775485, 'fraction_numerical': 0.02731025722451572, 'mean_word_length': 4.921052631578948, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '437521', 'license': 'Apache-2.0', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1070, 'n_words': 319, 'path': 'tests/pQSAR_tests.ipynb', 'repo_name': 'ichxw/pQSAR', 'size': '3149'}