{"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\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-09T17:49:29.676452Z","iopub.execute_input":"2022-12-09T17:49:29.677291Z","iopub.status.idle":"2022-12-09T17:49:29.783589Z","shell.execute_reply.started":"2022-12-09T17:49:29.677153Z","shell.execute_reply":"2022-12-09T17:49:29.782286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rna = pd.read_hdf(\"/kaggle/input/open-problems-multimodal/train_cite_inputs.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:07:40.037464Z","iopub.execute_input":"2022-12-09T20:07:40.037825Z","iopub.status.idle":"2022-12-09T20:08:27.277336Z","shell.execute_reply.started":"2022-12-09T20:07:40.037799Z","shell.execute_reply":"2022-12-09T20:08:27.276237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rna.columns=rna.columns.str[:15]\nrna.head(100)","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:08:27.279137Z","iopub.execute_input":"2022-12-09T20:08:27.279492Z","iopub.status.idle":"2022-12-09T20:08:27.331641Z","shell.execute_reply.started":"2022-12-09T20:08:27.279456Z","shell.execute_reply":"2022-12-09T20:08:27.330469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rna.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-08T20:59:33.028125Z","iopub.execute_input":"2022-12-08T20:59:33.028986Z","iopub.status.idle":"2022-12-08T20:59:33.036697Z","shell.execute_reply.started":"2022-12-08T20:59:33.028937Z","shell.execute_reply":"2022-12-08T20:59:33.035699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename=pd.read_csv('/kaggle/input/research-project-01-around-multimodal-singlecell/CD_info.csv')\nrename.head(50)","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:08:49.738241Z","iopub.execute_input":"2022-12-09T20:08:49.738610Z","iopub.status.idle":"2022-12-09T20:08:49.770504Z","shell.execute_reply.started":"2022-12-09T20:08:49.738580Z","shell.execute_reply":"2022-12-09T20:08:49.769377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:51:11.847694Z","iopub.execute_input":"2022-12-09T20:51:11.848075Z","iopub.status.idle":"2022-12-09T20:51:11.853876Z","shell.execute_reply.started":"2022-12-09T20:51:11.848045Z","shell.execute_reply":"2022-12-09T20:51:11.853141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rna_copy=rna.T\nrename_copy=rename.rename(columns={'ENSG ID':'gene_id'})\n\nrename_copy=rename_copy.merge(rna_copy, on='gene_id', how='inner')\nrename_copy.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:52:45.160789Z","iopub.execute_input":"2022-12-09T20:52:45.161515Z","iopub.status.idle":"2022-12-09T20:53:36.545380Z","shell.execute_reply.started":"2022-12-09T20:52:45.161469Z","shell.execute_reply":"2022-12-09T20:53:36.544286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename_copy=rename_copy.drop(columns=['Unnamed: 0','gene_id','names'])\nrename_copy=rename_copy.T\nrename_copy.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:57:26.654839Z","iopub.execute_input":"2022-12-09T20:57:26.655223Z","iopub.status.idle":"2022-12-09T20:57:27.308393Z","shell.execute_reply.started":"2022-12-09T20:57:26.655181Z","shell.execute_reply":"2022-12-09T20:57:27.307339Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename_copy.columns = rename_copy.iloc[0]\nrename_copy1=rename_copy[1:]\nrename_copy1.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:58:36.187869Z","iopub.execute_input":"2022-12-09T20:58:36.188266Z","iopub.status.idle":"2022-12-09T20:58:36.263973Z","shell.execute_reply.started":"2022-12-09T20:58:36.188232Z","shell.execute_reply":"2022-12-09T20:58:36.262401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option('display.max_columns', None)\nrename_copy1.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:39:28.024321Z","iopub.execute_input":"2022-12-09T20:39:28.024730Z","iopub.status.idle":"2022-12-09T20:39:28.101196Z","shell.execute_reply.started":"2022-12-09T20:39:28.024698Z","shell.execute_reply":"2022-12-09T20:39:28.100269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename_copy1=rename_copy1.T.groupby(level=0).first().T","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:58:58.236791Z","iopub.execute_input":"2022-12-09T20:58:58.237147Z","iopub.status.idle":"2022-12-09T20:59:11.736957Z","shell.execute_reply.started":"2022-12-09T20:58:58.237120Z","shell.execute_reply":"2022-12-09T20:59:11.735426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rename_copy1.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:59:24.062896Z","iopub.execute_input":"2022-12-09T20:59:24.063850Z","iopub.status.idle":"2022-12-09T20:59:24.071264Z","shell.execute_reply.started":"2022-12-09T20:59:24.063808Z","shell.execute_reply":"2022-12-09T20:59:24.069977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target=pd.read_csv('/kaggle/input/feature-shop-for-multimodal-singlecell-competition/_citeseq_meta_all_text_also.csv')\ntarget=target.loc[target['Train0OrTest1']==0]\ntarget_copy=target.drop(columns=['cell_id','Train0OrTest1', 'day', 'donor', 'cell_type', 'technology', 'Gender'], axis=1)\ntarget_copy.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T20:32:08.991178Z","iopub.execute_input":"2022-12-09T20:32:08.991618Z","iopub.status.idle":"2022-12-09T20:32:09.262265Z","shell.execute_reply.started":"2022-12-09T20:32:08.991582Z","shell.execute_reply":"2022-12-09T20:32:09.260783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import roc_auc_score\n\nres=pd.DataFrame()\ny=1\nfor i in target_copy.columns:    #для каждого клеточного типа\n    ix=1\n    for j in rename_copy1.columns:   #для каждого рнк\n        res.loc[ix,y]=roc_auc_score(target_copy[i], rename_copy1[j])\n        ix+=1\n    y+=1\nres.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-09T21:00:01.320228Z","iopub.execute_input":"2022-12-09T21:00:01.320566Z","iopub.status.idle":"2022-12-09T21:00:11.377781Z","shell.execute_reply.started":"2022-12-09T21:00:01.320538Z","shell.execute_reply":"2022-12-09T21:00:11.376771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res1=res.to_numpy()\nres2=pd.DataFrame(data=res1, index=rename_copy1.columns, columns=target_copy.columns)","metadata":{"execution":{"iopub.status.busy":"2022-12-09T21:00:17.238365Z","iopub.execute_input":"2022-12-09T21:00:17.238758Z","iopub.status.idle":"2022-12-09T21:00:17.246892Z","shell.execute_reply.started":"2022-12-09T21:00:17.238728Z","shell.execute_reply":"2022-12-09T21:00:17.245561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"auc=pd.DataFrame()\nfor i in res2.columns:\n   # auc=auc.reset_index(drop=True)\n    res2=res2.sort_values(by=i)\n    df1=res2.index.to_frame(name=i+' rna ')\n    df1=df1.reset_index(drop=True)\n\n    df2=res2[i].to_frame(name='Auc for '+i)\n    df2=df2.reset_index(drop=True)  \n    auc =pd.concat([auc,df1], axis=1)\n    auc =pd.concat([auc,df2], axis=1)\nauc\nauc.to_csv('sorted_rna_by_auc_110.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-09T21:00:29.796775Z","iopub.execute_input":"2022-12-09T21:00:29.797879Z","iopub.status.idle":"2022-12-09T21:00:29.821032Z","shell.execute_reply.started":"2022-12-09T21:00:29.797829Z","shell.execute_reply":"2022-12-09T21:00:29.819720Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ndisplay( auc.head(10).T)","metadata":{"execution":{"iopub.status.busy":"2022-12-09T21:00:34.334618Z","iopub.execute_input":"2022-12-09T21:00:34.335192Z","iopub.status.idle":"2022-12-09T21:00:34.353023Z","shell.execute_reply.started":"2022-12-09T21:00:34.335158Z","shell.execute_reply":"2022-12-09T21:00:34.351767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display( auc.tail(10).T)","metadata":{"execution":{"iopub.status.busy":"2022-12-09T21:00:47.230816Z","iopub.execute_input":"2022-12-09T21:00:47.231228Z","iopub.status.idle":"2022-12-09T21:00:47.250754Z","shell.execute_reply.started":"2022-12-09T21:00:47.231187Z","shell.execute_reply":"2022-12-09T21:00:47.249296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}