Post-processing of TRANSPIRE results


[1]:
import TRANSPIRE

import pandas as pd
import numpy as np

1. Load data, define comparisons, and generate synthetic translocations

[2]:
f = 'mydata.csv'
df = TRANSPIRE.data.import_data.load_data(f)

comparisons = [('uninfected', 'infected')]

synthetic_translocations = TRANSPIRE.data.generate_translocations.make_translocations(df, comparisons)
mapping, mapping_r = TRANSPIRE.utils.get_mapping(df)

synthetic_translocations.head()
[2]:
1 2 3 4 5 6 7 8 9 10 11 12
accession_A gene name_A localization_A condition_A accession_B gene name_B localization_B condition_B label
O00115 DNASE2 ER/Golgi/Lysosome uninfected O00115 DNASE2 ER/Golgi/Lysosome infected ER/Golgi/Lysosome to ER/Golgi/Lysosome 0.121081 0.378059 0.287889 0.142575 0.056295 0.014235 0.091988 0.249011 0.334238 0.181254 0.104927 0.041090
O00116 AGPS Peroxisome infected ER/Golgi/Lysosome to Peroxisome 0.121081 0.378059 0.287889 0.142575 0.056295 0.014235 0.035467 0.087956 0.190615 0.228672 0.353767 0.095804
O00151 PDLIM1 PM/Cytosol infected ER/Golgi/Lysosome to PM/Cytosol 0.121081 0.378059 0.287889 0.142575 0.056295 0.014235 0.298505 0.273591 0.136350 0.124446 0.101276 0.051836
O00161 SNAP23 PM/Cytosol infected ER/Golgi/Lysosome to PM/Cytosol 0.121081 0.378059 0.287889 0.142575 0.056295 0.014235 0.303401 0.275456 0.219409 0.094259 0.065571 0.027320
O00186 STXBP3 PM/Cytosol infected ER/Golgi/Lysosome to PM/Cytosol 0.121081 0.378059 0.287889 0.142575 0.056295 0.014235 0.251250 0.279922 0.220812 0.102742 0.089897 0.047200

2. Load TRANSPIRE predictions

[3]:
predictions = TRANSPIRE.data.import_data.load_predictions('results.csv')

3. Perform GO enrichment analysis on translocating protiens

Make GOAnalyzer to perform enrichment analyses (facilitated by GOATOOLS)

[4]:
# define a background set of genes to assess enrichment against
background = df.index.get_level_values('accession').unique()
GO_analyzer = TRANSPIRE.go_enrichment.GOAnalyzer(background, species = '9606', alpha = 0.05, method = 'fdr_bh')
  EXISTS: go-basic.obo
  EXISTS: gene2go
go-basic.obo: fmt(1.2) rel(2020-05-02) 47,240 GO Terms
HMS:0:00:03.614330 336,356 annotations, 20,586 genes, 18,410 GOs, 1 taxids READ: gene2go

Load BP Gene Ontology Analysis ...
fisher module not installed.  Falling back on scipy.stats.fisher_exact
 95%  3,051 of  3,196 population items found in association

Load CC Gene Ontology Analysis ...
fisher module not installed.  Falling back on scipy.stats.fisher_exact
 98%  3,147 of  3,196 population items found in association

Load MF Gene Ontology Analysis ...
fisher module not installed.  Falling back on scipy.stats.fisher_exact
 95%  3,032 of  3,196 population items found in association

Perform GO enrichment analysis for translocating proteins

[20]:
translocation_accs = predictions.index.get_level_values('accession_A')[predictions['passes cutoff?']].unique()
translocation_enrichment = GO_analyzer.get_enrichment(translocation_accs)

Run BP Gene Ontology Analysis: current study set of 728 IDs ...
 96%    701 of    727 study items found in association
100%    727 of    728 study items found in population(3196)
Calculating 6,820 uncorrected p-values using fisher_scipy_stats
   6,820 GO terms are associated with  3,049 of  3,196 population items
   3,239 GO terms are associated with    701 of    727 study items
  METHOD fdr_bh:
      30 GO terms found significant (< 0.05=alpha) ( 26 enriched +   4 purified): statsmodels fdr_bh
     260 study items associated with significant GO IDs (enriched)
       4 study items associated with significant GO IDs (purified)

