Import Libraries


In [3]:
from __future__ import division
import os
import math
%matplotlib inline
import numpy as np
import pylab
import matplotlib.pyplot as plt
from matplotlib import rc
import scipy.stats as stats
import pandas as pd
from clean_data import CANCER_TYPES

from IPython.html.widgets import interact
from IPython.html import widgets
from IPython.display import display

In [5]:
can_types = []
for c in CANCER_TYPES:
    f1 = '../results/' + c + os.sep + 'cna_pathway_score.txt'
    
    if os.path.exists(f1):
        can_types.append(c)

print "There are %d cancer types ready to be analysed" % len(can_types)
can_type_wid = widgets.DropdownWidget(description="Select Cancer Type", values=can_types)
display(can_type_wid)


There are 9 cancer types ready to be analysed

In [5]:
can = can_type_wid.value
input_fpath = '../results/' + can + os.sep + 'cna_pathway_score.txt'
sdf = pd.read_table(input_fpath, sep='\t', header=0, index_col=0)

res = pd.Series(index=sdf.index)
for p in sdf.index:
    res.loc[p] = -1*math.log10(stats.ttest_ind(sdf.loc[p], nsdf.loc[p], equal_var=False)[1])

@interact(pval=widgets.FloatSliderWidget(min=res.min(), max=res.max(), value=max(res.max()-5, res.min()), step=1))
def plot_entiched(pval):
    pylab.rcParams['figure.figsize'] = (12.0, 8.0)
    res[res > pval].order().plot(title=can + " Enriched Pathways vs t-test P-values (-log10)", kind='barh', rot=0)


Correlating pathways scores with clinical outcomes


In [ ]:
cohort = "ACC BLCA BRCA CESC CHOL COAD COADREAD DLBC ESCA FPPP GBM GBMLGG HNSC KICH KIRC KIRP LAML LGG LIHC LUAD LUSC MESO OV PAAD PRAD READ SARC SKCM STAD TGCT THCA THYM UCEC UCS UVM"

can_types = []
for c in cohort.split():
    f1 = '../results/' + c + os.sep + c'silent_mutation_pathway_score.txt'
    f2 = '../results/' + c + os.sep + 'nsilent_mutation_pathway_score.txt'
    if os.path.exists(f1) and os.path.exists(f2):
        can_types.append(c)

print "There are %d cancer types ready to be analysed" % len(can_types)
can_type_wid = widgets.DropdownWidget(description="Select Cancer Type", values=can_types)
display(can_type_wid)