{"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-11T11:48:12.565749Z","iopub.execute_input":"2022-12-11T11:48:12.566215Z","iopub.status.idle":"2022-12-11T11:48:12.638855Z","shell.execute_reply.started":"2022-12-11T11:48:12.566123Z","shell.execute_reply":"2022-12-11T11:48:12.637822Z"},"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-11T11:48:12.640843Z","iopub.execute_input":"2022-12-11T11:48:12.641155Z","iopub.status.idle":"2022-12-11T11:49:02.584329Z","shell.execute_reply.started":"2022-12-11T11:48:12.641129Z","shell.execute_reply":"2022-12-11T11:49:02.583098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rna_copy=rna.copy()\nrna_copy.columns=rna_copy.columns.str.split('_').str[1] \nrna_copy.head(100)","metadata":{"execution":{"iopub.status.busy":"2022-12-11T11:49:02.586224Z","iopub.execute_input":"2022-12-11T11:49:02.586675Z","iopub.status.idle":"2022-12-11T11:49:05.105636Z","shell.execute_reply.started":"2022-12-11T11:49:02.586634Z","shell.execute_reply":"2022-12-11T11:49:05.104469Z"},"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-11T11:49:05.107237Z","iopub.execute_input":"2022-12-11T11:49:05.108305Z","iopub.status.idle":"2022-12-11T11:49:05.366122Z","shell.execute_reply.started":"2022-12-11T11:49:05.108256Z","shell.execute_reply":"2022-12-11T11:49:05.364962Z"},"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        #print(target_copy[i])\n       # print(rna_copy[j])\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-11T11:49:05.370123Z","iopub.execute_input":"2022-12-11T11:49:05.370503Z","iopub.status.idle":"2022-12-11T12:33:33.509097Z","shell.execute_reply.started":"2022-12-11T11:49:05.370470Z","shell.execute_reply":"2022-12-11T12:33:33.507912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res1=res.to_numpy()\nres2=pd.DataFrame(data=res1, index=rna_copy.columns, columns=target_copy.columns)","metadata":{"execution":{"iopub.status.busy":"2022-12-11T12:33:33.511043Z","iopub.execute_input":"2022-12-11T12:33:33.511772Z","iopub.status.idle":"2022-12-11T12:33:33.519459Z","shell.execute_reply.started":"2022-12-11T12:33:33.511726Z","shell.execute_reply":"2022-12-11T12:33:33.518293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res2.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-11T12:33:33.520868Z","iopub.execute_input":"2022-12-11T12:33:33.521656Z","iopub.status.idle":"2022-12-11T12:33:33.540558Z","shell.execute_reply.started":"2022-12-11T12:33:33.521622Z","shell.execute_reply":"2022-12-11T12:33:33.539396Z"},"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.to_csv('sorted_rna_by_auc_full.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-11T12:33:33.542136Z","iopub.execute_input":"2022-12-11T12:33:33.542640Z","iopub.status.idle":"2022-12-11T12:33:33.937299Z","shell.execute_reply.started":"2022-12-11T12:33:33.542599Z","shell.execute_reply":"2022-12-11T12:33:33.936466Z"},"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-11T12:33:33.939047Z","iopub.execute_input":"2022-12-11T12:33:33.939750Z","iopub.status.idle":"2022-12-11T12:33:33.959811Z","shell.execute_reply.started":"2022-12-11T12:33:33.939707Z","shell.execute_reply":"2022-12-11T12:33:33.958939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display( auc.tail(10).T)","metadata":{"execution":{"iopub.status.busy":"2022-12-11T12:33:33.960988Z","iopub.execute_input":"2022-12-11T12:33:33.961737Z","iopub.status.idle":"2022-12-11T12:33:33.987293Z","shell.execute_reply.started":"2022-12-11T12:33:33.961695Z","shell.execute_reply":"2022-12-11T12:33:33.986096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}