Run CC Gene Ontology Analysis: current study set of 728 IDs ...
 99%    722 of    727 study items found in association
100%    727 of    728 study items found in population(3196)
Calculating 1,109 uncorrected p-values using fisher_scipy_stats
   1,109 GO terms are associated with  3,145 of  3,196 population items
     622 GO terms are associated with    722 of    727 study items
  METHOD fdr_bh:
      35 GO terms found significant (< 0.05=alpha) ( 28 enriched +   7 purified): statsmodels fdr_bh
     639 study items associated with significant GO IDs (enriched)
      92 study items associated with significant GO IDs (purified)

Run MF Gene Ontology Analysis: current study set of 728 IDs ...
 96%    699 of    727 study items found in association
100%    727 of    728 study items found in population(3196)
Calculating 2,192 uncorrected p-values using fisher_scipy_stats
   2,192 GO terms are associated with  3,030 of  3,196 population items
     908 GO terms are associated with    699 of    727 study items
  METHOD fdr_bh:
       5 GO terms found significant (< 0.05=alpha) (  5 enriched +   0 purified): statsmodels fdr_bh
     573 study items associated with significant GO IDs (enriched)
       0 study items associated with significant GO IDs (purified)
[21]:
translocation_enrichment
[21]:
NS enrichment name ratio_in_study ratio_in_pop p_uncorrected depth study_count p_fdr_bh study_items
GO accession
GO:0006413 BP e translational initiation 67/727 103/3196 1.138456e-20 3 67 7.764267e-17 1654, 1964, 1965, 1968, 1973, 1981, 1982, 3646...
GO:0000184 BP e nuclear-transcribed mRNA catabolic process, no... 53/727 83/3196 5.171506e-16 10 53 1.763483e-12 1981, 2935, 3646, 3921, 5515, 5976, 6122, 6124...
GO:0006614 BP e SRP-dependent cotranslational protein targetin... 50/727 81/3196 2.685849e-14 12 50 6.105829e-11 3921, 6122, 6124, 6125, 6133, 6134, 6135, 6137...
GO:0019083 BP e viral transcription 48/727 77/3196 5.258122e-14 4 48 8.965097e-11 3921, 6122, 6124, 6125, 6133, 6134, 6135, 6137...
GO:0006886 BP e intracellular protein transport 65/727 131/3196 6.139768e-12 8 65 8.374644e-09 160, 161, 162, 163, 164, 372, 378, 381, 400, 1...
GO:0006890 BP e retrograde vesicle-mediated transport, Golgi t... 28/727 39/3196 7.885321e-11 6 28 8.962982e-08 372, 378, 381, 1314, 1315, 3831, 5861, 6836, 6...
GO:0006888 BP e endoplasmic reticulum to Golgi vesicle-mediate... 42/727 87/3196 1.485486e-07 6 42 1.447288e-04 372, 378, 1314, 1315, 1639, 1778, 1781, 2621, ...
GO:0006412 BP e translation 57/727 134/3196 2.370902e-07 7 57 2.021194e-04 207, 1615, 1915, 1981, 2935, 3921, 5610, 6122,...
GO:0043488 BP e regulation of mRNA stability 31/727 60/3196 9.324625e-07 9 31 6.359395e-04 207, 1981, 3315, 3842, 5578, 5684, 5689, 5700,...
GO:0032482 BP e Rab protein signal transduction 20/727 33/3196 2.926560e-06 8 20 1.814467e-03 5861, 5864, 5865, 5867, 5868, 5869, 5873, 5878...
GO:0060071 BP e Wnt signaling pathway, planar cell polarity pa... 26/727 51/3196 1.016250e-05 9 26 4.950587e-03 160, 161, 163, 1173, 1175, 5684, 5689, 5700, 5...
GO:0031397 BP e negative regulation of protein ubiquitination 11/727 15/3196 4.325101e-05 10 11 1.914097e-02 207, 857, 3301, 6188, 8878, 9532, 9636, 11261,...
GO:0001732 BP e formation of cytoplasmic translation initiatio... 10/727 13/3196 5.095329e-05 8 10 1.914097e-02 1983, 3646, 8661, 8662, 8663, 8667, 8668, 8894...
GO:0010972 BP e negative regulation of G2/M transition of mito... 20/727 38/3196 5.254492e-05 9 20 1.914097e-02 2273, 5684, 5689, 5700, 5702, 5704, 5705, 5706...
GO:0019886 BP e antigen processing and presentation of exogeno... 20/727 38/3196 5.254492e-05 5 20 1.914097e-02 160, 161, 162, 163, 164, 1173, 1175, 1639, 177...
GO:0070498 BP e interleukin-1-mediated signaling pathway 22/727 43/3196 5.332528e-05 7 22 1.914097e-02 5595, 5684, 5689, 5700, 5702, 5704, 5705, 5706...
GO:0006521 BP e regulation of cellular amino acid metabolic pr... 19/727 36/3196 7.715603e-05 6 19 2.505734e-02 1728, 5684, 5689, 5700, 5702, 5704, 5705, 5706...
GO:0042147 BP e retrograde transport, endosome to Golgi 17/727 31/3196 9.867668e-05 6 17 3.058977e-02 400, 1639, 6642, 6643, 7879, 8675, 8729, 9367,...
GO:0090263 BP e positive regulation of canonical Wnt signaling... 27/727 60/3196 1.269032e-04 8 27 3.615045e-02 857, 1613, 1654, 5684, 5689, 5700, 5702, 5704,...
GO:0033572 BP e transferrin transport 13/727 21/3196 1.272157e-04 9 13 3.615045e-02 392, 523, 526, 528, 529, 535, 1785, 7037, 9296...
GO:0090383 BP e phagosome acidification 10/727 14/3196 1.420635e-04 12 10 3.875492e-02 523, 526, 528, 529, 535, 7879, 9296, 9550, 513...
GO:0061418 BP e regulation of transcription from RNA polymeras... 20/727 40/3196 1.651179e-04 12 20 4.331169e-02 5684, 5689, 5700, 5702, 5704, 5705, 5706, 5707...
GO:0090090 BP e negative regulation of canonical Wnt signaling... 26/727 58/3196 1.883253e-04 8 26 4.756956e-02 857, 1601, 2010, 5684, 5689, 5700, 5702, 5704,...
GO:0045652 BP e regulation of megakaryocyte differentiation 7/727 8/3196 1.978210e-04 7 7 4.797158e-02 3276, 3692, 4015, 4343, 7057, 10398, 121504
GO:0016579 BP e protein deubiquitination 28/727 64/3196 2.089647e-04 9 28 4.797158e-02 5684, 5689, 5700, 5702, 5704, 5705, 5706, 5707...
GO:0002181 BP e cytoplasmic translation 15/727 27/3196 2.110187e-04 8 15 4.797158e-02 3921, 6133, 6135, 6139, 6142, 6143, 6146, 6152...
GO:0005829 CC e cytosol 455/727 1334/3196 6.754852e-38 2 455 7.491131e-35 16, 48, 70, 120, 128, 143, 159, 160, 161, 162,...
GO:0022627 CC e cytosolic small ribosomal subunit 24/727 33/3196 1.227456e-09 5 24 2.722498e-07 1654, 3921, 6187, 6188, 6189, 6191, 6193, 6194...
GO:0016020 CC e membrane 266/727 884/3196 1.887482e-09 2 266 3.488696e-07 16, 70, 102, 120, 143, 160, 163, 164, 310, 311...
GO:0070062 CC e extracellular exosome 282/727 958/3196 7.712528e-09 6 282 1.221885e-06 16, 48, 52, 70, 102, 128, 143, 159, 203, 231, ...
GO:0005634 CC e nucleus 231/727 756/3196 1.019253e-08 5 231 1.412940e-06 102, 143, 207, 310, 403, 581, 790, 817, 824, 8...
GO:0022624 CC e proteasome accessory complex 15/727 17/3196 1.714408e-08 2 15 2.112532e-06 5700, 5702, 5704, 5705, 5706, 5707, 5708, 5709...
GO:0030666 CC e endocytic vesicle membrane 13/727 15/3196 2.643905e-07 6 13 2.932091e-05 160, 161, 163, 817, 857, 949, 1173, 1175, 1785...
GO:0022625 CC e cytosolic large ribosomal subunit 25/727 43/3196 4.994355e-07 5 25 5.035218e-05 6122, 6124, 6125, 6133, 6134, 6135, 6137, 6139...
GO:0005737 CC e cytoplasm 265/727 928/3196 8.023717e-07 2 265 7.415251e-05 16, 48, 52, 70, 102, 143, 159, 164, 203, 207, ...
GO:0000502 CC e proteasome complex 23/727 40/3196 1.895943e-06 5 23 1.617385e-04 3300, 3315, 5684, 5689, 5700, 5702, 5704, 5705...
GO:0005730 CC e nucleolus 60/727 161/3196 1.838891e-05 5 60 1.456664e-03 439, 1656, 1915, 2547, 3162, 3337, 3609, 3692,...
GO:0030126 CC e COPI vesicle coat 8/727 9/3196 5.006332e-05 5 8 3.402078e-03 372, 1314, 1315, 9276, 11316, 22818, 22820, 23423
GO:0030904 CC e retromer complex 10/727 13/3196 5.095329e-05 3 10 3.402078e-03 1639, 6642, 6643, 7879, 8724, 9559, 51479, 516...
GO:0031901 CC e early endosome membrane 27/727 58/3196 5.215088e-05 6 27 3.402078e-03 857, 3107, 3133, 5867, 5868, 5869, 5878, 6642,...
GO:0010008 CC e endosome membrane 33/727 76/3196 7.128547e-05 5 33 3.952779e-03 392, 535, 967, 3916, 3949, 5868, 6233, 6642, 6...
GO:0008541 CC e proteasome regulatory particle, lid subcomplex 6/727 6/3196 1.363396e-04 2 6 7.200028e-03 5709, 5714, 5717, 5718, 5719, 10213
GO:0033290 CC e eukaryotic 48S preinitiation complex 9/727 12/3196 1.752318e-04 4 9 8.833274e-03 1965, 3646, 8661, 8662, 8663, 8667, 8668, 2733...
GO:0005838 CC e proteasome regulatory particle 7/727 8/3196 1.978210e-04 2 7 9.538410e-03 5707, 5708, 5713, 5714, 5718, 5719, 9861
GO:0005840 CC e ribosome 19/727 38/3196 2.496730e-04 5 19 1.153547e-02 5610, 6133, 6173, 6188, 6191, 6193, 6201, 6203...
GO:0005852 CC e eukaryotic translation initiation factor 3 com... 9/727 13/3196 4.548583e-04 2 9 1.868288e-02 1654, 3646, 8661, 8662, 8663, 8667, 8668, 2733...
GO:0008540 CC e proteasome regulatory particle, base subcomplex 8/727 11/3196 5.879953e-04 2 8 2.227521e-02 5700, 5702, 5704, 5705, 5706, 5707, 5708, 5711
GO:0031597 CC e cytosolic proteasome complex 5/727 5/3196 6.025756e-04 6 5 2.227521e-02 3416, 5704, 5705, 5706, 10213
GO:0030131 CC e clathrin adaptor complex 5/727 5/3196 6.025756e-04 4 5 2.227521e-02 162, 163, 8546, 8907, 26985
GO:0005874 CC e microtubule 28/727 68/3196 6.231870e-04 6 28 2.229401e-02 1155, 1639, 1778, 1781, 1785, 1808, 2010, 2288...
GO:1990904 CC e ribonucleoprotein complex 28/727 69/3196 7.439872e-04 2 28 2.521062e-02 143, 1653, 1938, 3609, 4691, 4869, 6124, 6125,...
GO:0005765 CC e lysosomal membrane 50/727 144/3196 7.501806e-04 7 50 2.521062e-02 162, 164, 523, 526, 528, 529, 535, 949, 967, 1...
GO:0012505 CC e endomembrane system 28/727 70/3196 1.256637e-03 2 28 4.098854e-02 526, 5861, 5864, 5865, 5867, 5868, 5869, 5873,...
GO:0016282 CC e eukaryotic 43S preinitiation complex 8/727 12/3196 1.413522e-03 4 8 4.478847e-02 3646, 8661, 8662, 8663, 8667, 8668, 27335, 51386
GO:0005515 MF e protein binding 559/727 2190/3196 2.110386e-08 2 559 4.625966e-05 48, 52, 102, 143, 159, 160, 161, 162, 163, 164...
GO:0003723 MF e RNA binding 158/727 483/3196 4.995147e-08 4 158 5.474682e-05 48, 310, 311, 372, 1615, 1634, 1653, 1654, 165...
GO:0003743 MF e translation initiation factor activity 18/727 30/3196 1.140057e-05 6 18 7.057986e-03 1964, 1965, 1968, 1973, 1981, 1982, 1983, 3646...
GO:0048027 MF e mRNA 5'-UTR binding 12/727 16/3196 1.287954e-05 6 12 7.057986e-03 1654, 4628, 4691, 6125, 6189, 6201, 6207, 6208...
GO:0035615 MF e clathrin adaptor activity 9/727 11/3196 5.488424e-05 5 9 2.406125e-02 160, 161, 163, 164, 1173, 1175, 1601, 3092, 8907

Plot the enriched terms and their values

[27]:
import matplotlib.pyplot as plt

TRANSPIRE.visualization.result_visualization.plot_GO_enrichment_results(translocation_enrichment, orient='horizontal')
plt.show()
../_images/notebooks_post-processing_(GO_analysis,_co-translocation_analysis,_etc.)_13_0.png

4. Determine co-translocating proteins

Compute Mahalanobis distances between all proteins

[5]:
possible_translocation_profiles =TRANSPIRE.data.generate_translocations.make_translocations(df, comparisons, synthetic=False).reset_index().set_index(predictions.index.names)

# get rid of index levels that aren't informative
possible_translocation_profiles = possible_translocation_profiles.reset_index(['localization_A', 'localization_B', 'accession_B', 'gene name_B'], drop=True)

possible_translocation_profiles.index.names = ['condition_A', 'condition_B', 'accession', 'gene name']
dists = possible_translocation_profiles.groupby(['condition_A', 'condition_B']).apply(lambda x: TRANSPIRE.cotranslocation.compute_distance(x.loc[x.name, :]))
dists = dists.reset_index().melt(dists.index.names).dropna().set_index(['condition_A', 'condition_B', 'accession_A', 'accession_B', 'gene name_A', 'gene name_B']).squeeze()
[20]:
dists.sort_values()
[20]:
condition_A  condition_B  accession_A  accession_B  gene name_A  gene name_B
uninfected   infected     P13667       Q15084       PDIA4        PDIA6            0.487088
                          P51398       Q5JTZ9       DAP3         AARS2            0.521965
                          P04083       P08758       ANXA1        ANXA5            0.546352
                          P30040       P30101       ERP29        PDIA3            0.548835
                          P34897       Q99797       SHMT2        MIPEP            0.641325
                                                                                   ...
                          P35527       Q6P1Q0       KRT9         LETMD1         111.279417
                                       Q9NSI6       KRT9         BRWD1          111.435963
                                       Q9NYJ1       KRT9         COA4           111.567667
                                       Q8TAA5       KRT9         GRPEL2         112.014439
                                       Q13057       KRT9         COASY          112.063816
