Gregory Way, 2018
The figures consist of TP53 classifier scores stratified by TP53 inactivation status and cancer-type.
There are two sets of plots generated:
In [1]:
import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
%matplotlib inline
plt.style.use('seaborn-notebook')
In [3]:
sns.set(style='white')
sns.set_context('paper', rc={'font.size':16, 'axes.titlesize':11, 'axes.labelsize':20,
'xtick.labelsize':18, 'ytick.labelsize':14})
In [4]:
def random_guess_line(**kwargs):
plt.axhline(y=0.5, color='k', ls='dashed', linewidth=0.7)
In [5]:
# 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)
Out[5]:
In [6]:
extreme_types = ['OV', 'UCS', 'THCA', 'UVM']
extreme_df = prediction_df[prediction_df['DISEASE'].isin(extreme_types)]
In [7]:
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');
In [8]:
brca_df = prediction_df[prediction_df['DISEASE'] == 'BRCA']
ucec_df = prediction_df[prediction_df['DISEASE'] == 'UCEC']
In [9]:
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()
In [10]:
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')
In [11]:
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')