|
a |
|
b/notebooks/process_shap.ipynb |
|
|
1 |
{ |
|
|
2 |
"cells": [ |
|
|
3 |
{ |
|
|
4 |
"cell_type": "code", |
|
|
5 |
"execution_count": 1, |
|
|
6 |
"metadata": {}, |
|
|
7 |
"outputs": [], |
|
|
8 |
"source": [ |
|
|
9 |
"import pandas as pd\n", |
|
|
10 |
"from tqdm.notebook import tqdm" |
|
|
11 |
] |
|
|
12 |
}, |
|
|
13 |
{ |
|
|
14 |
"cell_type": "code", |
|
|
15 |
"execution_count": 2, |
|
|
16 |
"metadata": {}, |
|
|
17 |
"outputs": [], |
|
|
18 |
"source": [ |
|
|
19 |
"omics = [\"proteomics\",\n", |
|
|
20 |
" \"metabolomics\",\n", |
|
|
21 |
" \"drugresponse\",\n", |
|
|
22 |
" \"crisprcas9\",\n", |
|
|
23 |
" \"methylation\",\n", |
|
|
24 |
" \"transcriptomics\",\n", |
|
|
25 |
" \"copynumber\"]" |
|
|
26 |
] |
|
|
27 |
}, |
|
|
28 |
{ |
|
|
29 |
"cell_type": "code", |
|
|
30 |
"execution_count": 3, |
|
|
31 |
"metadata": {}, |
|
|
32 |
"outputs": [], |
|
|
33 |
"source": [ |
|
|
34 |
"TIMESTAMP = \"20241210_000556\"" |
|
|
35 |
] |
|
|
36 |
}, |
|
|
37 |
{ |
|
|
38 |
"cell_type": "code", |
|
|
39 |
"execution_count": 5, |
|
|
40 |
"metadata": {}, |
|
|
41 |
"outputs": [ |
|
|
42 |
{ |
|
|
43 |
"data": { |
|
|
44 |
"text/html": [ |
|
|
45 |
"<div>\n", |
|
|
46 |
"<style scoped>\n", |
|
|
47 |
" .dataframe tbody tr th:only-of-type {\n", |
|
|
48 |
" vertical-align: middle;\n", |
|
|
49 |
" }\n", |
|
|
50 |
"\n", |
|
|
51 |
" .dataframe tbody tr th {\n", |
|
|
52 |
" vertical-align: top;\n", |
|
|
53 |
" }\n", |
|
|
54 |
"\n", |
|
|
55 |
" .dataframe thead th {\n", |
|
|
56 |
" text-align: right;\n", |
|
|
57 |
" }\n", |
|
|
58 |
"</style>\n", |
|
|
59 |
"<table border=\"1\" class=\"dataframe\">\n", |
|
|
60 |
" <thead>\n", |
|
|
61 |
" <tr style=\"text-align: right;\">\n", |
|
|
62 |
" <th></th>\n", |
|
|
63 |
" <th>Sample_ID</th>\n", |
|
|
64 |
" <th>target_name</th>\n", |
|
|
65 |
" <th>omics_feature</th>\n", |
|
|
66 |
" <th>Shap_value</th>\n", |
|
|
67 |
" </tr>\n", |
|
|
68 |
" </thead>\n", |
|
|
69 |
" <tbody>\n", |
|
|
70 |
" <tr>\n", |
|
|
71 |
" <th>42644</th>\n", |
|
|
72 |
" <td>SIDM00001</td>\n", |
|
|
73 |
" <td>Latent_1</td>\n", |
|
|
74 |
" <td>proteomics_ABHD14B</td>\n", |
|
|
75 |
" <td>0.000240</td>\n", |
|
|
76 |
" </tr>\n", |
|
|
77 |
" <tr>\n", |
|
|
78 |
" <th>42645</th>\n", |
|
|
79 |
" <td>SIDM00003</td>\n", |
|
|
80 |
" <td>Latent_1</td>\n", |
|
|
81 |
" <td>proteomics_ABHD14B</td>\n", |
|
|
82 |
" <td>-0.000120</td>\n", |
|
|
83 |
" </tr>\n", |
|
|
84 |
" <tr>\n", |
|
|
85 |
" <th>42646</th>\n", |
|
|
86 |
" <td>SIDM00005</td>\n", |
|
|
87 |
" <td>Latent_1</td>\n", |
|
|
88 |
" <td>proteomics_ABHD14B</td>\n", |
|
|
89 |
" <td>-0.000593</td>\n", |
|
|
90 |
" </tr>\n", |
|
|
91 |
" <tr>\n", |
|
|
92 |
" <th>42647</th>\n", |
|
|
93 |
" <td>SIDM00006</td>\n", |
|
|
94 |
" <td>Latent_1</td>\n", |
|
|
95 |
" <td>proteomics_ABHD14B</td>\n", |
|
|
96 |
" <td>0.000908</td>\n", |
|
|
97 |
" </tr>\n", |
|
|
98 |
" <tr>\n", |
|
|
99 |
" <th>42648</th>\n", |
|
|
100 |
" <td>SIDM00007</td>\n", |
|
|
101 |
" <td>Latent_1</td>\n", |
|
|
102 |
" <td>proteomics_ABHD14B</td>\n", |
|
|
103 |
" <td>0.000113</td>\n", |
|
|
104 |
" </tr>\n", |
|
|
105 |
" </tbody>\n", |
|
|
106 |
"</table>\n", |
|
|
107 |
"</div>" |
|
|
108 |
], |
|
|
109 |
"text/plain": [ |
|
|
110 |
" Sample_ID target_name omics_feature Shap_value\n", |
|
|
111 |
"42644 SIDM00001 Latent_1 proteomics_ABHD14B 0.000240\n", |
|
|
112 |
"42645 SIDM00003 Latent_1 proteomics_ABHD14B -0.000120\n", |
|
|
113 |
"42646 SIDM00005 Latent_1 proteomics_ABHD14B -0.000593\n", |
|
|
114 |
"42647 SIDM00006 Latent_1 proteomics_ABHD14B 0.000908\n", |
|
|
115 |
"42648 SIDM00007 Latent_1 proteomics_ABHD14B 0.000113" |
|
|
116 |
] |
|
|
117 |
}, |
|
|
118 |
"execution_count": 5, |
|
|
119 |
"metadata": {}, |
|
|
120 |
"output_type": "execute_result" |
|
|
121 |
} |
|
|
122 |
], |
|
|
123 |
"source": [ |
|
|
124 |
"df.head()" |
|
|
125 |
] |
|
|
126 |
}, |
|
|
127 |
{ |
|
|
128 |
"cell_type": "code", |
|
|
129 |
"execution_count": null, |
|
|
130 |
"metadata": {}, |
|
|
131 |
"outputs": [], |
|
|
132 |
"source": [ |
|
|
133 |
"for omic in tqdm(omics[1:]):\n", |
|
|
134 |
" df = pd.read_feather(\n", |
|
|
135 |
" f\"/home/scai/E0160_P01_PhenPred/reports/vae/files/20231023_092657_shap_values_{omic}.feather\"\n", |
|
|
136 |
" )\n", |
|
|
137 |
" df.iloc[:, 1:] = df.iloc[:, 1:].abs()\n", |
|
|
138 |
" df_sum = df.groupby(\"target_name\").sum()\n", |
|
|
139 |
" df_sum.to_csv(\n", |
|
|
140 |
" f\"/home/scai/E0160_P01_PhenPred/reports/vae/files/{omic}_shap_values.csv.gz\"\n", |
|
|
141 |
" )" |
|
|
142 |
] |
|
|
143 |
}, |
|
|
144 |
{ |
|
|
145 |
"cell_type": "code", |
|
|
146 |
"execution_count": null, |
|
|
147 |
"metadata": {}, |
|
|
148 |
"outputs": [], |
|
|
149 |
"source": [] |
|
|
150 |
} |
|
|
151 |
], |
|
|
152 |
"metadata": { |
|
|
153 |
"kernelspec": { |
|
|
154 |
"display_name": "mosa", |
|
|
155 |
"language": "python", |
|
|
156 |
"name": "python3" |
|
|
157 |
}, |
|
|
158 |
"language_info": { |
|
|
159 |
"codemirror_mode": { |
|
|
160 |
"name": "ipython", |
|
|
161 |
"version": 3 |
|
|
162 |
}, |
|
|
163 |
"file_extension": ".py", |
|
|
164 |
"mimetype": "text/x-python", |
|
|
165 |
"name": "python", |
|
|
166 |
"nbconvert_exporter": "python", |
|
|
167 |
"pygments_lexer": "ipython3", |
|
|
168 |
"version": "3.10.14" |
|
|
169 |
} |
|
|
170 |
}, |
|
|
171 |
"nbformat": 4, |
|
|
172 |
"nbformat_minor": 2 |
|
|
173 |
} |