Name: value, Length: 2573046, dtype: float64

Load CORUM complexes

[21]:
corum, prot_to_complex, complex_to_prot = TRANSPIRE.data.import_data.load_CORUM()

Extract true postive (members of CORUM complexes) and true negative (marker proteins of distinct subcellular organelles) populations from the data

[62]:
tn = TRANSPIRE.cotranslocation.extract_true_neg(dists, df)
tp = TRANSPIRE.cotranslocation.extract_true_pos(dists, complex_to_prot, prot_to_complex)

Compute a false-positive rate based on true negative and true positive populations

[67]:
fpr = TRANSPIRE.cotranslocation.compute_fpr(tp, tn)

Determine a distance cutoff based on your desired fpr

[92]:
fpr_cutoff = 0.05 # 5% FPR cutoff
dist_cutoff = fpr.groupby(['condition_A', 'condition_B']).apply(lambda x: x[x<=fpr_cutoff].idxmax()[0])

Identify cotranslocation based on distance cutoff

[99]:
transloc_accs = predictions.index.get_level_values('accession_A')[predictions['passes cutoff?']].unique()
transloc_dists = dists[dists.index.get_level_values('accession_A').isin(transloc_accs)&dists.index.get_level_values('accession_B').isin(transloc_accs)]

cotransloc_dists = transloc_dists[transloc_dists <= dist_cutoff.loc[list(zip(transloc_dists.index.get_level_values('condition_A'), transloc_dists.index.get_level_values('condition_B')))].values]
cotransloc_accs = np.unique(cotransloc_dists.index.get_level_values('accession_A').values.tolist()+cotransloc_dists.index.get_level_values('accession_B').values.tolist())

