{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-21T14:29:50.460993Z","iopub.execute_input":"2023-01-21T14:29:50.461552Z","iopub.status.idle":"2023-01-21T14:29:50.486538Z","shell.execute_reply.started":"2023-01-21T14:29:50.461440Z","shell.execute_reply":"2023-01-21T14:29:50.485700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"проверить корреляцию UCHL1  PSMB8  с белками СД и с рнк этих же СД ","metadata":{}},{"cell_type":"code","source":"def get_CDname(filename):\n    cd = filename.split('_')\n    return cd[0]","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:29:50.488747Z","iopub.execute_input":"2023-01-21T14:29:50.489483Z","iopub.status.idle":"2023-01-21T14:29:50.495702Z","shell.execute_reply.started":"2023-01-21T14:29:50.489442Z","shell.execute_reply":"2023-01-21T14:29:50.493967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd44 = pd.read_csv('/kaggle/input/nips22-cdrna-correlations/CD44_pearson_rna_all.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:29:50.497318Z","iopub.execute_input":"2023-01-21T14:29:50.498155Z","iopub.status.idle":"2023-01-21T14:29:50.582985Z","shell.execute_reply.started":"2023-01-21T14:29:50.498110Z","shell.execute_reply":"2023-01-21T14:29:50.581849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd44['genes'] = [ t.split('_')[-1] for t in cd44['gene_id'] ]","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:29:50.586113Z","iopub.execute_input":"2023-01-21T14:29:50.586928Z","iopub.status.idle":"2023-01-21T14:29:50.609629Z","shell.execute_reply.started":"2023-01-21T14:29:50.586864Z","shell.execute_reply":"2023-01-21T14:29:50.608675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd44[cd44['genes']=='UCHL1']","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_y = pd.read_hdf('/kaggle/input/open-problems-multimodal/train_cite_targets.h5')\ndf_y.columns","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:29:50.640403Z","iopub.execute_input":"2023-01-21T14:29:50.640722Z","iopub.status.idle":"2023-01-21T14:29:51.526385Z","shell.execute_reply.started":"2023-01-21T14:29:50.640695Z","shell.execute_reply":"2023-01-21T14:29:51.525561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.DataFrame(index=df_y.columns)","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:29:51.527668Z","iopub.execute_input":"2023-01-21T14:29:51.528419Z","iopub.status.idle":"2023-01-21T14:29:51.533920Z","shell.execute_reply.started":"2023-01-21T14:29:51.528385Z","shell.execute_reply":"2023-01-21T14:29:51.532735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pearsonUCHL1 = []\npearsonPSMB8 = []\nspearman = []\nfor cd in df_y.columns:\n    p = pd.read_csv('/kaggle/input/nips22-cdrna-correlations/'+cd+'_pearson_rna_all.csv')\n    p.set_index('gene_id')\n    UCHL1 = p[p['gene_id'].str.contains('UCHL1')]\n    PSMB8 = p[p['gene_id'].str.contains('PSMB8')]\n    pearsonUCHL1.append(UCHL1.iloc[0][cd])\n    pearsonPSMB8.append(PSMB8.iloc[0][cd])\n    \ndf['UCHL1'] = pearsonUCHL1\ndf['PSMB8'] = pearsonPSMB8","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['UCHL1_abs']=df['UCHL1'].abs()\ndf['PSMB8_abs']=df['PSMB8'].abs()","metadata":{"execution":{"iopub.status.busy":"2023-01-21T14:52:16.414581Z","iopub.execute_input":"2023-01-21T14:52:16.414974Z","iopub.status.idle":"2023-01-21T14:52:16.422542Z","shell.execute_reply.started":"2023-01-21T14:52:16.414943Z","shell.execute_reply":"2023-01-21T14:52:16.421272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv('UCHL1_PSMB8 VS all CD.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:06:48.907061Z","iopub.execute_input":"2023-01-21T15:06:48.907812Z","iopub.status.idle":"2023-01-21T15:06:48.915657Z","shell.execute_reply.started":"2023-01-21T15:06:48.907754Z","shell.execute_reply":"2023-01-21T15:06:48.914572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"RNA-RNA","metadata":{}},{"cell_type":"code","source":"gene_name = 'UCHL1'","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:01:19.115139Z","iopub.execute_input":"2023-01-21T15:01:19.115644Z","iopub.status.idle":"2023-01-21T15:01:19.122022Z","shell.execute_reply.started":"2023-01-21T15:01:19.115606Z","shell.execute_reply":"2023-01-21T15:01:19.120661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gene_name = 'PSMB8'","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:07:17.379259Z","iopub.execute_input":"2023-01-21T15:07:17.379686Z","iopub.status.idle":"2023-01-21T15:07:17.385143Z","shell.execute_reply.started":"2023-01-21T15:07:17.379655Z","shell.execute_reply":"2023-01-21T15:07:17.383818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_rna = pd.read_hdf('/kaggle/input/open-problems-multimodal/train_cite_inputs.h5')\n","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:01:21.055932Z","iopub.execute_input":"2023-01-21T15:01:21.056351Z","iopub.status.idle":"2023-01-21T15:02:17.687320Z","shell.execute_reply.started":"2023-01-21T15:01:21.056317Z","shell.execute_reply":"2023-01-21T15:02:17.685998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gene_rna = df_rna.columns[df_rna.columns.str.contains(gene_name)]","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:07:23.380836Z","iopub.execute_input":"2023-01-21T15:07:23.381222Z","iopub.status.idle":"2023-01-21T15:07:23.399313Z","shell.execute_reply.started":"2023-01-21T15:07:23.381194Z","shell.execute_reply":"2023-01-21T15:07:23.397975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gene_rna_df = df_rna[gene_rna]","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:07:26.663429Z","iopub.execute_input":"2023-01-21T15:07:26.663804Z","iopub.status.idle":"2023-01-21T15:07:26.670042Z","shell.execute_reply.started":"2023-01-21T15:07:26.663775Z","shell.execute_reply":"2023-01-21T15:07:26.668640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gene_rna_corrs = pd.DataFrame(index=df_rna.columns)","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:07:29.431003Z","iopub.execute_input":"2023-01-21T15:07:29.431374Z","iopub.status.idle":"2023-01-21T15:07:29.436425Z","shell.execute_reply.started":"2023-01-21T15:07:29.431343Z","shell.execute_reply":"2023-01-21T15:07:29.435494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col1 in gene_rna_df.columns:\n    pears=[]\n    y=gene_rna_df[col1]\n    for col in df_rna.columns:\n            pears_c = np.corrcoef(y,df_rna[col])[0,1]\n            pears.append(pears_c)\n    gene_rna_corrs[col1]=pears\n    gene_rna_corrs[col1+'_ABS']=gene_rna_corrs[col1].abs()","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:07:32.497534Z","iopub.execute_input":"2023-01-21T15:07:32.497949Z","iopub.status.idle":"2023-01-21T15:08:08.242677Z","shell.execute_reply.started":"2023-01-21T15:07:32.497909Z","shell.execute_reply":"2023-01-21T15:08:08.241856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gene_rna_corrs.to_csv(gene_name+'_VS_all_rna_Pearson.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Результаты","metadata":{}},{"cell_type":"markdown","source":"Лучшие корреляции UCHL1 с белками","metadata":{}},{"cell_type":"code","source":"df.sort_values('UCHL1_abs',ascending = False)","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:10:33.766770Z","iopub.execute_input":"2023-01-21T15:10:33.767177Z","iopub.status.idle":"2023-01-21T15:10:33.783589Z","shell.execute_reply.started":"2023-01-21T15:10:33.767146Z","shell.execute_reply":"2023-01-21T15:10:33.782753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Лучшие корреляции PSMB8 с белками","metadata":{}},{"cell_type":"code","source":"df.sort_values('PSMB8_abs',ascending = False)","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:12:27.466555Z","iopub.execute_input":"2023-01-21T15:12:27.467604Z","iopub.status.idle":"2023-01-21T15:12:27.482918Z","shell.execute_reply.started":"2023-01-21T15:12:27.467565Z","shell.execute_reply":"2023-01-21T15:12:27.481723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PSMB8_rna = pd.read_csv('/kaggle/working/PSMB8_VS_all_rna_Pearson.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:14:10.199744Z","iopub.execute_input":"2023-01-21T15:14:10.200160Z","iopub.status.idle":"2023-01-21T15:14:10.241502Z","shell.execute_reply.started":"2023-01-21T15:14:10.200129Z","shell.execute_reply":"2023-01-21T15:14:10.240413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PSMB8_rna.sort_values('ENSG00000204264_PSMB8_ABS',ascending=False)","metadata":{"execution":{"iopub.status.busy":"2023-01-21T15:14:13.264632Z","iopub.execute_input":"2023-01-21T15:14:13.265108Z","iopub.status.idle":"2023-01-21T15:14:13.289028Z","shell.execute_reply.started":"2023-01-21T15:14:13.265073Z","shell.execute_reply":"2023-01-21T15:14:13.287789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"UCHL1_rna = pd.read_csv('/kaggle/working/UCHL1_VS_all_rna_Pearson.csv')\nUCHL1_rna.sort_values('ENSG00000154277_UCHL1_ABS',ascending=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}