<jupyter_start><jupyter_text>Plots to generate supplementary figures for TP53 classifier figure**<NAME>, 2018**The figures consist of TP53 classifier scores stratified by TP53 inactivation status and cancer-type.There are two sets of plots generated:1. Cancer-types for which TP53 loss of function events are on either extreme of proportions.  * OV and UCS have a high percentage of TP53 loss events  * THCA and UVM have a low percentage of TP53 loss events  * The figure demonstrates that even in cancer-types with extreme values (and that they were not even included in model training) the classifier can detect TP53 inactivation2. Cancer-types for which TP53 loss events are enriched in specific subtypes.  * Basal BRCA subtype tumors often have TP53 mutations  * UCEC subtypes have different proportions of TP53 loss events as well.  * The figure shows how subtype assignments do not confound TP53 classifier predictions within cancer-types<jupyter_code>import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.style.use('seaborn-notebook')
sns.set(style='white')
sns.set_context('paper', rc={'font.size':16, 'axes.titlesize':11, 'axes.labelsize':20,
                             'xtick.labelsize':18, 'ytick.labelsize':14})
def random_guess_line(**kwargs):
    plt.axhline(y=0.5, color='k', ls='dashed', linewidth=0.7)
# The prediction file stores the TP53 classifier scores for all samples
prediction_file = os.path.join('..', 'classifiers', 'TP53', 'tables',
                               'mutation_classification_scores.tsv')
prediction_df = pd.read_table(prediction_file, index_col=0)
prediction_df.head(2)<jupyter_output><empty_output><jupyter_text>Predictions for cancer-types with extreme proportions of TP53 loss of function events* Samples that are heavily TP53 mutated or copy number lost: OV, UCS* Samples that are heavily TP53 wild-type: THCA, UVMNote that these samples were not used in training the classifier.<jupyter_code>extreme_types = ['OV', 'UCS', 'THCA', 'UVM']
extreme_df =  prediction_df[prediction_df['DISEASE'].isin(extreme_types)]
figure_name = os.path.join('..', 'figures', 'TP53_opposite_spectrum_cancertypes.pdf')
plt.figure(figsize=(2, 6))
g = sns.factorplot(x='total_status', y='weight', col='DISEASE', data=extreme_df,
                   palette="hls", col_order=extreme_types, kind='strip', jitter=0.4,
                   alpha=0.8)
g.map(random_guess_line)
(g.set_axis_labels('', 'TP53 Classifier Score')
  .set_xticklabels(['Wild Type', 'Other'])
  .set_titles("{col_name}")
  .set(ylim=(0, 1)))
plt.tight_layout()
plt.savefig(figure_name, dpi=600, bbox_inchex='tight');<jupyter_output><empty_output><jupyter_text>Predictions for cancer-types that have differential proportions of TP53 alterations according to subtypeThese include: BRCA and UCEC<jupyter_code>brca_df =  prediction_df[prediction_df['DISEASE'] == 'BRCA']
ucec_df =  prediction_df[prediction_df['DISEASE'] == 'UCEC']
def plot_subtype(df, title):
    ax = sns.stripplot(x='SUBTYPE', y='weight', hue='total_status',
                   data=df,  dodge=True,
                   palette='hls', edgecolor='black',
                   jitter=0.3, alpha=0.8)
    plt.axhline(0.5, color='black', linestyle='dashed', linewidth=1)
    ax.set_ylabel('TP53 Classifier Score')
    ax.legend_.remove()
    ax.set_title(title, size=19)
    sns.despine()
    plt.tight_layout()
brca_file_name = os.path.join('..', 'figures', 'TP53_BRCA_subtype_confounding.pdf')
plot_subtype(brca_df, 'BRCA')
plt.savefig(brca_file_name, dpi=600, bbox_inchex='tight')
ucec_file_name = os.path.join('..', 'figures', 'TP53_UCEC_subtype_confounding.pdf')
plot_subtype(ucec_df, 'UCEC')
plt.savefig(ucec_file_name, dpi=600, bbox_inchex='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11823700184745316, 'fraction_numerical': 0.0242808128793877, 'mean_word_length': 5.054313099041534, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '39642', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1220, 'n_words': 327, 'path': 'scripts/tp53_ddr_cancertype_subtypes.ipynb', 'repo_name': 'nvk747/pancancer', 'size': '3794'}