Query STRINGdb for known interactions

[102]:
gsi = TRANSPIRE.cotranslocation.GetSTRINGInteractions()
known_interactions = gsi.query(cotransloc_accs, '9606')
[103]:
known_interactions.head()
[103]:
stringId_A stringId_B preferredName_A preferredName_B ncbiTaxonId score nscore fscore pscore ascore escore dscore tscore
Accession_A Accession_B
Q16401 P43686 ENSP00000210313 ENSP00000157812 PSMD5 PSMC4 9606 0.989 0.000 0.0 0.000 0.063 0.827 0.9 0.410
P48556 P43686 ENSP00000215071 ENSP00000157812 PSMD8 PSMC4 9606 0.999 0.000 0.0 0.000 0.880 0.994 0.9 0.917
Q16401 ENSP00000215071 ENSP00000210313 PSMD8 PSMD5 9606 0.990 0.000 0.0 0.000 0.081 0.869 0.9 0.290
Q9Y5K8 O94804 ENSP00000216442 ENSP00000176763 ATP6V1D STK10 9606 0.900 0.000 0.0 0.000 0.000 0.000 0.9 0.000
P25788 P43686 ENSP00000216455 ENSP00000157812 PSMA3 PSMC4 9606 0.999 0.059 0.0 0.201 0.798 0.994 0.9 0.429

