Created
September 18, 2018 05:03
-
-
Save cplaisier/b4560ffa44c49701fa31971b76103e9c to your computer and use it in GitHub Desktop.
Coverts postProcessed files to have entrez IDs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import pandas as pd | |
| gene2entrez = [] | |
| with open('gene2entrez.csv', mode='r') as infile: | |
| reader1 = csv.reader(infile) | |
| gene2entrez = {row1[0]:row1[1] for row1 in reader1} | |
| for post in ['pita','targetscan','tfbs_db']: | |
| # read in the gene symbol map and the post proc | |
| pp1 = pd.read_csv( 'postProcessed_vSurv/postProcessed_GBM_'+post+'.csv', header = 0, index_col = 0) | |
| # tfsplit the post proc | |
| ppcols_expMatches = ['TFBS_DB.Exapnded Matches','Up.WEEDER Motif2 Expanded Matches','Up.WEEDER Motif1 Expanded Matches','Up.MEME Motif2 Expanded Matches','Up.MEME Motif1 Expanded Matches'] | |
| for ppcol in ppcols_expMatches: | |
| for pprow in pp1.index.values: | |
| if not pd.isnull(pp1.loc[pprow,ppcol]): | |
| print pp1.loc[pprow,ppcol] | |
| tmp1 = ' '.join([':'.join([gene2entrez[i.split(':')[0]],';'.join([gene2entrez[j] for j in i.split(':')[1].split(';')])]) for i in pp1.loc[pprow,ppcol].split(' ')]) | |
| print tmp1 | |
| pp1.loc[pprow,ppcol] = tmp1 | |
| ppcols_corMatches = ['TFBS_DB.Minimum Correlated_GBM','TFBS_DB.Correlated Matches_GBM','Up.WEEDER Motif2 Minimum Correlated_GBM','Up.WEEDER Motif2 Correlated Matches_GBM','Up.WEEDER Motif1 Minimum Correlated_GBM','Up.WEEDER Motif1 Correlated Matches_GBM','Up.MEME Motif2 Minimum Correlated','Up.MEME Motif2 Correlated Matches_GBM','Up.MEME Motif1 Minimum Correlated_GBM','Up.MEME Motif1 Correlated Matches_GBM'] | |
| for ppcol in ppcols_corMatches: | |
| for pprow in pp1.index.values: | |
| if not pd.isnull(pp1.loc[pprow,ppcol]): | |
| tmp1 = ' '.join([gene2entrez[i.split(':')[0]]+':'+i.split(':')[1]+':'+i.split(':')[2] for i in pp1.loc[pprow,ppcol].split(' ')]) | |
| print tmp1 | |
| pp1.loc[pprow,ppcol] = tmp1 | |
| pp1.fillna('NA').to_csv('postProcessed_vSurv/postProcessed_GBM_Entrez_'+post+'.csv') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment