<jupyter_start><jupyter_text>Gene Expression and RPPA Concordance Identify relationship between gene expression data and Reverse phase protein lysate microarray (RPPA) data   Inputs and Functions<jupyter_code>import rnaseq_lib as r
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import pearsonr
# RPPA Data
rppa_path = './data/rppa.tsv'
rppa = pd.read_csv(rppa_path, sep='\t', index_col=0)
# Shorten TCGA sample names to 15 char limit
rppa.index = [x[:15] for x in rppa.index]  

# Gene Expression Data
# Synapse ID: syn12009613
data_path = '/mnt/data/Objects/tcga_gtex_data.hd5'
exp = pd.read_hdf(data_path, key='exp').apply(r.math.l2norm)
met = pd.read_hdf(data_path, key='met')
df = r.data.add_metadata_to_exp(exp, met)

# Subset for TCGA Tumor
tcga = exp.loc[[x for x in df.index if 
                x.startswith('TCGA') and x.endswith('01')]]
# Subset for GTEx for comparison
gtex = exp.loc[[x for x in df.index if x.startswith('GTEX')]]

# Normalize to log2(x + 0.001)
tcga = tcga.apply(r.math.l2norm)
gtex = gtex.apply(r.math.l2norm)
# Add a few differnetly labelled examples
rppa['ERBB2'] = rppa['HER2']
rppa['KDR'] = rppa['VEGFR2']
for x in [tcga, rppa]:
    print 'Samples: {}\tGenes: {}'.format(*x.shape)
def create_plot_df(gene, rppa=rppa, tcga=tcga, df=df):
    pdf = pd.DataFrame()
    pdf['RPPA'] = rppa[gene].dropna()
    pdf['TCGA'] = tcga[gene].dropna()
    pdf['GTEX'] = gtex[gene].dropna()
    pdf['Tissue'] = df.tissue
    pdf['Tumor'] = df.tumor
    return pdf
def jointplot(gene, rppa=rppa, tcga=tcga):
    df = create_plot_df(gene, rppa=rppa, tcga=tcga)
    sns.jointplot(x='RPPA', y='TCGA', data=df, 
                  kind='reg', scatter_kws={'alpha':0.3})<jupyter_output><empty_output><jupyter_text>Subset By Sample and Gene Intersection<jupyter_code>rppa_genes = set(rppa.columns[1:])
all_genes = set(df.columns)
genes = rppa_genes.intersection(all_genes)
print 'Number of genes in both datasets: {}'.format(len(genes))
samples = sorted(set(tcga.index).intersection(set(rppa.index)))
print 'Number of shared samples: {}'.format(len(samples))
tcga = tcga.loc[samples][sorted(genes)]
rppa = rppa.loc[samples][sorted(genes)]<jupyter_output><empty_output><jupyter_text>PearsonR ConcordanceWhat is the general concordance relationship between RPPA and RNA-seq TPM data?<jupyter_code>genes = sorted(genes)
pr = {}
for g in genes:
    t = create_plot_df(g)
    pr[g] = round(pearsonr(t.RPPA, t.TCGA)[0], 2)
pr = pd.Series(pr).sort_values()
sns.boxplot(pr)
plt.xlabel('PearsonR Score')
plt.title('PearsonR Gene Scores Between RPPA and RNA-Seq');<jupyter_output><empty_output><jupyter_text>Subset top 20 most concordant values<jupyter_code>sub = pr.tail(20)
plt.figure(figsize=(8, 4))
plt.scatter(sub.index, sub)
plt.xticks(rotation=45, fontsize=10);<jupyter_output><empty_output><jupyter_text>Concordance Evaluation  HER2/ERBB2<jupyter_code>breast = df[(df.tissue == 'Breast') & (df.tumor == 'yes')]
erbb2_c = r.math.overlay_gmm_to_hist(breast.ERBB2)
print len(breast)
print len(breast[breast.ERBB2 > erbb2_c])
jointplot('ERBB2')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14729426833173231, 'fraction_numerical': 0.01569004162664105, 'mean_word_length': 5.563025210084033, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '219013', 'license': 'Apache-2.0', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1227, 'n_words': 258, 'path': 'Analysis-Notebooks/Expression-RPPA-Concordance.ipynb', 'repo_name': 'jvivian/Actionable-Subtypes-Manuscript', 'size': '3123'}