Combine known interaction information with cotranslocation information

[110]:
isknown = pd.Series(cotransloc_dists.reset_index([n for n in cotransloc_dists.index.names if not 'accession' in n]).index.isin(known_interactions.index), index = cotransloc_dists.index)

pd.concat([cotransloc_dists, isknown], axis=1, keys = ['Mahalanobis distance', 'known interaction?'])
[110]:
Mahalanobis distance known interaction?
condition_A condition_B accession_A accession_B gene name_A gene name_B
uninfected infected A0AVT1 O00231 UBA6 PSMD11 2.482505 True
O00154 O00231 ACOT7 PSMD11 3.157640 False
O00203 O00231 AP3B1 PSMD11 3.091579 False
O00231 O00232 PSMD11 PSMD12 2.637260 True
A0AVT1 O00425 UBA6 IGF2BP3 2.502198 False
... ... ... ... ... ...
Q9UNM6 Q9Y6M1 PSMD13 IGF2BP2 2.395706 False
Q9Y230 Q9Y6M1 RUVBL2 IGF2BP2 2.972433 False
Q9Y265 Q9Y6M1 RUVBL1 IGF2BP2 3.339705 False
Q9Y3I0 Q9Y6M1 RTCB IGF2BP2 2.039269 False
Q9Y678 Q9Y6M1 COPG1 IGF2BP2 2.863510 False

15265 rows × 2 columns