Skip to content

Commit

Permalink
Merge pull request #92 from jjc2718/figures_final
Browse files Browse the repository at this point in the history
Larger figure fonts for publication
  • Loading branch information
jjc2718 authored Jul 1, 2022
2 parents f0406fa + 41d2521 commit 2277fc9
Show file tree
Hide file tree
Showing 14 changed files with 21,014 additions and 18,493 deletions.
232 changes: 132 additions & 100 deletions 00_download_data/3_sample_intersection.ipynb

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions 00_download_data/nbconverted/3_sample_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@


# map data types to readable names
# TODO: store this somewhere central
data_map = {
'expression': 'gene expression',
'me_27k': '27k methylation',
'me_450k': '450k methylation',
'expression': 'expression',
'me_27k': '27k',
'me_450k': '450k',
'rppa': 'RPPA',
'mirna': 'microRNA',
'mut_sigs': 'mut sigs',
'mut_sigs': 'mut. sigs',
}

# get sample list for each -omics data type
Expand Down Expand Up @@ -115,12 +114,11 @@ def series_from_samples(samples, labels):
# In[8]:


# probably stick with venn diagram here
sns.set({'figure.figsize': (8, 10)})
sns.set_style('white')

# get only sample lists from gene expression and mutation
labels = ['gene expression', 'mutation']
labels = ['expression', 'mutation']
label_map = {l: sample_lists[l] for l in labels}

venn(label_map)
Expand All @@ -133,7 +131,7 @@ def series_from_samples(samples, labels):


sns.set_style('white')
labels = ['gene expression', 'mutation', '27k methylation', '450k methylation']
labels = ['expression', 'mutation', '27k', '450k']
samples = [sample_lists[l] for l in labels]

upset_series = series_from_samples(samples, labels)
Expand All @@ -143,11 +141,13 @@ def series_from_samples(samples, labels):
# In[10]:


subplots = up.plot(upset_series[upset_series != 0], element_size=60)
plt.title('TCGA sample intersections, expression/methylation datasets', size=13)
plt.ylabel('Intersection size', size=13)
plt.yticks(fontsize=13)
subplots['matrix'].set_yticklabels(labels=subplots['matrix'].get_yticklabels(), fontsize=12)
subplots = up.plot(upset_series[upset_series != 0], element_size=60,
totals_plot_elements=1)
plt.title('TCGA sample intersections, expression/methylation datasets', size=18)
plt.ylabel('Intersection size', size=18)
plt.yticks(fontsize=18)
subplots['matrix'].set_yticklabels(labels=subplots['matrix'].get_yticklabels(), fontsize=18)
plt.gcf().delaxes(subplots['totals'])

# we can clean up whitespace below in figure assembly script
if SAVE_FIGS:
Expand All @@ -164,8 +164,8 @@ def series_from_samples(samples, labels):


sns.set_style('white')
labels = ['gene expression', 'mutation', '27k methylation', '450k methylation',
'RPPA', 'microRNA', 'mut sigs']
labels = ['expression', 'mutation', '27k', '450k',
'RPPA', 'microRNA', 'mut. sigs']
samples = [sample_lists[l] for l in labels]

upset_series = series_from_samples(samples, labels)
Expand All @@ -176,10 +176,11 @@ def series_from_samples(samples, labels):


subplots = up.plot(upset_series[upset_series >= 100], element_size=60)
plt.title('TCGA sample intersections, all datasets', size=13)
plt.ylabel('Intersection size', size=13)
plt.yticks(fontsize=13)
subplots['matrix'].set_yticklabels(labels=subplots['matrix'].get_yticklabels(), fontsize=12)
plt.title('TCGA sample intersections, all datasets', size=18)
plt.ylabel('Intersection size', size=16)
plt.yticks(fontsize=16)
subplots['matrix'].set_yticklabels(labels=subplots['matrix'].get_yticklabels(), fontsize=16)
plt.gcf().delaxes(subplots['totals'])

if SAVE_FIGS:
images_dir = Path(cfg.images_dirs['data'])
Expand Down
19 changes: 2 additions & 17 deletions 02_classify_mutations/nbconverted/plot_all_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
import matplotlib.pyplot as plt
import seaborn as sns

