{"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-08T20:58:36.424122Z","iopub.execute_input":"2022-12-08T20:58:36.424494Z","iopub.status.idle":"2022-12-08T20:58:36.438229Z","shell.execute_reply.started":"2022-12-08T20:58:36.424463Z","shell.execute_reply":"2022-12-08T20:58:36.437464Z"},"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-08T20:58:36.439819Z","iopub.execute_input":"2022-12-08T20:58:36.440605Z","iopub.status.idle":"2022-12-08T20:59:32.978380Z","shell.execute_reply.started":"2022-12-08T20:58:36.440570Z","shell.execute_reply":"2022-12-08T20:59:32.977353Z"},"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-08T20:59:32.980053Z","iopub.execute_input":"2022-12-08T20:59:32.980365Z","iopub.status.idle":"2022-12-08T20:59:33.026550Z","shell.execute_reply.started":"2022-12-08T20:59:32.980336Z","shell.execute_reply":"2022-12-08T20:59:33.025365Z"},"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-08T20:59:33.039298Z","iopub.execute_input":"2022-12-08T20:59:33.039630Z","iopub.status.idle":"2022-12-08T20:59:33.064020Z","shell.execute_reply.started":"2022-12-08T20:59:33.039594Z","shell.execute_reply":"2022-12-08T20:59:33.062947Z"},"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-08T20:59:33.065407Z","iopub.execute_input":"2022-12-08T20:59:33.065784Z","iopub.status.idle":"2022-12-08T20:59:33.246728Z","shell.execute_reply.started":"2022-12-08T20:59:33.065751Z","shell.execute_reply":"2022-12-08T20:59:33.245727Z"},"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 rna.columns:   #для каждого рнк\n        res.loc[ix,y]=roc_auc_score(target_copy[i], rna[j])\n        ix+=1\n    y+=1\nres.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-08T20:59:33.248702Z","iopub.execute_input":"2022-12-08T20:59:33.249118Z","iopub.status.idle":"2022-12-08T21:43:31.408553Z","shell.execute_reply.started":"2022-12-08T20:59:33.249077Z","shell.execute_reply":"2022-12-08T21:43:31.407218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res1=res.to_numpy()\nres2=pd.DataFrame(data=res1, index=rna.columns, columns=target_copy.columns)","metadata":{"execution":{"iopub.status.busy":"2022-12-08T21:43:31.410076Z","iopub.execute_input":"2022-12-08T21:43:31.410458Z","iopub.status.idle":"2022-12-08T21:43:31.417208Z","shell.execute_reply.started":"2022-12-08T21:43:31.410415Z","shell.execute_reply":"2022-12-08T21:43:31.416298Z"},"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.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-08T21:43:31.418579Z","iopub.execute_input":"2022-12-08T21:43:31.419284Z","iopub.status.idle":"2022-12-08T21:43:31.821826Z","shell.execute_reply.started":"2022-12-08T21:43:31.419250Z","shell.execute_reply":"2022-12-08T21:43:31.820581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option('display.max_columns', None)\ndisplay( auc.head(10).T)","metadata":{"execution":{"iopub.status.busy":"2022-12-08T21:43:31.823259Z","iopub.execute_input":"2022-12-08T21:43:31.823639Z","iopub.status.idle":"2022-12-08T21:43:31.844532Z","shell.execute_reply.started":"2022-12-08T21:43:31.823598Z","shell.execute_reply":"2022-12-08T21:43:31.843272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display( auc.tail(10).T)","metadata":{"execution":{"iopub.status.busy":"2022-12-08T21:43:31.849202Z","iopub.execute_input":"2022-12-08T21:43:31.849723Z","iopub.status.idle":"2022-12-08T21:43:31.871621Z","shell.execute_reply.started":"2022-12-08T21:43:31.849680Z","shell.execute_reply":"2022-12-08T21:43:31.870406Z"},"trusted":true},"execution_count":null,"outputs":[]}]}