# svgutils sometimes doesn't deal well with text as paths in svgs
# so for this file, we'll save the text as text, then convert it by hand
# in inkscape to paths which seem to work fine in svgutils
#
# for some reason just the plots in this file have this issue, plots from
# other analysis scripts don't have this issue so we don't have to do all this
plt.rcParams['svg.fonttype'] = 'none'

import mpmp.config as cfg
import mpmp.utilities.analysis_utilities as au
import mpmp.utilities.plot_utilities as plu
Expand Down Expand Up @@ -345,7 +337,7 @@
if merged_geneset:
# for the larger gene set we need a bigger figure, since we
# separate the heatmap into multiple rows
sns.set({'figure.figsize': (38, 13)})
sns.set({'figure.figsize': (38, 21)})
else:
sns.set({'figure.figsize': (28, 6)})

Expand All @@ -360,7 +352,7 @@
origin_eps_y=0.015,
length_x=0.85,
length_y=0.95)
plt.suptitle('Performance by data type for cancer-related genes, all data types')
plt.suptitle('Performance by data type for cancer-related genes, all data types', size=26)
plt.tight_layout()
else:
ax = plu.plot_heatmap_split(heatmap_df,
Expand Down Expand Up @@ -427,10 +419,3 @@
plt.savefig(images_dir / 'all_heatmap_sig.png',
dpi=300, bbox_inches='tight')


# In[20]:


print(heatmap_sig_df.shape)
heatmap_sig_df.iloc[:, :10]

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
all_results_df.sort_values(by='p_value').head(10)


# In[7]:
# In[13]:


sns.set({'figure.figsize': (24, 6)})
Expand All @@ -171,7 +171,7 @@
SIG_ALPHA,
metric=plot_metric,
verbose=True,
label_x_lower_bounds=[0.2, 0.2, 0.4],
label_x_lower_bounds=[0.2, 0.3, 0.5],
label_y_lower_bounds=[4, 4, 5],
mark_overlap=True,
overlap_reference='cancer gene set')
Expand Down
10 changes: 1 addition & 9 deletions 02_classify_mutations/nbconverted/plot_methylation_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
import seaborn as sns
from adjustText import adjust_text

# svgutils sometimes doesn't deal well with text as paths in svgs
# so for this file, we'll save the text as text, then convert it by hand
# in inkscape to paths which seem to work fine in svgutils
#
# for some reason just the plots in this file have this issue, plots from
# other analysis scripts don't have this issue so we don't have to do all this
plt.rcParams['svg.fonttype'] = 'none'

import mpmp.config as cfg
import mpmp.utilities.analysis_utilities as au
import mpmp.utilities.plot_utilities as plu
Expand Down Expand Up @@ -148,7 +140,7 @@
SIG_ALPHA,
metric=plot_metric,
verbose=True,
label_x_lower_bounds=[0.5, 0.4, 0.4],
label_x_lower_bounds=[0.55, 0.4, 0.4],
label_y_lower_bounds=[4, 4, 4])

if SAVE_FIGS:
Expand Down
203 changes: 12 additions & 191 deletions 02_classify_mutations/plot_all_results.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions 02_classify_mutations/plot_expression_gene_sets.ipynb

Large diffs are not rendered by default.

20 changes: 6 additions & 14 deletions 02_classify_mutations/plot_methylation_results.ipynb

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions 02_classify_mutations/plot_results_n_dims.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


BAYES_OPT = False
MLP = True
MLP = False

if BAYES_OPT:
results_dir = Path(
Expand Down Expand Up @@ -226,7 +226,8 @@
handle = mpatches.Patch(color=colors[ix], label=data)
handles.append(handle)

plt.legend(title='Data types used to train model', handles=handles, loc='lower right')
plt.legend(title='', handles=handles,
loc='lower right', fontsize=15, title_fontsize=15)
plt.tight_layout()

if SAVE_FIGS:
Expand Down Expand Up @@ -408,7 +409,7 @@
compare_df[compare_df.gene == 'TP53'].head(10)


# In[ ]:
# In[17]:


sns.set({'figure.figsize': (13, 6)})
Expand All @@ -426,9 +427,3 @@
plt.savefig(images_dir / svg_filename, bbox_inches='tight')
plt.savefig(images_dir / png_filename, dpi=300, bbox_inches='tight')


# In[ ]:




250 changes: 127 additions & 123 deletions 05_classify_mutations_multimodal/plot_multimodal_results.ipynb

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions 06_predict_survival/plot_survival_results.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 2277fc9

Please sign in to comment.