{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "cf18a668",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"# real data\n",
"real_data = pd.read_csv('../datasets/real_data_PvDeepSet_ready.csv')\n",
"real_data['source'] = 'real'\n",
"real_data_train = real_data[(real_data.sets == 'train') & (real_data.sample_id_paired.str.contains('DF'))].reset_index(drop=True)\n",
"real_data_test = real_data[(real_data.sets == 'test') & (real_data.sample_id_paired.str.contains('DF'))].reset_index(drop=True)\n",
"real_data_test_lc = real_data[(real_data.sets == 'test') & (real_data.sample_id_paired.str.contains('LC'))].reset_index(drop=True)\n",
"\n",
"\n",
"\n",
"pvAmpSeq_simultion_ready = pd.read_csv('../datasets/pvAmpSeq_simulation_ready.csv')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8d3473b2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b1ecebd2",
"metadata": {},
"outputs": [],
"source": [
"from DeepSets import run_prediction"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "96c65ae1",
"metadata": {},
"outputs": [],
"source": [
"pvAmpSeq_simultion_ready['prior_C'] = 1/3\n",
"pvAmpSeq_simultion_ready['prior_L'] = 1/3\n",
"pvAmpSeq_simultion_ready['prior_I'] = 1/3"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" sample_id_paired | \n",
" pair_id | \n",
" patient_id | \n",
" sample_id | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Sero-040-LC_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
"
\n",
" \n",
" | 7 | \n",
" Sero-040-LC_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R08 | \n",
"
\n",
" \n",
" | 36 | \n",
" Sero-182-LC_2 | \n",
" Sero-182_2 | \n",
" Sero-182 | \n",
" Sero-182-R12 | \n",
"
\n",
" \n",
" | 43 | \n",
" Sero-182-LC_2 | \n",
" Sero-182_2 | \n",
" Sero-182 | \n",
" Sero-182-R01 | \n",
"
\n",
" \n",
" | 71 | \n",
" Sero-194-LC_2 | \n",
" Sero-194_2 | \n",
" Sero-194 | \n",
" Sero-194-R09 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" sample_id_paired pair_id patient_id sample_id\n",
"0 Sero-040-LC_4 Sero-040_4 Sero-040 Sero-040-R04\n",
"7 Sero-040-LC_4 Sero-040_4 Sero-040 Sero-040-R08\n",
"36 Sero-182-LC_2 Sero-182_2 Sero-182 Sero-182-R12\n",
"43 Sero-182-LC_2 Sero-182_2 Sero-182 Sero-182-R01\n",
"71 Sero-194-LC_2 Sero-194_2 Sero-194 Sero-194-R09"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real_data_test_lc[['sample_id_paired',\t'pair_id',\t'patient_id',\t'sample_id']].drop_duplicates().head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"temp = real_data_test[real_data_test.country == 'Ethiopia'].copy().reset_index(drop=True)\n",
"\n",
"temp['pair_order'] = temp['sample_id_paired'].str.split('_').str[1]\n",
"# temp['sample_id_paired'] = temp['sample_id_paired'].str[:9] + 'P' + temp['sample_id_paired'].str[11:]\n",
"# temp = temp[data.columns]\n"
]
},
{
"cell_type": "code",
"execution_count": 79,
"id": "5d400e68",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "7b3c3a1d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"48"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp.sample_id_paired.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "53fd6668",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" sample_id_paired | \n",
" pair_id | \n",
" patient_id | \n",
" sample_id | \n",
" episode | \n",
" true_episode | \n",
" marker | \n",
" allele | \n",
" frequency | \n",
" MOI | \n",
" ... | \n",
" prior_C | \n",
" prior_L | \n",
" prior_I | \n",
" post_C | \n",
" post_L | \n",
" post_I | \n",
" recurrence_class | \n",
" sets | \n",
" source | \n",
" pair_order | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Sero-040-DF_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
" 1 | \n",
" 2.0 | \n",
" Chr09 | \n",
" Chr09-1 | \n",
" 0.371429 | \n",
" 4 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.174856 | \n",
" 0.825144 | \n",
" I | \n",
" test | \n",
" real | \n",
" 4 | \n",
"
\n",
" \n",
" | 1 | \n",
" Sero-040-DF_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
" 1 | \n",
" 2.0 | \n",
" Chr09 | \n",
" Chr09-3 | \n",
" 0.228571 | \n",
" 4 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.174856 | \n",
" 0.825144 | \n",
" I | \n",
" test | \n",
" real | \n",
" 4 | \n",
"
\n",
" \n",
" | 2 | \n",
" Sero-040-DF_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
" 1 | \n",
" 2.0 | \n",
" Chr10 | \n",
" Chr10-1 | \n",
" 0.406593 | \n",
" 4 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.174856 | \n",
" 0.825144 | \n",
" I | \n",
" test | \n",
" real | \n",
" 4 | \n",
"
\n",
" \n",
" | 3 | \n",
" Sero-040-DF_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
" 1 | \n",
" 2.0 | \n",
" Chr11 | \n",
" Chr11-2 | \n",
" 0.168317 | \n",
" 4 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.174856 | \n",
" 0.825144 | \n",
" I | \n",
" test | \n",
" real | \n",
" 4 | \n",
"
\n",
" \n",
" | 4 | \n",
" Sero-040-DF_4 | \n",
" Sero-040_4 | \n",
" Sero-040 | \n",
" Sero-040-R04 | \n",
" 1 | \n",
" 2.0 | \n",
" Chr11 | \n",
" Chr11-1 | \n",
" 0.495050 | \n",
" 4 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.174856 | \n",
" 0.825144 | \n",
" I | \n",
" test | \n",
" real | \n",
" 4 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 1607 | \n",
" Sero-109-DF_3 | \n",
" Sero-109_3 | \n",
" Sero-109 | \n",
" Sero-109-R08 | \n",
" 2 | \n",
" 3.0 | \n",
" Chr07 | \n",
" Chr07-1 | \n",
" 0.275641 | \n",
" 3 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.703100 | \n",
" 0.296900 | \n",
" L | \n",
" test | \n",
" real | \n",
" 3 | \n",
"
\n",
" \n",
" | 1608 | \n",
" Sero-109-DF_3 | \n",
" Sero-109_3 | \n",
" Sero-109 | \n",
" Sero-109-R08 | \n",
" 2 | \n",
" 3.0 | \n",
" Chr05 | \n",
" Chr05-5 | \n",
" 0.124183 | \n",
" 3 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.703100 | \n",
" 0.296900 | \n",
" L | \n",
" test | \n",
" real | \n",
" 3 | \n",
"
\n",
" \n",
" | 1609 | \n",
" Sero-109-DF_3 | \n",
" Sero-109_3 | \n",
" Sero-109 | \n",
" Sero-109-R08 | \n",
" 2 | \n",
" 3.0 | \n",
" Chr05 | \n",
" Chr05-2 | \n",
" 0.254902 | \n",
" 3 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.703100 | \n",
" 0.296900 | \n",
" L | \n",
" test | \n",
" real | \n",
" 3 | \n",
"
\n",
" \n",
" | 1610 | \n",
" Sero-109-DF_3 | \n",
" Sero-109_3 | \n",
" Sero-109 | \n",
" Sero-109-R08 | \n",
" 2 | \n",
" 3.0 | \n",
" Chr05 | \n",
" Chr05-3 | \n",
" 0.196078 | \n",
" 3 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.703100 | \n",
" 0.296900 | \n",
" L | \n",
" test | \n",
" real | \n",
" 3 | \n",
"
\n",
" \n",
" | 1611 | \n",
" Sero-109-DF_3 | \n",
" Sero-109_3 | \n",
" Sero-109 | \n",
" Sero-109-R08 | \n",
" 2 | \n",
" 3.0 | \n",
" Chr09 | \n",
" Chr09-2 | \n",
" 0.250000 | \n",
" 3 | \n",
" ... | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.333333 | \n",
" 0.0 | \n",
" 0.703100 | \n",
" 0.296900 | \n",
" L | \n",
" test | \n",
" real | \n",
" 3 | \n",
"
\n",
" \n",
"
\n",
"
1612 rows × 22 columns
\n",
"
"
],
"text/plain": [
" sample_id_paired pair_id patient_id sample_id episode \\\n",
"0 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
"1 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
"2 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
"3 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
"4 Sero-040-DF_4 Sero-040_4 Sero-040 Sero-040-R04 1 \n",
"... ... ... ... ... ... \n",
"1607 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
"1608 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
"1609 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
"1610 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
"1611 Sero-109-DF_3 Sero-109_3 Sero-109 Sero-109-R08 2 \n",
"\n",
" true_episode marker allele frequency MOI ... prior_C prior_L \\\n",
"0 2.0 Chr09 Chr09-1 0.371429 4 ... 0.333333 0.333333 \n",
"1 2.0 Chr09 Chr09-3 0.228571 4 ... 0.333333 0.333333 \n",
"2 2.0 Chr10 Chr10-1 0.406593 4 ... 0.333333 0.333333 \n",
"3 2.0 Chr11 Chr11-2 0.168317 4 ... 0.333333 0.333333 \n",
"4 2.0 Chr11 Chr11-1 0.495050 4 ... 0.333333 0.333333 \n",
"... ... ... ... ... ... ... ... ... \n",
"1607 3.0 Chr07 Chr07-1 0.275641 3 ... 0.333333 0.333333 \n",
"1608 3.0 Chr05 Chr05-5 0.124183 3 ... 0.333333 0.333333 \n",
"1609 3.0 Chr05 Chr05-2 0.254902 3 ... 0.333333 0.333333 \n",
"1610 3.0 Chr05 Chr05-3 0.196078 3 ... 0.333333 0.333333 \n",
"1611 3.0 Chr09 Chr09-2 0.250000 3 ... 0.333333 0.333333 \n",
"\n",
" prior_I post_C post_L post_I recurrence_class sets source \\\n",
"0 0.333333 0.0 0.174856 0.825144 I test real \n",
"1 0.333333 0.0 0.174856 0.825144 I test real \n",
"2 0.333333 0.0 0.174856 0.825144 I test real \n",
"3 0.333333 0.0 0.174856 0.825144 I test real \n",
"4 0.333333 0.0 0.174856 0.825144 I test real \n",
"... ... ... ... ... ... ... ... \n",
"1607 0.333333 0.0 0.703100 0.296900 L test real \n",
"1608 0.333333 0.0 0.703100 0.296900 L test real \n",
"1609 0.333333 0.0 0.703100 0.296900 L test real \n",
"1610 0.333333 0.0 0.703100 0.296900 L test real \n",
"1611 0.333333 0.0 0.703100 0.296900 L test real \n",
"\n",
" pair_order \n",
"0 4 \n",
"1 4 \n",
"2 4 \n",
"3 4 \n",
"4 4 \n",
"... ... \n",
"1607 3 \n",
"1608 3 \n",
"1609 3 \n",
"1610 3 \n",
"1611 3 \n",
"\n",
"[1612 rows x 22 columns]"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "de61dbd8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0000000000000002"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp3.values[2, 1:4].sum()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "5c0986c4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"143\n"
]
}
],
"source": [
"temp3 = run_prediction(temp)\n",
"# temp3\n",
"# temp3['C'] = temp3['C'].round(4)\n",
"# temp3['L'] = temp3['L'].round(4)\n",
"# temp3['I'] = temp3['I'].round(4)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "2488da46",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pair_id | \n",
" prior_C | \n",
" prior_L | \n",
" prior_I | \n",
" prob_C | \n",
" prob_L | \n",
" prob_I | \n",
"
\n",
" \n",
" \n",
" \n",
"
\n",
"
"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [pair_id, prior_C, prior_L, prior_I, prob_C, prob_L, prob_I]\n",
"Index: []"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp3[temp3.prob_L == 0.8250]"
]
},
{
"cell_type": "code",
"execution_count": 62,
"id": "26869713",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.000e+00, 0.000e+00, 1.030e-02, 1.425e-01, 0.000e+00, 4.113e-01,\n",
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 6.560e-02,\n",
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,\n",
" 1.000e-03, 0.000e+00, 0.000e+00, 5.857e-01, 0.000e+00, 0.000e+00,\n",
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 3.471e-01, 0.000e+00,\n",
" 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,\n",
" 2.000e-04, 0.000e+00, 3.340e-02, 7.391e-01, 7.930e-01, 6.600e-03,\n",
" 0.000e+00, 0.000e+00, 1.400e-03, 0.000e+00, 0.000e+00, 0.000e+00])"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp3['C'].values.round(4)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "396bf2fb",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pair_id | \n",
" true_episode | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Sero-040_4 | \n",
" 2.0 | \n",
"
\n",
" \n",
" | 7 | \n",
" Sero-040_4 | \n",
" 3.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" pair_id true_episode\n",
"0 Sero-040_4 2.0\n",
"7 Sero-040_4 3.0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp[temp.patient_id == 'Sero-040'][['pair_id', 'true_episode']].drop_duplicates()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "08c5d09b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"33"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp.patient_id.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "06ddb7a3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"47"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp[['patient_id', 'true_episode']].drop_duplicates().shape[0]-33"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "65abb261",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" patient_id | \n",
" episode | \n",
" relapse_source_epi | \n",
" C | \n",
" L | \n",
" I | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Sero-040 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.4412 | \n",
" 0.5588 | \n",
"
\n",
" \n",
" | 1 | \n",
" Sero-041 | \n",
" 2 | \n",
" 1 | \n",
" 0.4113 | \n",
" 0.5611 | \n",
" 0.0276 | \n",
"
\n",
" \n",
" | 2 | \n",
" Sero-041 | \n",
" 3 | \n",
" 2 | \n",
" 0.1759 | \n",
" 0.7901 | \n",
" 0.0341 | \n",
"
\n",
" \n",
" | 3 | \n",
" Sero-041 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9785 | \n",
" 0.0215 | \n",
"
\n",
" \n",
" | 4 | \n",
" Sero-041 | \n",
" 5 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9785 | \n",
" 0.0215 | \n",
"
\n",
" \n",
" | 5 | \n",
" Sero-041 | \n",
" 6 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1282 | \n",
" 0.8718 | \n",
"
\n",
" \n",
" | 6 | \n",
" Sero-048 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.2813 | \n",
" 0.7187 | \n",
"
\n",
" \n",
" | 7 | \n",
" Sero-048 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1603 | \n",
" 0.8397 | \n",
"
\n",
" \n",
" | 8 | \n",
" Sero-048 | \n",
" 5 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1603 | \n",
" 0.8397 | \n",
"
\n",
" \n",
" | 9 | \n",
" Sero-081 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.3995 | \n",
" 0.6005 | \n",
"
\n",
" \n",
" | 10 | \n",
" Sero-086 | \n",
" 2 | \n",
" 1 | \n",
" 0.0656 | \n",
" 0.8952 | \n",
" 0.0392 | \n",
"
\n",
" \n",
" | 11 | \n",
" Sero-103 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1925 | \n",
" 0.8075 | \n",
"
\n",
" \n",
" | 12 | \n",
" Sero-105 | \n",
" 6 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.4750 | \n",
" 0.5250 | \n",
"
\n",
" \n",
" | 13 | \n",
" Sero-107 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1009 | \n",
" 0.8991 | \n",
"
\n",
" \n",
" | 14 | \n",
" Sero-109 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.7522 | \n",
" 0.2478 | \n",
"
\n",
" \n",
" | 15 | \n",
" Sero-110 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.5647 | \n",
" 0.4353 | \n",
"
\n",
" \n",
" | 16 | \n",
" Sero-130 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1440 | \n",
" 0.8560 | \n",
"
\n",
" \n",
" | 17 | \n",
" Sero-131 | \n",
" 2 | \n",
" 1 | \n",
" 0.0010 | \n",
" 0.9840 | \n",
" 0.0150 | \n",
"
\n",
" \n",
" | 18 | \n",
" Sero-131 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.2770 | \n",
" 0.7230 | \n",
"
\n",
" \n",
" | 19 | \n",
" Sero-138 | \n",
" 5 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1460 | \n",
" 0.8540 | \n",
"
\n",
" \n",
" | 20 | \n",
" Sero-139 | \n",
" 2 | \n",
" 1 | \n",
" 0.5857 | \n",
" 0.3897 | \n",
" 0.0246 | \n",
"
\n",
" \n",
" | 21 | \n",
" Sero-142 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.3768 | \n",
" 0.6232 | \n",
"
\n",
" \n",
" | 22 | \n",
" Sero-142 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1754 | \n",
" 0.8246 | \n",
"
\n",
" \n",
" | 23 | \n",
" Sero-148 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1023 | \n",
" 0.8977 | \n",
"
\n",
" \n",
" | 24 | \n",
" Sero-154 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9993 | \n",
" 0.0007 | \n",
"
\n",
" \n",
" | 25 | \n",
" Sero-161 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9723 | \n",
" 0.0277 | \n",
"
\n",
" \n",
" | 26 | \n",
" Sero-161 | \n",
" 3 | \n",
" 2 | \n",
" 0.3471 | \n",
" 0.6463 | \n",
" 0.0066 | \n",
"
\n",
" \n",
" | 27 | \n",
" Sero-161 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9899 | \n",
" 0.0101 | \n",
"
\n",
" \n",
" | 28 | \n",
" Sero-182 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.0935 | \n",
" 0.9065 | \n",
"
\n",
" \n",
" | 29 | \n",
" Sero-194 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.0681 | \n",
" 0.9319 | \n",
"
\n",
" \n",
" | 30 | \n",
" Sero-194 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.0930 | \n",
" 0.9070 | \n",
"
\n",
" \n",
" | 31 | \n",
" Sero-195 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.0949 | \n",
" 0.9051 | \n",
"
\n",
" \n",
" | 32 | \n",
" Sero-215 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1731 | \n",
" 0.8269 | \n",
"
\n",
" \n",
" | 33 | \n",
" Sero-218 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.4813 | \n",
" 0.5187 | \n",
"
\n",
" \n",
" | 34 | \n",
" Sero-226 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1585 | \n",
" 0.8415 | \n",
"
\n",
" \n",
" | 35 | \n",
" Sero-229 | \n",
" 2 | \n",
" 1 | \n",
" 0.0002 | \n",
" 0.9990 | \n",
" 0.0008 | \n",
"
\n",
" \n",
" | 36 | \n",
" Sero-230 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.4955 | \n",
" 0.5045 | \n",
"
\n",
" \n",
" | 37 | \n",
" Sero-232 | \n",
" 2 | \n",
" 1 | \n",
" 0.7391 | \n",
" 0.2608 | \n",
" 0.0001 | \n",
"
\n",
" \n",
" | 38 | \n",
" Sero-232 | \n",
" 3 | \n",
" 2 | \n",
" 0.7930 | \n",
" 0.2069 | \n",
" 0.0001 | \n",
"
\n",
" \n",
" | 39 | \n",
" Sero-232 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9999 | \n",
" 0.0001 | \n",
"
\n",
" \n",
" | 40 | \n",
" Sero-242 | \n",
" 2 | \n",
" 1 | \n",
" 0.0066 | \n",
" 0.9889 | \n",
" 0.0045 | \n",
"
\n",
" \n",
" | 41 | \n",
" Sero-244 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.1184 | \n",
" 0.8816 | \n",
"
\n",
" \n",
" | 42 | \n",
" Sero-256 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.3498 | \n",
" 0.6502 | \n",
"
\n",
" \n",
" | 43 | \n",
" Sero-258 | \n",
" 3 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.8536 | \n",
" 0.1464 | \n",
"
\n",
" \n",
" | 44 | \n",
" Sero-258 | \n",
" 4 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9372 | \n",
" 0.0628 | \n",
"
\n",
" \n",
" | 45 | \n",
" Sero-267 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.7976 | \n",
" 0.2024 | \n",
"
\n",
" \n",
" | 46 | \n",
" Sero-277 | \n",
" 2 | \n",
" 1 | \n",
" 0.0000 | \n",
" 0.9551 | \n",
" 0.0449 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" patient_id episode relapse_source_epi C L I\n",
"0 Sero-040 3 1 0.0000 0.4412 0.5588\n",
"1 Sero-041 2 1 0.4113 0.5611 0.0276\n",
"2 Sero-041 3 2 0.1759 0.7901 0.0341\n",
"3 Sero-041 4 1 0.0000 0.9785 0.0215\n",
"4 Sero-041 5 1 0.0000 0.9785 0.0215\n",
"5 Sero-041 6 1 0.0000 0.1282 0.8718\n",
"6 Sero-048 2 1 0.0000 0.2813 0.7187\n",
"7 Sero-048 3 1 0.0000 0.1603 0.8397\n",
"8 Sero-048 5 1 0.0000 0.1603 0.8397\n",
"9 Sero-081 3 1 0.0000 0.3995 0.6005\n",
"10 Sero-086 2 1 0.0656 0.8952 0.0392\n",
"11 Sero-103 3 1 0.0000 0.1925 0.8075\n",
"12 Sero-105 6 1 0.0000 0.4750 0.5250\n",
"13 Sero-107 4 1 0.0000 0.1009 0.8991\n",
"14 Sero-109 3 1 0.0000 0.7522 0.2478\n",
"15 Sero-110 2 1 0.0000 0.5647 0.4353\n",
"16 Sero-130 2 1 0.0000 0.1440 0.8560\n",
"17 Sero-131 2 1 0.0010 0.9840 0.0150\n",
"18 Sero-131 3 1 0.0000 0.2770 0.7230\n",
"19 Sero-138 5 1 0.0000 0.1460 0.8540\n",
"20 Sero-139 2 1 0.5857 0.3897 0.0246\n",
"21 Sero-142 2 1 0.0000 0.3768 0.6232\n",
"22 Sero-142 3 1 0.0000 0.1754 0.8246\n",
"23 Sero-148 3 1 0.0000 0.1023 0.8977\n",
"24 Sero-154 2 1 0.0000 0.9993 0.0007\n",
"25 Sero-161 2 1 0.0000 0.9723 0.0277\n",
"26 Sero-161 3 2 0.3471 0.6463 0.0066\n",
"27 Sero-161 4 1 0.0000 0.9899 0.0101\n",
"28 Sero-182 3 1 0.0000 0.0935 0.9065\n",
"29 Sero-194 3 1 0.0000 0.0681 0.9319\n",
"30 Sero-194 4 1 0.0000 0.0930 0.9070\n",
"31 Sero-195 3 1 0.0000 0.0949 0.9051\n",
"32 Sero-215 2 1 0.0000 0.1731 0.8269\n",
"33 Sero-218 2 1 0.0000 0.4813 0.5187\n",
"34 Sero-226 3 1 0.0000 0.1585 0.8415\n",
"35 Sero-229 2 1 0.0002 0.9990 0.0008\n",
"36 Sero-230 3 1 0.0000 0.4955 0.5045\n",
"37 Sero-232 2 1 0.7391 0.2608 0.0001\n",
"38 Sero-232 3 2 0.7930 0.2069 0.0001\n",
"39 Sero-232 4 1 0.0000 0.9999 0.0001\n",
"40 Sero-242 2 1 0.0066 0.9889 0.0045\n",
"41 Sero-244 2 1 0.0000 0.1184 0.8816\n",
"42 Sero-256 2 1 0.0000 0.3498 0.6502\n",
"43 Sero-258 3 1 0.0000 0.8536 0.1464\n",
"44 Sero-258 4 1 0.0000 0.9372 0.0628\n",
"45 Sero-267 2 1 0.0000 0.7976 0.2024\n",
"46 Sero-277 2 1 0.0000 0.9551 0.0449"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bd2dc041",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" C | \n",
" L | \n",
" I | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0.0000 | \n",
" 0.4412 | \n",
" 0.5588 | \n",
"
\n",
" \n",
" | 1 | \n",
" 0.0000 | \n",
" 0.1282 | \n",
" 0.8718 | \n",
"
\n",
" \n",
" | 2 | \n",
" 0.0103 | \n",
" 0.9684 | \n",
" 0.0213 | \n",
"
\n",
" \n",
" | 3 | \n",
" 0.1425 | \n",
" 0.6402 | \n",
" 0.2173 | \n",
"
\n",
" \n",
" | 4 | \n",
" 0.0000 | \n",
" 0.4368 | \n",
" 0.5632 | \n",
"
\n",
" \n",
" | 5 | \n",
" 0.4113 | \n",
" 0.5611 | \n",
" 0.0276 | \n",
"
\n",
" \n",
" | 6 | \n",
" 0.0000 | \n",
" 0.0833 | \n",
" 0.9167 | \n",
"
\n",
" \n",
" | 7 | \n",
" 0.0000 | \n",
" 0.1084 | \n",
" 0.8916 | \n",
"
\n",
" \n",
" | 8 | \n",
" 0.0000 | \n",
" 0.2813 | \n",
" 0.7187 | \n",
"
\n",
" \n",
" | 9 | \n",
" 0.0000 | \n",
" 0.1603 | \n",
" 0.8397 | \n",
"
\n",
" \n",
" | 10 | \n",
" 0.0000 | \n",
" 0.3995 | \n",
" 0.6005 | \n",
"
\n",
" \n",
" | 11 | \n",
" 0.0656 | \n",
" 0.8952 | \n",
" 0.0392 | \n",
"
\n",
" \n",
" | 12 | \n",
" 0.0000 | \n",
" 0.1925 | \n",
" 0.8075 | \n",
"
\n",
" \n",
" | 13 | \n",
" 0.0000 | \n",
" 0.4750 | \n",
" 0.5250 | \n",
"
\n",
" \n",
" | 14 | \n",
" 0.0000 | \n",
" 0.1009 | \n",
" 0.8991 | \n",
"
\n",
" \n",
" | 15 | \n",
" 0.0000 | \n",
" 0.7522 | \n",
" 0.2478 | \n",
"
\n",
" \n",
" | 16 | \n",
" 0.0000 | \n",
" 0.5647 | \n",
" 0.4353 | \n",
"
\n",
" \n",
" | 17 | \n",
" 0.0000 | \n",
" 0.1440 | \n",
" 0.8560 | \n",
"
\n",
" \n",
" | 18 | \n",
" 0.0010 | \n",
" 0.9841 | \n",
" 0.0150 | \n",
"
\n",
" \n",
" | 19 | \n",
" 0.0000 | \n",
" 0.2770 | \n",
" 0.7230 | \n",
"
\n",
" \n",
" | 20 | \n",
" 0.0000 | \n",
" 0.1460 | \n",
" 0.8540 | \n",
"
\n",
" \n",
" | 21 | \n",
" 0.5857 | \n",
" 0.3897 | \n",
" 0.0246 | \n",
"
\n",
" \n",
" | 22 | \n",
" 0.0000 | \n",
" 0.3768 | \n",
" 0.6232 | \n",
"
\n",
" \n",
" | 23 | \n",
" 0.0000 | \n",
" 0.1754 | \n",
" 0.8246 | \n",
"
\n",
" \n",
" | 24 | \n",
" 0.0000 | \n",
" 0.1023 | \n",
" 0.8977 | \n",
"
\n",
" \n",
" | 25 | \n",
" 0.0000 | \n",
" 0.9993 | \n",
" 0.0007 | \n",
"
\n",
" \n",
" | 26 | \n",
" 0.0000 | \n",
" 0.9722 | \n",
" 0.0277 | \n",
"
\n",
" \n",
" | 27 | \n",
" 0.0000 | \n",
" 0.1487 | \n",
" 0.8513 | \n",
"
\n",
" \n",
" | 28 | \n",
" 0.3471 | \n",
" 0.6463 | \n",
" 0.0066 | \n",
"
\n",
" \n",
" | 29 | \n",
" 0.0000 | \n",
" 0.0935 | \n",
" 0.9065 | \n",
"
\n",
" \n",
" | 30 | \n",
" 0.0000 | \n",
" 0.0681 | \n",
" 0.9319 | \n",
"
\n",
" \n",
" | 31 | \n",
" 0.0000 | \n",
" 0.0930 | \n",
" 0.9070 | \n",
"
\n",
" \n",
" | 32 | \n",
" 0.0000 | \n",
" 0.0949 | \n",
" 0.9051 | \n",
"
\n",
" \n",
" | 33 | \n",
" 0.0000 | \n",
" 0.1731 | \n",
" 0.8269 | \n",
"
\n",
" \n",
" | 34 | \n",
" 0.0000 | \n",
" 0.4813 | \n",
" 0.5187 | \n",
"
\n",
" \n",
" | 35 | \n",
" 0.0000 | \n",
" 0.1585 | \n",
" 0.8415 | \n",
"
\n",
" \n",
" | 36 | \n",
" 0.0002 | \n",
" 0.9989 | \n",
" 0.0008 | \n",
"
\n",
" \n",
" | 37 | \n",
" 0.0000 | \n",
" 0.4955 | \n",
" 0.5045 | \n",
"
\n",
" \n",
" | 38 | \n",
" 0.0334 | \n",
" 0.9617 | \n",
" 0.0049 | \n",
"
\n",
" \n",
" | 39 | \n",
" 0.7391 | \n",
" 0.2608 | \n",
" 0.0001 | \n",
"
\n",
" \n",
" | 40 | \n",
" 0.7930 | \n",
" 0.2069 | \n",
" 0.0001 | \n",
"
\n",
" \n",
" | 41 | \n",
" 0.0066 | \n",
" 0.9888 | \n",
" 0.0045 | \n",
"
\n",
" \n",
" | 42 | \n",
" 0.0000 | \n",
" 0.1184 | \n",
" 0.8816 | \n",
"
\n",
" \n",
" | 43 | \n",
" 0.0000 | \n",
" 0.3498 | \n",
" 0.6502 | \n",
"
\n",
" \n",
" | 44 | \n",
" 0.0014 | \n",
" 0.9359 | \n",
" 0.0627 | \n",
"
\n",
" \n",
" | 45 | \n",
" 0.0000 | \n",
" 0.8535 | \n",
" 0.1464 | \n",
"
\n",
" \n",
" | 46 | \n",
" 0.0000 | \n",
" 0.7976 | \n",
" 0.2024 | \n",
"
\n",
" \n",
" | 47 | \n",
" 0.0000 | \n",
" 0.9551 | \n",
" 0.0449 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" C L I\n",
"0 0.0000 0.4412 0.5588\n",
"1 0.0000 0.1282 0.8718\n",
"2 0.0103 0.9684 0.0213\n",
"3 0.1425 0.6402 0.2173\n",
"4 0.0000 0.4368 0.5632\n",
"5 0.4113 0.5611 0.0276\n",
"6 0.0000 0.0833 0.9167\n",
"7 0.0000 0.1084 0.8916\n",
"8 0.0000 0.2813 0.7187\n",
"9 0.0000 0.1603 0.8397\n",
"10 0.0000 0.3995 0.6005\n",
"11 0.0656 0.8952 0.0392\n",
"12 0.0000 0.1925 0.8075\n",
"13 0.0000 0.4750 0.5250\n",
"14 0.0000 0.1009 0.8991\n",
"15 0.0000 0.7522 0.2478\n",
"16 0.0000 0.5647 0.4353\n",
"17 0.0000 0.1440 0.8560\n",
"18 0.0010 0.9841 0.0150\n",
"19 0.0000 0.2770 0.7230\n",
"20 0.0000 0.1460 0.8540\n",
"21 0.5857 0.3897 0.0246\n",
"22 0.0000 0.3768 0.6232\n",
"23 0.0000 0.1754 0.8246\n",
"24 0.0000 0.1023 0.8977\n",
"25 0.0000 0.9993 0.0007\n",
"26 0.0000 0.9722 0.0277\n",
"27 0.0000 0.1487 0.8513\n",
"28 0.3471 0.6463 0.0066\n",
"29 0.0000 0.0935 0.9065\n",
"30 0.0000 0.0681 0.9319\n",
"31 0.0000 0.0930 0.9070\n",
"32 0.0000 0.0949 0.9051\n",
"33 0.0000 0.1731 0.8269\n",
"34 0.0000 0.4813 0.5187\n",
"35 0.0000 0.1585 0.8415\n",
"36 0.0002 0.9989 0.0008\n",
"37 0.0000 0.4955 0.5045\n",
"38 0.0334 0.9617 0.0049\n",
"39 0.7391 0.2608 0.0001\n",
"40 0.7930 0.2069 0.0001\n",
"41 0.0066 0.9888 0.0045\n",
"42 0.0000 0.1184 0.8816\n",
"43 0.0000 0.3498 0.6502\n",
"44 0.0014 0.9359 0.0627\n",
"45 0.0000 0.8535 0.1464\n",
"46 0.0000 0.7976 0.2024\n",
"47 0.0000 0.9551 0.0449"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp3"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" sample_id_paired | \n",
" pair_id | \n",
" patient_id | \n",
" post_C | \n",
" post_L | \n",
" post_I | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2401 | \n",
" AR-024_1-DF0 | \n",
" AR-024_10 | \n",
" AR-024 | \n",
" 0.000000 | \n",
" 0.181853 | \n",
" 8.181471e-01 | \n",
"
\n",
" \n",
" | 2357 | \n",
" AR-024_3-DF | \n",
" AR-024_3 | \n",
" AR-024 | \n",
" 0.747905 | \n",
" 0.252095 | \n",
" 7.417523e-08 | \n",
"
\n",
" \n",
" | 2378 | \n",
" AR-024_8-DF | \n",
" AR-024_8 | \n",
" AR-024 | \n",
" 0.688672 | \n",
" 0.311328 | \n",
" 5.231539e-08 | \n",
"
\n",
" \n",
" | 2189 | \n",
" AR-067_1-DF | \n",
" AR-067_1 | \n",
" AR-067 | \n",
" 0.000000 | \n",
" 0.997268 | \n",
" 2.731921e-03 | \n",
"
\n",
" \n",
" | 2480 | \n",
" AR-081_1-DF | \n",
" AR-081_1 | \n",
" AR-081 | \n",
" 0.000000 | \n",
" 0.121702 | \n",
" 8.782983e-01 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 469 | \n",
" Sero-256-DF_1 | \n",
" Sero-256_1 | \n",
" Sero-256 | \n",
" 0.000000 | \n",
" 0.169196 | \n",
" 8.308039e-01 | \n",
"
\n",
" \n",
" | 499 | \n",
" Sero-258-DF_3 | \n",
" Sero-258_3 | \n",
" Sero-258 | \n",
" 0.000000 | \n",
" 0.936023 | \n",
" 6.397652e-02 | \n",
"
\n",
" \n",
" | 530 | \n",
" Sero-258-DF_6 | \n",
" Sero-258_6 | \n",
" Sero-258 | \n",
" 0.000000 | \n",
" 0.743152 | \n",
" 2.568480e-01 | \n",
"
\n",
" \n",
" | 641 | \n",
" Sero-267-DF_1 | \n",
" Sero-267_1 | \n",
" Sero-267 | \n",
" 0.000000 | \n",
" 0.520532 | \n",
" 4.794680e-01 | \n",
"
\n",
" \n",
" | 609 | \n",
" Sero-277-DF_1 | \n",
" Sero-277_1 | \n",
" Sero-277 | \n",
" 0.000000 | \n",
" 0.994670 | \n",
" 5.329520e-03 | \n",
"
\n",
" \n",
"
\n",
"
85 rows × 6 columns
\n",
"
"
],
"text/plain": [
" sample_id_paired pair_id patient_id post_C post_L post_I\n",
"2401 AR-024_1-DF0 AR-024_10 AR-024 0.000000 0.181853 8.181471e-01\n",
"2357 AR-024_3-DF AR-024_3 AR-024 0.747905 0.252095 7.417523e-08\n",
"2378 AR-024_8-DF AR-024_8 AR-024 0.688672 0.311328 5.231539e-08\n",
"2189 AR-067_1-DF AR-067_1 AR-067 0.000000 0.997268 2.731921e-03\n",
"2480 AR-081_1-DF AR-081_1 AR-081 0.000000 0.121702 8.782983e-01\n",
"... ... ... ... ... ... ...\n",
"469 Sero-256-DF_1 Sero-256_1 Sero-256 0.000000 0.169196 8.308039e-01\n",
"499 Sero-258-DF_3 Sero-258_3 Sero-258 0.000000 0.936023 6.397652e-02\n",
"530 Sero-258-DF_6 Sero-258_6 Sero-258 0.000000 0.743152 2.568480e-01\n",
"641 Sero-267-DF_1 Sero-267_1 Sero-267 0.000000 0.520532 4.794680e-01\n",
"609 Sero-277-DF_1 Sero-277_1 Sero-277 0.000000 0.994670 5.329520e-03\n",
"\n",
"[85 rows x 6 columns]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temp2 = real_data_test[real_data_test.pair_id.isin(real_data_test_lc.pair_id.unique())]\n",
"temp2[['sample_id_paired', 'pair_id', 'patient_id', 'post_C', 'post_L', 'post_I']].drop_duplicates().sort_values('sample_id_paired')"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2539, 21)"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real_data_test_lc.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c05a857",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "cbf23b97",
"metadata": {},
"source": [
"prepatring for model"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "580a4347",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" patient_id | \n",
" sample_id | \n",
" episode | \n",
" marker | \n",
" allele | \n",
" frequency | \n",
" country | \n",
" MOIs | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Sero-040 | \n",
" Sero-040-R01 | \n",
" 1.0 | \n",
" Chr01 | \n",
" Chr01-1 | \n",
" 0.531524 | \n",
" ethiopia | \n",
" 6 | \n",
"
\n",
" \n",
" | 1 | \n",
" Sero-182 | \n",
" Sero-182-R12 | \n",
" 3.0 | \n",
" Chr11 | \n",
" Chr11-2 | \n",
" 0.149320 | \n",
" ethiopia | \n",
" 3 | \n",
"
\n",
" \n",
" | 2 | \n",
" Sero-182 | \n",
" Sero-182-R12 | \n",
" 3.0 | \n",
" Chr13 | \n",
" Chr13-1 | \n",
" 0.729045 | \n",
" ethiopia | \n",
" 3 | \n",
"
\n",
" \n",
" | 3 | \n",
" Sero-182 | \n",
" Sero-182-R12 | \n",
" 3.0 | \n",
" Chr13 | \n",
" Chr13-2 | \n",
" 0.129575 | \n",
" ethiopia | \n",
" 3 | \n",
"
\n",
" \n",
" | 4 | \n",
" Sero-182 | \n",
" Sero-182-R12 | \n",
" 3.0 | \n",
" Chr14 | \n",
" Chr14-1 | \n",
" 0.931269 | \n",
" ethiopia | \n",
" 3 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 6734 | \n",
" AR-322 | \n",
" AR-322-140 | \n",
" 2.0 | \n",
" Chr03 | \n",
" Chr03-1 | \n",
" 0.526098 | \n",
" solomon_island | \n",
" 2 | \n",
"
\n",
" \n",
" | 6735 | \n",
" AR-322 | \n",
" AR-322-140 | \n",
" 2.0 | \n",
" Chr02 | \n",
" Chr02-2 | \n",
" 0.148837 | \n",
" solomon_island | \n",
" 2 | \n",
"
\n",
" \n",
" | 6736 | \n",
" AR-322 | \n",
" AR-322-140 | \n",
" 2.0 | \n",
" Chr02 | \n",
" Chr02-6 | \n",
" 0.042156 | \n",
" solomon_island | \n",
" 2 | \n",
"
\n",
" \n",
" | 6737 | \n",
" AR-302 | \n",
" AR-302-0 | \n",
" 2.0 | \n",
" Chr11 | \n",
" Chr11-2 | \n",
" 0.232755 | \n",
" solomon_island | \n",
" 2 | \n",
"
\n",
" \n",
" | 6738 | \n",
" AR-382 | \n",
" AR-382-168 | \n",
" 2.0 | \n",
" Chr14 | \n",
" Chr14-1 | \n",
" 0.244186 | \n",
" solomon_island | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
6739 rows × 8 columns
\n",
"
"
],
"text/plain": [
" patient_id sample_id episode marker allele frequency \\\n",
"0 Sero-040 Sero-040-R01 1.0 Chr01 Chr01-1 0.531524 \n",
"1 Sero-182 Sero-182-R12 3.0 Chr11 Chr11-2 0.149320 \n",
"2 Sero-182 Sero-182-R12 3.0 Chr13 Chr13-1 0.729045 \n",
"3 Sero-182 Sero-182-R12 3.0 Chr13 Chr13-2 0.129575 \n",
"4 Sero-182 Sero-182-R12 3.0 Chr14 Chr14-1 0.931269 \n",
"... ... ... ... ... ... ... \n",
"6734 AR-322 AR-322-140 2.0 Chr03 Chr03-1 0.526098 \n",
"6735 AR-322 AR-322-140 2.0 Chr02 Chr02-2 0.148837 \n",
"6736 AR-322 AR-322-140 2.0 Chr02 Chr02-6 0.042156 \n",
"6737 AR-302 AR-302-0 2.0 Chr11 Chr11-2 0.232755 \n",
"6738 AR-382 AR-382-168 2.0 Chr14 Chr14-1 0.244186 \n",
"\n",
" country MOIs \n",
"0 ethiopia 6 \n",
"1 ethiopia 3 \n",
"2 ethiopia 3 \n",
"3 ethiopia 3 \n",
"4 ethiopia 3 \n",
"... ... ... \n",
"6734 solomon_island 2 \n",
"6735 solomon_island 2 \n",
"6736 solomon_island 2 \n",
"6737 solomon_island 2 \n",
"6738 solomon_island 1 \n",
"\n",
"[6739 rows x 8 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"real_data = pd.read_csv('../datasets/pvAmpSeq_simulation_ready.csv')\n",
"real_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e99846b1",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"id": "d53547f3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['patient_id', 'sample_id', 'episode', 'marker', 'allele', 'frequency',\n",
" 'country', 'mois', 'loci'],\n",
" dtype='object')"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"real_data.columns.str.lower()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "1fa0def5",
"metadata": {},
"outputs": [],
"source": [
"real_data.drop('marker', axis=1, inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "87d4246d",
"metadata": {},
"outputs": [],
"source": [
"real_data['loci'] = 3"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "d39d95f0",
"metadata": {},
"outputs": [],
"source": [
"if 'loci' in real_data.columns and not 'marker' in real_data.columns:\n",
" print(True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "42e83ca5",
"metadata": {},
"outputs": [],
"source": [
"# preparing data sample dataset for GUI test\n",
"\n",
"sample_data = real_data[real_data.country != 'ethiopia']\n",
"\n",
"sampled_patients = sample_data['patient_id'].sample(20)\n",
"mapping_dict = {}\n",
"for i, p_id in enumerate(sampled_patients):\n",
" mapping_dict[p_id] = \"P0\" + str(i+1) if i <9 else \"P\" + str(i+1)\n",
"\n",
"sample_data = sample_data[sample_data.patient_id.isin(sampled_patients)]\n",
"sample_data['patient_id'] = sample_data['patient_id'].map(mapping_dict)\n",
"sample_data = sample_data.drop(['sample_id', 'frequency', 'MOIs'], axis=1)\n",
"\n",
"\n",
"country_map = {'peru':'C1', 'solomon_island':'C2'}\n",
"sample_data['country'] = sample_data['country'].map(country_map)\n",
"sample_data = sample_data.sort_values('patient_id').reset_index(drop=True)\n",
"sample_data.to_csv('../datasets/GUI_sample_dataset.csv', index=False)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7fa2cb72",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ccf2bd51",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pair_id | \n",
" prob_C | \n",
" prob_L | \n",
" prob_I | \n",
" predicted_class | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" AR-024_P1 | \n",
" 3.471411e-07 | \n",
" 0.304471 | \n",
" 6.955286e-01 | \n",
" I | \n",
"
\n",
" \n",
" | 1 | \n",
" AR-024_P10 | \n",
" 3.380386e-09 | \n",
" 0.173901 | \n",
" 8.260994e-01 | \n",
" I | \n",
"
\n",
" \n",
" | 2 | \n",
" AR-024_P2 | \n",
" 9.909202e-04 | \n",
" 0.999007 | \n",
" 2.018461e-06 | \n",
" L | \n",
"
\n",
" \n",
" | 3 | \n",
" AR-024_P3 | \n",
" 6.369301e-01 | \n",
" 0.363069 | \n",
" 4.884979e-07 | \n",
" C | \n",
"
\n",
" \n",
" | 4 | \n",
" AR-024_P4 | \n",
" 4.486354e-09 | \n",
" 0.172445 | \n",
" 8.275549e-01 | \n",
" I | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" pair_id prob_C prob_L prob_I predicted_class\n",
"0 AR-024_P1 3.471411e-07 0.304471 6.955286e-01 I\n",
"1 AR-024_P10 3.380386e-09 0.173901 8.260994e-01 I\n",
"2 AR-024_P2 9.909202e-04 0.999007 2.018461e-06 L\n",
"3 AR-024_P3 6.369301e-01 0.363069 4.884979e-07 C\n",
"4 AR-024_P4 4.486354e-09 0.172445 8.275549e-01 I"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = result['results_table']\n",
"df = df[['pair_id', 'prob_C', 'prob_L','prob_I','predicted_class']].drop_duplicates().reset_index(drop=True)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "97639f81",
"metadata": {},
"outputs": [],
"source": [
"def apply_class_order(p_class):\n",
" if p_class == 'C':\n",
" return 1\n",
" elif p_class == 'L':\n",
" return 2\n",
" else: return 3\n",
"\n",
"df['class_order'] = df['predicted_class'].apply(apply_class_order)\n",
"\n",
"df = df.sort_values(['class_order']).reset_index(drop=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fdf63901",
"metadata": {},
"outputs": [],
"source": [
"import plotly.express as px\n",
"import pandas as pd\n",
"\n",
"df = result['results_table']\n",
"df = df[['pair_id', 'prob_C', 'prob_L','prob_I','predicted_class']].drop_duplicates().reset_index(drop=True)\n",
"df_C = df[df.predicted_class == 'C'].sort_values('prob_C', ascending=False).reset_index(drop=True)\n",
"df_L = df[df.predicted_class == 'L'].sort_values('prob_L', ascending=False).reset_index(drop=True)\n",
"df_I = df[df.predicted_class == 'I'].sort_values('prob_I', ascending=False).reset_index(drop=True)\n",
"\n",
"df = pd.concat([df_C, df_L, df_I], ignore_index=True)\n",
"\n",
"df_long = df.melt(\n",
" id_vars=['pair_id'], \n",
" value_vars=['prob_C', 'prob_L', 'prob_I'],\n",
" var_name='Probability_Type', \n",
" value_name='Probability'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "3af62b53",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"I"
],
[
"L"
],
[
"C"
],
[
"undefined"
]
],
"domain": {
"x": [
0,
1
],
"y": [
0,
1
]
},
"hole": 0.5,
"hovertemplate": "Class=%{customdata[0]}
Count=%{value}",
"labels": [
"I",
"L",
"C",
"undefined"
],
"legendgroup": "",
"marker": {
"colors": [
"#1fb3c4",
"#e6b400",
"#ff4d00",
"#ab63fa"
],
"line": {
"color": "#FFFFFF",
"width": 2
}
},
"name": "",
"showlegend": true,
"textinfo": "percent+label",
"textposition": "inside",
"type": "pie",
"values": {
"bdata": "4QCCACYAAQA=",
"dtype": "i2"
}
}
],
"layout": {
"height": 500,
"legend": {
"orientation": "h",
"title": {},
"tracegroupgap": 0,
"x": 0.5,
"xanchor": "center",
"y": 1.05,
"yanchor": "bottom"
},
"margin": {
"b": 20,
"l": 20,
"r": 20,
"t": 60
},
"paper_bgcolor": "white",
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "#C8D4E3",
"linecolor": "#C8D4E3",
"minorgridcolor": "#C8D4E3",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "#C8D4E3",
"linecolor": "#C8D4E3",
"minorgridcolor": "#C8D4E3",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermap": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermap"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "white",
"showlakes": true,
"showland": true,
"subunitcolor": "#C8D4E3"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "white",
"polar": {
"angularaxis": {
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": ""
},
"bgcolor": "white",
"radialaxis": {
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
},
"yaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
},
"zaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
},
"baxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
},
"bgcolor": "white",
"caxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "#EBF0F8",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "#EBF0F8",
"zerolinewidth": 2
}
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.express as px\n",
"import pandas as pd\n",
"\n",
"# 1. Prepare the data\n",
"# Assuming 'df' is your processed dataframe from the previous step\n",
"counts_df = df['predicted_class'].value_counts().reset_index()\n",
"counts_df.columns = ['Class', 'Count']\n",
"\n",
"# 2. Create the Donut Chart\n",
"fig = px.pie(\n",
" counts_df, \n",
" values='Count', \n",
" names='Class', \n",
" hole=0.5, # This creates the \"donut\" effect\n",
" color='Class',\n",
" # Keeping colors consistent: Orange (C), Yellow (L), Teal (I)\n",
" color_discrete_map={\n",
" 'C': '#ff4d00', \n",
" 'L': '#e6b400', \n",
" 'I': '#1fb3c4'\n",
" },\n",
" template=\"plotly_white\"\n",
")\n",
"\n",
"# 3. Refine the layout to match your previous style\n",
"fig.update_layout(\n",
" margin=dict(l=20, r=20, t=60, b=20),\n",
" height=500,\n",
" paper_bgcolor='white',\n",
" # Horizontal legend at the top\n",
" legend=dict(\n",
" orientation=\"h\",\n",
" yanchor=\"bottom\",\n",
" y=1.05,\n",
" xanchor=\"center\",\n",
" x=0.5,\n",
" title=None\n",
" )\n",
")\n",
"\n",
"# 4. Enhance the traces (labels and percentages)\n",
"fig.update_traces(\n",
" textposition='inside', \n",
" textinfo='percent+label', # Shows the Class name and %\n",
" marker=dict(line=dict(color='#FFFFFF', width=2)) # Adds a small white gap between segments\n",
")\n",
"\n",
"fig.show()\n"
]
},
{
"cell_type": "code",
"execution_count": 74,
"id": "3860e7d0",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "Probability_Type=prob_C
pair_id=%{x}
Probability=%{y}",
"legendgroup": "prob_C",
"marker": {
"color": "#ff4d00",
"pattern": {
"shape": ""
}
},
"name": "prob_C",
"orientation": "v",
"showlegend": true,
"textposition": "auto",
"type": "bar",
"x": [
"AR-346_P1",
"AR-359_P10",
"M1A007F_P1",
"Sero-232_P6",
"Sero-273_P1",
"AR-110_P1",
"AR-348_P1",
"AR-187_P4",
"AR-359_P7",
"AR-359_P6",
"Sero-232_P5",
"Sero-232_P4",
"AR-024_P8",
"M1E026C_P1",
"AR-359_P8",
"AR-382_P1",
"M1D036A_P1",
"AR-187_P6",
"AR-187_P5",
"AR-306_P3",
"AR-133_P3",
"AR-142_P2",
"M1D049A_P1",
"AR-359_P4",
"M1E036B_P1",
"Sero-226_P1",
"M1B011B_P1",
"AR-359_P11",
"AR-359_P13",
"AR-133_P1",
"AR-133_P2",
"AR-250_P1",
"AR-359_P3",
"AR-359_P2",
"AR-024_P3",
"AR-221_P1",
"AR-160_P1",
"Sero-139_P1",
"AR-081_P3",
"Sero-154_P1",
"AR-176_P3",
"AR-098_P1",
"Sero-229_P1",
"Sero-242_P3",
"Sero-271_P1",
"AR-024_P2",
"Sero-162_P1",
"Sero-157_P1",
"Sero-262_P1",
"Sero-048_P6",
"Sero-222_P1",
"Sero-138_P9",
"Sero-134_P1",
"Sero-234_P1",
"Sero-162_P3",
"Sero-271_P3",
"Sero-242_P2",
"Sero-138_P8",
"Sero-131_P1",
"Sero-269_P1",
"Sero-271_P2",
"Sero-185_P1",
"Sero-138_P10",
"Sero-234_P2",
"Sero-138_P6",
"Sero-123_P3",
"Sero-242_P1",
"Sero-194_P6",
"Sero-232_P3",
"Sero-232_P2",
"AR-248_P1",
"Sero-258_P5",
"Sero-138_P5",
"Sero-138_P7",
"M1A043E_P1",
"Sero-148_P1",
"Sero-169_P1",
"Sero-277_P1",
"Sero-101_P5",
"Sero-179_P1",
"Sero-185_P6",
"Sero-232_P1",
"AR-325_P1",
"M1A020B_P1",
"AR-237_P1",
"Sero-248_P1",
"Sero-085_P1",
"Sero-258_P3",
"Sero-258_P6",
"Sero-234_P4",
"Sero-041_P13",
"Sero-161_P1",
"Sero-109_P1",
"Sero-224_P1",
"AR-192_P1",
"Sero-224_P2",
"Sero-095_P3",
"AR-067_P1",
"AR-359_P1",
"Sero-182_P1",
"Sero-162_P2",
"AR-140_P2",
"Sero-101_P3",
"AR-326_P1",
"Sero-098_P1",
"Sero-127_P1",
"Sero-145_P1",
"Sero-041_P3",
"Sero-041_P10",
"Sero-100_P1",
"Sero-129_P1",
"Sero-258_P1",
"AR-173_P1",
"Sero-258_P2",
"Sero-083_P3",
"Sero-234_P3",
"Sero-087_P1",
"Sero-214_P2",
"AR-142_P6",
"Sero-215_P3",
"Sero-267_P1",
"Sero-158_P1",
"Sero-150_P1",
"Sero-215_P2",
"Sero-093_P3",
"Sero-109_P2",
"Sero-105_P5",
"Sero-105_P13",
"Sero-109_P3",
"Sero-209_P2",
"Sero-105_P1",
"Sero-224_P3",
"Sero-041_P5",
"Sero-054_P1",
"Sero-258_P4",
"AR-234_P1",
"AR-142_P1",
"AR-302_P1",
"Sero-130_P2",
"Sero-234_P6",
"Sero-058_P1",
"AR-258_P1",
"Sero-041_P1",
"Sero-041_P6",
"Sero-235_P1",
"M1C002A_P1",
"Sero-081_P1",
"Sero-110_P1",
"Sero-105_P6",
"Sero-081_P3",
"Sero-041_P2",
"Sero-234_P5",
"Sero-101_P6",
"Sero-230_P3",
"Sero-048_P5",
"Sero-083_P1",
"Sero-086_P1",
"Sero-196_P1",
"M1C081A_P5",
"M1E028C_P1",
"Sero-105_P9",
"Sero-130_P3",
"Sero-161_P6",
"Sero-192_P1",
"Sero-041_P7",
"Sero-253_P1",
"Sero-129_P2",
"Sero-195_P2",
"Sero-061_P1",
"Sero-209_P3",
"Sero-230_P1",
"Sero-105_P10",
"Sero-226_P2",
"Sero-191_P2",
"Sero-107_P10",
"Sero-107_P3",
"Sero-040_P3",
"AR-359_P5",
"Sero-177_P1",
"Sero-194_P2",
"Sero-185_P3",
"Sero-191_P3",
"Sero-103_P1",
"M1D026D_P1",
"Sero-107_P8",
"AR-081_P2",
"AR-142_P5",
"Sero-185_P5",
"AR-341_P1",
"Sero-143_P1",
"Sero-195_P3",
"Sero-111_P1",
"Sero-057_P1",
"Sero-110_P3",
"M1D049D_P1",
"M1E022A_P1",
"Sero-107_P2",
"AR-140_P3",
"Sero-122_P1",
"Sero-052_P1",
"Sero-182_P2",
"Sero-139_P2",
"Sero-194_P4",
"M1E036B_P2",
"M1E044C_P1",
"Sero-194_P3",
"Sero-041_P8",
"Sero-117_P1",
"Sero-041_P14",
"AR-304_P1",
"Sero-107_P6",
"Sero-230_P2",
"Sero-161_P5",
"M1C031G_P1",
"M1D036C_P1",
"Sero-095_P2",
"Sero-185_P2",
"M1A007B_P1",
"Sero-118_P1",
"AR-274_P1",
"AR-300_P1",
"AR-343_P1",
"Sero-181_P3",
"AR-024_P9",
"Sero-161_P4",
"Sero-041_P4",
"Sero-183_P1",
"AR-288_P1",
"M1B040B_P1",
"Sero-041_P15",
"Sero-110_P2",
"Sero-130_P1",
"Sero-088_P1",
"Sero-244_P1",
"Sero-048_P15",
"Sero-215_P4",
"M1A008D_P1",
"Sero-185_P4",
"M1D026A_P1",
"Sero-041_P12",
"M1E025B_P1",
"Sero-040_P6",
"Sero-041_P9",
"Sero-048_P9",
"Sero-040_P2",
"Sero-048_P13",
"Sero-103_P2",
"AR-345_P1",
"Sero-048_P12",
"M1C010B_P1",
"Sero-061_P2",
"Sero-148_P3",
"M1E044C_P3",
"M1D038D_P1",
"Sero-138_P4",
"Sero-215_P5",
"Sero-105_P11",
"Sero-148_P2",
"AR-081_P1",
"Sero-150_P2",
"Sero-161_P3",
"AR-140_P1",
"Sero-138_P1",
"AR-359_P9",
"Sero-048_P8",
"Sero-107_P7",
"Sero-226_P3",
"Sero-288_P1",
"M1E044C_P2",
"Sero-138_P3",
"Sero-048_P11",
"Sero-181_P2",
"M1D024B_P1",
"Sero-041_P11",
"Sero-105_P12",
"AR-359_P15",
"Sero-102_P1",
"Sero-150_P3",
"M1A161C_P1",
"Sero-209_P1",
"M1E036B_P3",
"Sero-066_P1",
"AR-024_P4",
"AR-024_P10",
"AR-024_P7",
"M1D026A_P3",
"Sero-101_P1",
"Sero-048_P4",
"AR-355_P1",
"AR-024_P5",
"Sero-048_P7",
"Sero-093_P1",
"AR-359_P14",
"AR-359_P12",
"AR-176_P2",
"Sero-142_P2",
"AR-176_P1",
"Sero-048_P14",
"M1D026D_P2",
"Sero-215_P6",
"Sero-107_P9",
"Sero-131_P3",
"M1D026A_P2",
"AR-142_P4",
"M1C081A_P4",
"Sero-194_P5",
"AR-322_P1",
"M1A083D_P1",
"Sero-083_P2",
"M1D049D_P3",
"M1C081A_P6",
"Sero-123_P1",
"Sero-095_P1",
"Sero-081_P2",
"Sero-142_P3",
"M1D042A_P1",
"Sero-182_P3",
"AR-328_P3",
"Sero-129_P3",
"AR-328_P1",
"Sero-048_P3",
"Sero-181_P1",
"Sero-061_P3",
"Sero-139_P3",
"M1E016A_P1",
"Sero-105_P15",
"Sero-194_P1",
"Sero-105_P7",
"Sero-094_P1",
"Sero-048_P10",
"M1D026D_P3",
"Sero-189_P1",
"Sero-215_P1",
"M1B020F_P1",
"Sero-105_P8",
"M1C019D_P1",
"AR-306_P1",
"Sero-105_P4",
"Sero-049_P1",
"Sero-107_P4",
"M1C081A_P1",
"AR-187_P2",
"AR-187_P1",
"M1A085C_P1",
"AR-328_P2",
"M1C061B_P1",
"Sero-114_P1",
"Sero-191_P1",
"Sero-161_P2",
"M1A082B_P1",
"Sero-105_P3",
"AR-383_P1",
"AR-024_P6",
"M1D010A_P1",
"M1E042B_P1",
"Sero-214_P1",
"AR-142_P3",
"Sero-218_P1",
"Sero-105_P14",
"M1C081A_P3",
"AR-024_P1",
"Sero-281_P1",
"Sero-123_P2",
"Sero-256_P1",
"M1D019A_P1",
"AR-187_P3",
"AR-246_P1",
"M1C081A_P2",
"Sero-131_P2",
"Sero-040_P1",
"M1C007E_P1",
"Sero-156_P1",
"Sero-138_P2",
"Sero-107_P1",
"Sero-093_P2",
"Sero-214_P3",
"Sero-101_P2",
"Sero-142_P1",
"Sero-107_P5",
"Sero-048_P1",
"Sero-195_P1",
"AR-214_P1",
"Sero-040_P4",
"Sero-048_P2",
"Sero-105_P2",
"M1D006D_P1",
"Sero-097_P1",
"Sero-040_P5",
"AR-306_P2",
"Sero-103_P3",
"Sero-101_P4",
"M1C090C_P1",
"AR-366_P1"
],
"xaxis": "x",
"y": {
"bdata": "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",
"dtype": "f4"
},
"yaxis": "y"
},
{
"hovertemplate": "Probability_Type=prob_L
pair_id=%{x}
Probability=%{y}",
"legendgroup": "prob_L",
"marker": {
"color": "#e6b400",
"pattern": {
"shape": ""
}
},
"name": "prob_L",
"orientation": "v",
"showlegend": true,
"textposition": "auto",
"type": "bar",
"x": [
"AR-346_P1",
"AR-359_P10",
"M1A007F_P1",
"Sero-232_P6",
"Sero-273_P1",
"AR-110_P1",
"AR-348_P1",
"AR-187_P4",
"AR-359_P7",
"AR-359_P6",
"Sero-232_P5",
"Sero-232_P4",
"AR-024_P8",
"M1E026C_P1",
"AR-359_P8",
"AR-382_P1",
"M1D036A_P1",
"AR-187_P6",
"AR-187_P5",
"AR-306_P3",
"AR-133_P3",
"AR-142_P2",
"M1D049A_P1",
"AR-359_P4",
"M1E036B_P1",
"Sero-226_P1",
"M1B011B_P1",
"AR-359_P11",
"AR-359_P13",
"AR-133_P1",
"AR-133_P2",
"AR-250_P1",
"AR-359_P3",
"AR-359_P2",
"AR-024_P3",
"AR-221_P1",
"AR-160_P1",
"Sero-139_P1",
"AR-081_P3",
"Sero-154_P1",
"AR-176_P3",
"AR-098_P1",
"Sero-229_P1",
"Sero-242_P3",
"Sero-271_P1",
"AR-024_P2",
"Sero-162_P1",
"Sero-157_P1",
"Sero-262_P1",
"Sero-048_P6",
"Sero-222_P1",
"Sero-138_P9",
"Sero-134_P1",
"Sero-234_P1",
"Sero-162_P3",
"Sero-271_P3",
"Sero-242_P2",
"Sero-138_P8",
"Sero-131_P1",
"Sero-269_P1",
"Sero-271_P2",
"Sero-185_P1",
"Sero-138_P10",
"Sero-234_P2",
"Sero-138_P6",
"Sero-123_P3",
"Sero-242_P1",
"Sero-194_P6",
"Sero-232_P3",
"Sero-232_P2",
"AR-248_P1",
"Sero-258_P5",
"Sero-138_P5",
"Sero-138_P7",
"M1A043E_P1",
"Sero-148_P1",
"Sero-169_P1",
"Sero-277_P1",
"Sero-101_P5",
"Sero-179_P1",
"Sero-185_P6",
"Sero-232_P1",
"AR-325_P1",
"M1A020B_P1",
"AR-237_P1",
"Sero-248_P1",
"Sero-085_P1",
"Sero-258_P3",
"Sero-258_P6",
"Sero-234_P4",
"Sero-041_P13",
"Sero-161_P1",
"Sero-109_P1",
"Sero-224_P1",
"AR-192_P1",
"Sero-224_P2",
"Sero-095_P3",
"AR-067_P1",
"AR-359_P1",
"Sero-182_P1",
"Sero-162_P2",
"AR-140_P2",
"Sero-101_P3",
"AR-326_P1",
"Sero-098_P1",
"Sero-127_P1",
"Sero-145_P1",
"Sero-041_P3",
"Sero-041_P10",
"Sero-100_P1",
"Sero-129_P1",
"Sero-258_P1",
"AR-173_P1",
"Sero-258_P2",
"Sero-083_P3",
"Sero-234_P3",
"Sero-087_P1",
"Sero-214_P2",
"AR-142_P6",
"Sero-215_P3",
"Sero-267_P1",
"Sero-158_P1",
"Sero-150_P1",
"Sero-215_P2",
"Sero-093_P3",
"Sero-109_P2",
"Sero-105_P5",
"Sero-105_P13",
"Sero-109_P3",
"Sero-209_P2",
"Sero-105_P1",
"Sero-224_P3",
"Sero-041_P5",
"Sero-054_P1",
"Sero-258_P4",
"AR-234_P1",
"AR-142_P1",
"AR-302_P1",
"Sero-130_P2",
"Sero-234_P6",
"Sero-058_P1",
"AR-258_P1",
"Sero-041_P1",
"Sero-041_P6",
"Sero-235_P1",
"M1C002A_P1",
"Sero-081_P1",
"Sero-110_P1",
"Sero-105_P6",
"Sero-081_P3",
"Sero-041_P2",
"Sero-234_P5",
"Sero-101_P6",
"Sero-230_P3",
"Sero-048_P5",
"Sero-083_P1",
"Sero-086_P1",
"Sero-196_P1",
"M1C081A_P5",
"M1E028C_P1",
"Sero-105_P9",
"Sero-130_P3",
"Sero-161_P6",
"Sero-192_P1",
"Sero-041_P7",
"Sero-253_P1",
"Sero-129_P2",
"Sero-195_P2",
"Sero-061_P1",
"Sero-209_P3",
"Sero-230_P1",
"Sero-105_P10",
"Sero-226_P2",
"Sero-191_P2",
"Sero-107_P10",
"Sero-107_P3",
"Sero-040_P3",
"AR-359_P5",
"Sero-177_P1",
"Sero-194_P2",
"Sero-185_P3",
"Sero-191_P3",
"Sero-103_P1",
"M1D026D_P1",
"Sero-107_P8",
"AR-081_P2",
"AR-142_P5",
"Sero-185_P5",
"AR-341_P1",
"Sero-143_P1",
"Sero-195_P3",
"Sero-111_P1",
"Sero-057_P1",
"Sero-110_P3",
"M1D049D_P1",
"M1E022A_P1",
"Sero-107_P2",
"AR-140_P3",
"Sero-122_P1",
"Sero-052_P1",
"Sero-182_P2",
"Sero-139_P2",
"Sero-194_P4",
"M1E036B_P2",
"M1E044C_P1",
"Sero-194_P3",
"Sero-041_P8",
"Sero-117_P1",
"Sero-041_P14",
"AR-304_P1",
"Sero-107_P6",
"Sero-230_P2",
"Sero-161_P5",
"M1C031G_P1",
"M1D036C_P1",
"Sero-095_P2",
"Sero-185_P2",
"M1A007B_P1",
"Sero-118_P1",
"AR-274_P1",
"AR-300_P1",
"AR-343_P1",
"Sero-181_P3",
"AR-024_P9",
"Sero-161_P4",
"Sero-041_P4",
"Sero-183_P1",
"AR-288_P1",
"M1B040B_P1",
"Sero-041_P15",
"Sero-110_P2",
"Sero-130_P1",
"Sero-088_P1",
"Sero-244_P1",
"Sero-048_P15",
"Sero-215_P4",
"M1A008D_P1",
"Sero-185_P4",
"M1D026A_P1",
"Sero-041_P12",
"M1E025B_P1",
"Sero-040_P6",
"Sero-041_P9",
"Sero-048_P9",
"Sero-040_P2",
"Sero-048_P13",
"Sero-103_P2",
"AR-345_P1",
"Sero-048_P12",
"M1C010B_P1",
"Sero-061_P2",
"Sero-148_P3",
"M1E044C_P3",
"M1D038D_P1",
"Sero-138_P4",
"Sero-215_P5",
"Sero-105_P11",
"Sero-148_P2",
"AR-081_P1",
"Sero-150_P2",
"Sero-161_P3",
"AR-140_P1",
"Sero-138_P1",
"AR-359_P9",
"Sero-048_P8",
"Sero-107_P7",
"Sero-226_P3",
"Sero-288_P1",
"M1E044C_P2",
"Sero-138_P3",
"Sero-048_P11",
"Sero-181_P2",
"M1D024B_P1",
"Sero-041_P11",
"Sero-105_P12",
"AR-359_P15",
"Sero-102_P1",
"Sero-150_P3",
"M1A161C_P1",
"Sero-209_P1",
"M1E036B_P3",
"Sero-066_P1",
"AR-024_P4",
"AR-024_P10",
"AR-024_P7",
"M1D026A_P3",
"Sero-101_P1",
"Sero-048_P4",
"AR-355_P1",
"AR-024_P5",
"Sero-048_P7",
"Sero-093_P1",
"AR-359_P14",
"AR-359_P12",
"AR-176_P2",
"Sero-142_P2",
"AR-176_P1",
"Sero-048_P14",
"M1D026D_P2",
"Sero-215_P6",
"Sero-107_P9",
"Sero-131_P3",
"M1D026A_P2",
"AR-142_P4",
"M1C081A_P4",
"Sero-194_P5",
"AR-322_P1",
"M1A083D_P1",
"Sero-083_P2",
"M1D049D_P3",
"M1C081A_P6",
"Sero-123_P1",
"Sero-095_P1",
"Sero-081_P2",
"Sero-142_P3",
"M1D042A_P1",
"Sero-182_P3",
"AR-328_P3",
"Sero-129_P3",
"AR-328_P1",
"Sero-048_P3",
"Sero-181_P1",
"Sero-061_P3",
"Sero-139_P3",
"M1E016A_P1",
"Sero-105_P15",
"Sero-194_P1",
"Sero-105_P7",
"Sero-094_P1",
"Sero-048_P10",
"M1D026D_P3",
"Sero-189_P1",
"Sero-215_P1",
"M1B020F_P1",
"Sero-105_P8",
"M1C019D_P1",
"AR-306_P1",
"Sero-105_P4",
"Sero-049_P1",
"Sero-107_P4",
"M1C081A_P1",
"AR-187_P2",
"AR-187_P1",
"M1A085C_P1",
"AR-328_P2",
"M1C061B_P1",
"Sero-114_P1",
"Sero-191_P1",
"Sero-161_P2",
"M1A082B_P1",
"Sero-105_P3",
"AR-383_P1",
"AR-024_P6",
"M1D010A_P1",
"M1E042B_P1",
"Sero-214_P1",
"AR-142_P3",
"Sero-218_P1",
"Sero-105_P14",
"M1C081A_P3",
"AR-024_P1",
"Sero-281_P1",
"Sero-123_P2",
"Sero-256_P1",
"M1D019A_P1",
"AR-187_P3",
"AR-246_P1",
"M1C081A_P2",
"Sero-131_P2",
"Sero-040_P1",
"M1C007E_P1",
"Sero-156_P1",
"Sero-138_P2",
"Sero-107_P1",
"Sero-093_P2",
"Sero-214_P3",
"Sero-101_P2",
"Sero-142_P1",
"Sero-107_P5",
"Sero-048_P1",
"Sero-195_P1",
"AR-214_P1",
"Sero-040_P4",
"Sero-048_P2",
"Sero-105_P2",
"M1D006D_P1",
"Sero-097_P1",
"Sero-040_P5",
"AR-306_P2",
"Sero-103_P3",
"Sero-101_P4",
"M1C090C_P1",
"AR-366_P1"
],
"xaxis": "x",
"y": {
"bdata": "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",
"dtype": "f4"
},
"yaxis": "y"
},
{
"hovertemplate": "Probability_Type=prob_I
pair_id=%{x}
Probability=%{y}",
"legendgroup": "prob_I",
"marker": {
"color": "#1fb3c4",
"pattern": {
"shape": ""
}
},
"name": "prob_I",
"orientation": "v",
"showlegend": true,
"textposition": "auto",
"type": "bar",
"x": [
"AR-346_P1",
"AR-359_P10",
"M1A007F_P1",
"Sero-232_P6",
"Sero-273_P1",
"AR-110_P1",
"AR-348_P1",
"AR-187_P4",
"AR-359_P7",
"AR-359_P6",
"Sero-232_P5",
"Sero-232_P4",
"AR-024_P8",
"M1E026C_P1",
"AR-359_P8",
"AR-382_P1",
"M1D036A_P1",
"AR-187_P6",
"AR-187_P5",
"AR-306_P3",
"AR-133_P3",
"AR-142_P2",
"M1D049A_P1",
"AR-359_P4",
"M1E036B_P1",
"Sero-226_P1",
"M1B011B_P1",
"AR-359_P11",
"AR-359_P13",
"AR-133_P1",
"AR-133_P2",
"AR-250_P1",
"AR-359_P3",
"AR-359_P2",
"AR-024_P3",
"AR-221_P1",
"AR-160_P1",
"Sero-139_P1",
"AR-081_P3",
"Sero-154_P1",
"AR-176_P3",
"AR-098_P1",
"Sero-229_P1",
"Sero-242_P3",
"Sero-271_P1",
"AR-024_P2",
"Sero-162_P1",
"Sero-157_P1",
"Sero-262_P1",
"Sero-048_P6",
"Sero-222_P1",
"Sero-138_P9",
"Sero-134_P1",
"Sero-234_P1",
"Sero-162_P3",
"Sero-271_P3",
"Sero-242_P2",
"Sero-138_P8",
"Sero-131_P1",
"Sero-269_P1",
"Sero-271_P2",
"Sero-185_P1",
"Sero-138_P10",
"Sero-234_P2",
"Sero-138_P6",
"Sero-123_P3",
"Sero-242_P1",
"Sero-194_P6",
"Sero-232_P3",
"Sero-232_P2",
"AR-248_P1",
"Sero-258_P5",
"Sero-138_P5",
"Sero-138_P7",
"M1A043E_P1",
"Sero-148_P1",
"Sero-169_P1",
"Sero-277_P1",
"Sero-101_P5",
"Sero-179_P1",
"Sero-185_P6",
"Sero-232_P1",
"AR-325_P1",
"M1A020B_P1",
"AR-237_P1",
"Sero-248_P1",
"Sero-085_P1",
"Sero-258_P3",
"Sero-258_P6",
"Sero-234_P4",
"Sero-041_P13",
"Sero-161_P1",
"Sero-109_P1",
"Sero-224_P1",
"AR-192_P1",
"Sero-224_P2",
"Sero-095_P3",
"AR-067_P1",
"AR-359_P1",
"Sero-182_P1",
"Sero-162_P2",
"AR-140_P2",
"Sero-101_P3",
"AR-326_P1",
"Sero-098_P1",
"Sero-127_P1",
"Sero-145_P1",
"Sero-041_P3",
"Sero-041_P10",
"Sero-100_P1",
"Sero-129_P1",
"Sero-258_P1",
"AR-173_P1",
"Sero-258_P2",
"Sero-083_P3",
"Sero-234_P3",
"Sero-087_P1",
"Sero-214_P2",
"AR-142_P6",
"Sero-215_P3",
"Sero-267_P1",
"Sero-158_P1",
"Sero-150_P1",
"Sero-215_P2",
"Sero-093_P3",
"Sero-109_P2",
"Sero-105_P5",
"Sero-105_P13",
"Sero-109_P3",
"Sero-209_P2",
"Sero-105_P1",
"Sero-224_P3",
"Sero-041_P5",
"Sero-054_P1",
"Sero-258_P4",
"AR-234_P1",
"AR-142_P1",
"AR-302_P1",
"Sero-130_P2",
"Sero-234_P6",
"Sero-058_P1",
"AR-258_P1",
"Sero-041_P1",
"Sero-041_P6",
"Sero-235_P1",
"M1C002A_P1",
"Sero-081_P1",
"Sero-110_P1",
"Sero-105_P6",
"Sero-081_P3",
"Sero-041_P2",
"Sero-234_P5",
"Sero-101_P6",
"Sero-230_P3",
"Sero-048_P5",
"Sero-083_P1",
"Sero-086_P1",
"Sero-196_P1",
"M1C081A_P5",
"M1E028C_P1",
"Sero-105_P9",
"Sero-130_P3",
"Sero-161_P6",
"Sero-192_P1",
"Sero-041_P7",
"Sero-253_P1",
"Sero-129_P2",
"Sero-195_P2",
"Sero-061_P1",
"Sero-209_P3",
"Sero-230_P1",
"Sero-105_P10",
"Sero-226_P2",
"Sero-191_P2",
"Sero-107_P10",
"Sero-107_P3",
"Sero-040_P3",
"AR-359_P5",
"Sero-177_P1",
"Sero-194_P2",
"Sero-185_P3",
"Sero-191_P3",
"Sero-103_P1",
"M1D026D_P1",
"Sero-107_P8",
"AR-081_P2",
"AR-142_P5",
"Sero-185_P5",
"AR-341_P1",
"Sero-143_P1",
"Sero-195_P3",
"Sero-111_P1",
"Sero-057_P1",
"Sero-110_P3",
"M1D049D_P1",
"M1E022A_P1",
"Sero-107_P2",
"AR-140_P3",
"Sero-122_P1",
"Sero-052_P1",
"Sero-182_P2",
"Sero-139_P2",
"Sero-194_P4",
"M1E036B_P2",
"M1E044C_P1",
"Sero-194_P3",
"Sero-041_P8",
"Sero-117_P1",
"Sero-041_P14",
"AR-304_P1",
"Sero-107_P6",
"Sero-230_P2",
"Sero-161_P5",
"M1C031G_P1",
"M1D036C_P1",
"Sero-095_P2",
"Sero-185_P2",
"M1A007B_P1",
"Sero-118_P1",
"AR-274_P1",
"AR-300_P1",
"AR-343_P1",
"Sero-181_P3",
"AR-024_P9",
"Sero-161_P4",
"Sero-041_P4",
"Sero-183_P1",
"AR-288_P1",
"M1B040B_P1",
"Sero-041_P15",
"Sero-110_P2",
"Sero-130_P1",
"Sero-088_P1",
"Sero-244_P1",
"Sero-048_P15",
"Sero-215_P4",
"M1A008D_P1",
"Sero-185_P4",
"M1D026A_P1",
"Sero-041_P12",
"M1E025B_P1",
"Sero-040_P6",
"Sero-041_P9",
"Sero-048_P9",
"Sero-040_P2",
"Sero-048_P13",
"Sero-103_P2",
"AR-345_P1",
"Sero-048_P12",
"M1C010B_P1",
"Sero-061_P2",
"Sero-148_P3",
"M1E044C_P3",
"M1D038D_P1",
"Sero-138_P4",
"Sero-215_P5",
"Sero-105_P11",
"Sero-148_P2",
"AR-081_P1",
"Sero-150_P2",
"Sero-161_P3",
"AR-140_P1",
"Sero-138_P1",
"AR-359_P9",
"Sero-048_P8",
"Sero-107_P7",
"Sero-226_P3",
"Sero-288_P1",
"M1E044C_P2",
"Sero-138_P3",
"Sero-048_P11",
"Sero-181_P2",
"M1D024B_P1",
"Sero-041_P11",
"Sero-105_P12",
"AR-359_P15",
"Sero-102_P1",
"Sero-150_P3",
"M1A161C_P1",
"Sero-209_P1",
"M1E036B_P3",
"Sero-066_P1",
"AR-024_P4",
"AR-024_P10",
"AR-024_P7",
"M1D026A_P3",
"Sero-101_P1",
"Sero-048_P4",
"AR-355_P1",
"AR-024_P5",
"Sero-048_P7",
"Sero-093_P1",
"AR-359_P14",
"AR-359_P12",
"AR-176_P2",
"Sero-142_P2",
"AR-176_P1",
"Sero-048_P14",
"M1D026D_P2",
"Sero-215_P6",
"Sero-107_P9",
"Sero-131_P3",
"M1D026A_P2",
"AR-142_P4",
"M1C081A_P4",
"Sero-194_P5",
"AR-322_P1",
"M1A083D_P1",
"Sero-083_P2",
"M1D049D_P3",
"M1C081A_P6",
"Sero-123_P1",
"Sero-095_P1",
"Sero-081_P2",
"Sero-142_P3",
"M1D042A_P1",
"Sero-182_P3",
"AR-328_P3",
"Sero-129_P3",
"AR-328_P1",
"Sero-048_P3",
"Sero-181_P1",
"Sero-061_P3",
"Sero-139_P3",
"M1E016A_P1",
"Sero-105_P15",
"Sero-194_P1",
"Sero-105_P7",
"Sero-094_P1",
"Sero-048_P10",
"M1D026D_P3",
"Sero-189_P1",
"Sero-215_P1",
"M1B020F_P1",
"Sero-105_P8",
"M1C019D_P1",
"AR-306_P1",
"Sero-105_P4",
"Sero-049_P1",
"Sero-107_P4",
"M1C081A_P1",
"AR-187_P2",
"AR-187_P1",
"M1A085C_P1",
"AR-328_P2",
"M1C061B_P1",
"Sero-114_P1",
"Sero-191_P1",
"Sero-161_P2",
"M1A082B_P1",
"Sero-105_P3",
"AR-383_P1",
"AR-024_P6",
"M1D010A_P1",
"M1E042B_P1",
"Sero-214_P1",
"AR-142_P3",
"Sero-218_P1",
"Sero-105_P14",
"M1C081A_P3",
"AR-024_P1",
"Sero-281_P1",
"Sero-123_P2",
"Sero-256_P1",
"M1D019A_P1",
"AR-187_P3",
"AR-246_P1",
"M1C081A_P2",
"Sero-131_P2",
"Sero-040_P1",
"M1C007E_P1",
"Sero-156_P1",
"Sero-138_P2",
"Sero-107_P1",
"Sero-093_P2",
"Sero-214_P3",
"Sero-101_P2",
"Sero-142_P1",
"Sero-107_P5",
"Sero-048_P1",
"Sero-195_P1",
"AR-214_P1",
"Sero-040_P4",
"Sero-048_P2",
"Sero-105_P2",
"M1D006D_P1",
"Sero-097_P1",
"Sero-040_P5",
"AR-306_P2",
"Sero-103_P3",
"Sero-101_P4",
"M1C090C_P1",
"AR-366_P1"
],
"xaxis": "x",
"y": {
"bdata": "Au74MzRFHjlVvxY5NR2VNzUdlTfZm6E2z5uhNr+gCzfz5Cg58+QoOcoQmzfKEJs3mb4CNJxccDpGy7A5yRneOYKABTqD0/44g9P+ODavijeG4K05A1CxOxni4ztI8CA8LD2kOynPIjnpirc5IvKQOSLykDkS3Y84vA/PO2kosjcGqZY7BqmWO1IhAzWYOCo6Tu01N5G/rDx27DI2IbwLOdG5lTmHAT84TcbnOeFO6jmP6C4653QHNpURkDi9NYY6+oyKOqWlljqr0Yg66YmbOuXWsDqKgNE6rI/nOrPIAjsCBwo7mZkLO+dyIzuyWSM7AEQzOxQvOTvS4ko72tSKOxBCCzpYWqI7R/OhO+b39DmUrIU7lKyFO+GthTg1l8E7grzdO7lT3zsFI9478iKkO+dq7DtqcPA7UKP/OzP8ATyoCAM8swMLPCsFqDuRFxk85hlCPOvmUzzcW1M86bBoPHJJdDzOF3k8omqDPG9nlDwKZpk8ZBqtPIW+IDdmfeM8h0voPIEX7jzYQ/w8xHMCPZGbKT1tmlM9PjVbPcSFbT05O4U9tWaPPRF0oD3VmaM9Re6xPb1gsj2GIbs98t3LPdMhmD0X49Q9/uj2PagQ+j3c3w0+uxwRPgo6Gj6UxIg9z1clPkpBJz45CCg+r6gpPkWiKj6tuTo+8DM9PpysQz5opEg+jxZNPnyBTj6vVlI+8uJKPn7MVT7fWF0+yM5jPvoLZz569YM+vYaIPiv0jD5+mow+3/eVPuO2nj6A+fI7mIenPrxWqj5/ops+7lSwPvdMuD5rZ7g+ayKVPc7gxT7cN8c+v5nIPkb+0j4DSWU9Xxk1PZIZvj20KuE+zZniPogc5T66Wuo+mHA3O2Uo7j4TBfQ+E30ePXAF+T6Crfs+dEx4P3fodT+HonQ/UqFyPzCScj8FjnE/qSNxP3FocD9S4G4/SoJuPzJxbj+Xem0/fzdtP8zibD99e2w/cb1rP6uxaz8TeWs/BGJrP/lIaz/av2o/9g1qP9ffaT8deWk/w8xoPwKwaD8lWmg/hCloP9QiaD+GCWg/cPBnP7xpZz89G2c/kQ1nPyPuZj8A6mY/wtlmP93VZj/MxWY/V2RmP8dCZj8PIWY/UfJlPzngZT/k2mU/Cs5lP5KfZT+rmWU/UcZkP5qPZD9pemQ/6xtkPwQHZD+97WM/xt1jP/NqYz8IJWM/yRpjP+KnYj/ih2I/PHtiP1tYYj+R/2E/xRdhP8cPYT/WC2E/N+lgP5aTYD8Ud2A/fe9fP/ToXz9F0F8/hH5fPxBMXz8/N18//7VeP36UXj/LVl4/pDpeP0PFXT8JtF0/cRFdP3MJXT8D9Vw/R1JcP2pPXD8yG1w/RAxcP8DfWz/VlVs/QEVbP9YrWz9KKFs/bg5bP4XeWj/EwFo/+gdZPzPFWD/LIFg/EB5YP08PWD/2Klc/NvVWP5eQVj9zJVY/oBNWP3uOVT/K4VQ/ktBUP82GVD/whFQ/1gZUP2gGVD8y+VM/o9pTP0B7Uz/LNVM/Qi9TP39WUj9qUFI/VTxQPzUjUD9X0E8/tZxPP66XTz+ul08/CHNPPw0vTz+mFU8/CBBPP3S8Tj+pgk0/El1NP9FPTT9CCE0/8oJMPwG/Sz91kUs/1U5LP7GoSj+DNEo/o85JPxOTST+tgUk/YOFIP961SD/crkg/X51IP5sUSD907kc/h1VHPwFYRj8QR0Y/XDpGP+feRT/rsUU/J0tFP88XRT9O2kQ/pMNEPyacRD9SD0Q/+s1DP624Qz9VqkM/rf9CPzOWQj/cGUI/cxRCP590QT96bkE/n3xAP3HnPz9uxD8/bsQ/P+pDPz94Oj4/c/Q9P6WvPD+SLjw/WrQ7P2pNOz9OCDo/IK45PxEMOT+XpTc/LDY3P/QZNz/2qDU/PaA1P2wEND9P9DI/KQ4yP1oNMj/o0zE/JMIxP+WWMD/d9y8/+m0uP6NOLj9uPy0/slUrP2pIKj/Ktyk/7icoPyHVJz+GlCI/RIYhP1kIID9V4h4/L30YP7HhFT+3sxU/CDIVPxneFD8BXRI/YpkRPz4LDz94Aw0/QzQLP40ZCT9a3Ag/C2EDPxhqAj/gYwI/",
"dtype": "f4"
},
"yaxis": "y"
}
],
"layout": {
"bargap": 0,
"barmode": "relative",
"height": 500,
"legend": {
"orientation": "h",
"title": {},
"tracegroupgap": 0,
"x": 0.5,
"xanchor": "center",
"y": 1.02,
"yanchor": "bottom"
},
"margin": {
"b": 50,
"l": 50,
"r": 20,
"t": 60
},
"paper_bgcolor": "white",
"plot_bgcolor": "white",
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "#C8D4E3",
"linecolor": "#C8D4E3",
"minorgridcolor": "#C8D4E3",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "#C8D4E3",
"linecolor": "#C8D4E3",
"minorgridcolor": "#C8D4E3",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermap": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermap"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "white",
"showlakes": true,
"showland": true,
"subunitcolor": "#C8D4E3"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "white",
"polar": {
"angularaxis": {
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": ""
},
"bgcolor": "white",
"radialaxis": {
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
},
"yaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
},
"zaxis": {
"backgroundcolor": "white",
"gridcolor": "#DFE8F3",
"gridwidth": 2,
"linecolor": "#EBF0F8",
"showbackground": true,
"ticks": "",
"zerolinecolor": "#EBF0F8"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
},
"baxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
},
"bgcolor": "white",
"caxis": {
"gridcolor": "#DFE8F3",
"linecolor": "#A2B1C6",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "#EBF0F8",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "#EBF0F8",
"linecolor": "#EBF0F8",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "#EBF0F8",
"zerolinewidth": 2
}
}
},
"title": {},
"xaxis": {
"anchor": "y",
"categoryarray": [
"AR-346_P1",
"AR-359_P10",
"M1A007F_P1",
"Sero-232_P6",
"Sero-273_P1",
"AR-110_P1",
"AR-348_P1",
"AR-187_P4",
"AR-359_P7",
"AR-359_P6",
"Sero-232_P5",
"Sero-232_P4",
"AR-024_P8",
"M1E026C_P1",
"AR-359_P8",
"AR-382_P1",
"M1D036A_P1",
"AR-187_P6",
"AR-187_P5",
"AR-306_P3",
"AR-133_P3",
"AR-142_P2",
"M1D049A_P1",
"AR-359_P4",
"M1E036B_P1",
"Sero-226_P1",
"M1B011B_P1",
"AR-359_P11",
"AR-359_P13",
"AR-133_P1",
"AR-133_P2",
"AR-250_P1",
"AR-359_P3",
"AR-359_P2",
"AR-024_P3",
"AR-221_P1",
"AR-160_P1",
"Sero-139_P1",
"AR-081_P3",
"Sero-154_P1",
"AR-176_P3",
"AR-098_P1",
"Sero-229_P1",
"Sero-242_P3",
"Sero-271_P1",
"AR-024_P2",
"Sero-162_P1",
"Sero-157_P1",
"Sero-262_P1",
"Sero-048_P6",
"Sero-222_P1",
"Sero-138_P9",
"Sero-134_P1",
"Sero-234_P1",
"Sero-162_P3",
"Sero-271_P3",
"Sero-242_P2",
"Sero-138_P8",
"Sero-131_P1",
"Sero-269_P1",
"Sero-271_P2",
"Sero-185_P1",
"Sero-138_P10",
"Sero-234_P2",
"Sero-138_P6",
"Sero-123_P3",
"Sero-242_P1",
"Sero-194_P6",
"Sero-232_P3",
"Sero-232_P2",
"AR-248_P1",
"Sero-258_P5",
"Sero-138_P5",
"Sero-138_P7",
"M1A043E_P1",
"Sero-148_P1",
"Sero-169_P1",
"Sero-277_P1",
"Sero-101_P5",
"Sero-179_P1",
"Sero-185_P6",
"Sero-232_P1",
"AR-325_P1",
"M1A020B_P1",
"AR-237_P1",
"Sero-248_P1",
"Sero-085_P1",
"Sero-258_P3",
"Sero-258_P6",
"Sero-234_P4",
"Sero-041_P13",
"Sero-161_P1",
"Sero-109_P1",
"Sero-224_P1",
"AR-192_P1",
"Sero-224_P2",
"Sero-095_P3",
"AR-067_P1",
"AR-359_P1",
"Sero-182_P1",
"Sero-162_P2",
"AR-140_P2",
"Sero-101_P3",
"AR-326_P1",
"Sero-098_P1",
"Sero-127_P1",
"Sero-145_P1",
"Sero-041_P3",
"Sero-041_P10",
"Sero-100_P1",
"Sero-129_P1",
"Sero-258_P1",
"AR-173_P1",
"Sero-258_P2",
"Sero-083_P3",
"Sero-234_P3",
"Sero-087_P1",
"Sero-214_P2",
"AR-142_P6",
"Sero-215_P3",
"Sero-267_P1",
"Sero-158_P1",
"Sero-150_P1",
"Sero-215_P2",
"Sero-093_P3",
"Sero-109_P2",
"Sero-105_P5",
"Sero-105_P13",
"Sero-109_P3",
"Sero-209_P2",
"Sero-105_P1",
"Sero-224_P3",
"Sero-041_P5",
"Sero-054_P1",
"Sero-258_P4",
"AR-234_P1",
"AR-142_P1",
"AR-302_P1",
"Sero-130_P2",
"Sero-234_P6",
"Sero-058_P1",
"AR-258_P1",
"Sero-041_P1",
"Sero-041_P6",
"Sero-235_P1",
"M1C002A_P1",
"Sero-081_P1",
"Sero-110_P1",
"Sero-105_P6",
"Sero-081_P3",
"Sero-041_P2",
"Sero-234_P5",
"Sero-101_P6",
"Sero-230_P3",
"Sero-048_P5",
"Sero-083_P1",
"Sero-086_P1",
"Sero-196_P1",
"M1C081A_P5",
"M1E028C_P1",
"Sero-105_P9",
"Sero-130_P3",
"Sero-161_P6",
"Sero-192_P1",
"Sero-041_P7",
"Sero-253_P1",
"Sero-129_P2",
"Sero-195_P2",
"Sero-061_P1",
"Sero-209_P3",
"Sero-230_P1",
"Sero-105_P10",
"Sero-226_P2",
"Sero-191_P2",
"Sero-107_P10",
"Sero-107_P3",
"Sero-040_P3",
"AR-359_P5",
"Sero-177_P1",
"Sero-194_P2",
"Sero-185_P3",
"Sero-191_P3",
"Sero-103_P1",
"M1D026D_P1",
"Sero-107_P8",
"AR-081_P2",
"AR-142_P5",
"Sero-185_P5",
"AR-341_P1",
"Sero-143_P1",
"Sero-195_P3",
"Sero-111_P1",
"Sero-057_P1",
"Sero-110_P3",
"M1D049D_P1",
"M1E022A_P1",
"Sero-107_P2",
"AR-140_P3",
"Sero-122_P1",
"Sero-052_P1",
"Sero-182_P2",
"Sero-139_P2",
"Sero-194_P4",
"M1E036B_P2",
"M1E044C_P1",
"Sero-194_P3",
"Sero-041_P8",
"Sero-117_P1",
"Sero-041_P14",
"AR-304_P1",
"Sero-107_P6",
"Sero-230_P2",
"Sero-161_P5",
"M1C031G_P1",
"M1D036C_P1",
"Sero-095_P2",
"Sero-185_P2",
"M1A007B_P1",
"Sero-118_P1",
"AR-274_P1",
"AR-300_P1",
"AR-343_P1",
"Sero-181_P3",
"AR-024_P9",
"Sero-161_P4",
"Sero-041_P4",
"Sero-183_P1",
"AR-288_P1",
"M1B040B_P1",
"Sero-041_P15",
"Sero-110_P2",
"Sero-130_P1",
"Sero-088_P1",
"Sero-244_P1",
"Sero-048_P15",
"Sero-215_P4",
"M1A008D_P1",
"Sero-185_P4",
"M1D026A_P1",
"Sero-041_P12",
"M1E025B_P1",
"Sero-040_P6",
"Sero-041_P9",
"Sero-048_P9",
"Sero-040_P2",
"Sero-048_P13",
"Sero-103_P2",
"AR-345_P1",
"Sero-048_P12",
"M1C010B_P1",
"Sero-061_P2",
"Sero-148_P3",
"M1E044C_P3",
"M1D038D_P1",
"Sero-138_P4",
"Sero-215_P5",
"Sero-105_P11",
"Sero-148_P2",
"AR-081_P1",
"Sero-150_P2",
"Sero-161_P3",
"AR-140_P1",
"Sero-138_P1",
"AR-359_P9",
"Sero-048_P8",
"Sero-107_P7",
"Sero-226_P3",
"Sero-288_P1",
"M1E044C_P2",
"Sero-138_P3",
"Sero-048_P11",
"Sero-181_P2",
"M1D024B_P1",
"Sero-041_P11",
"Sero-105_P12",
"AR-359_P15",
"Sero-102_P1",
"Sero-150_P3",
"M1A161C_P1",
"Sero-209_P1",
"M1E036B_P3",
"Sero-066_P1",
"AR-024_P4",
"AR-024_P10",
"AR-024_P7",
"M1D026A_P3",
"Sero-101_P1",
"Sero-048_P4",
"AR-355_P1",
"AR-024_P5",
"Sero-048_P7",
"Sero-093_P1",
"AR-359_P14",
"AR-359_P12",
"AR-176_P2",
"Sero-142_P2",
"AR-176_P1",
"Sero-048_P14",
"M1D026D_P2",
"Sero-215_P6",
"Sero-107_P9",
"Sero-131_P3",
"M1D026A_P2",
"AR-142_P4",
"M1C081A_P4",
"Sero-194_P5",
"AR-322_P1",
"M1A083D_P1",
"Sero-083_P2",
"M1D049D_P3",
"M1C081A_P6",
"Sero-123_P1",
"Sero-095_P1",
"Sero-081_P2",
"Sero-142_P3",
"M1D042A_P1",
"Sero-182_P3",
"AR-328_P3",
"Sero-129_P3",
"AR-328_P1",
"Sero-048_P3",
"Sero-181_P1",
"Sero-061_P3",
"Sero-139_P3",
"M1E016A_P1",
"Sero-105_P15",
"Sero-194_P1",
"Sero-105_P7",
"Sero-094_P1",
"Sero-048_P10",
"M1D026D_P3",
"Sero-189_P1",
"Sero-215_P1",
"M1B020F_P1",
"Sero-105_P8",
"M1C019D_P1",
"AR-306_P1",
"Sero-105_P4",
"Sero-049_P1",
"Sero-107_P4",
"M1C081A_P1",
"AR-187_P2",
"AR-187_P1",
"M1A085C_P1",
"AR-328_P2",
"M1C061B_P1",
"Sero-114_P1",
"Sero-191_P1",
"Sero-161_P2",
"M1A082B_P1",
"Sero-105_P3",
"AR-383_P1",
"AR-024_P6",
"M1D010A_P1",
"M1E042B_P1",
"Sero-214_P1",
"AR-142_P3",
"Sero-218_P1",
"Sero-105_P14",
"M1C081A_P3",
"AR-024_P1",
"Sero-281_P1",
"Sero-123_P2",
"Sero-256_P1",
"M1D019A_P1",
"AR-187_P3",
"AR-246_P1",
"M1C081A_P2",
"Sero-131_P2",
"Sero-040_P1",
"M1C007E_P1",
"Sero-156_P1",
"Sero-138_P2",
"Sero-107_P1",
"Sero-093_P2",
"Sero-214_P3",
"Sero-101_P2",
"Sero-142_P1",
"Sero-107_P5",
"Sero-048_P1",
"Sero-195_P1",
"AR-214_P1",
"Sero-040_P4",
"Sero-048_P2",
"Sero-105_P2",
"M1D006D_P1",
"Sero-097_P1",
"Sero-040_P5",
"AR-306_P2",
"Sero-103_P3",
"Sero-101_P4",
"M1C090C_P1",
"AR-366_P1"
],
"categoryorder": "array",
"domain": [
0,
1
],
"linecolor": "black",
"showgrid": false,
"showticklabels": false,
"ticks": "",
"title": {
"text": "Samples"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"gridcolor": "lightgrey",
"linecolor": "black",
"range": [
0,
1
],
"tickformat": ".1f",
"title": {
"text": "Probability"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.express as px\n",
"import pandas as pd\n",
"\n",
"df = result['results_table']\n",
"df = df[['pair_id', 'prob_C', 'prob_L','prob_I','predicted_class']].drop_duplicates().reset_index(drop=True)\n",
"\n",
"# Grouped and sorted blocks\n",
"df_C = df[df.predicted_class == 'C'].sort_values('prob_C', ascending=False).reset_index(drop=True)\n",
"df_L = df[df.predicted_class == 'L'].sort_values('prob_L', ascending=False).reset_index(drop=True)\n",
"df_I = df[df.predicted_class == 'I'].sort_values('prob_I', ascending=False).reset_index(drop=True)\n",
"\n",
"df_sorted = pd.concat([df_C, df_L, df_I], ignore_index=True)\n",
"\n",
"df_long = df_sorted.melt(\n",
" id_vars=['pair_id'], \n",
" value_vars=['prob_C', 'prob_L', 'prob_I'],\n",
" var_name='Probability_Type', \n",
" value_name='Probability'\n",
")\n",
"\n",
"fig = px.bar(\n",
" df_long, \n",
" x=\"pair_id\", \n",
" y=\"Probability\", \n",
" color=\"Probability_Type\",\n",
" color_discrete_sequence=['#ff4d00', '#e6b400', '#1fb3c4'],\n",
" category_orders={\"pair_id\": df_sorted['pair_id'].tolist()},\n",
" template=\"plotly_white\" # Sets white background and clean gridlines\n",
")\n",
"\n",
"fig.update_layout(\n",
" title=None,\n",
" margin=dict(l=50, r=20, t=60, b=50), # Adjusted for axis labels\n",
" height=500,\n",
" paper_bgcolor='white',\n",
" plot_bgcolor='white',\n",
" \n",
" # Horizontal legend at the top\n",
" legend=dict(\n",
" orientation=\"h\",\n",
" yanchor=\"bottom\",\n",
" y=1.02,\n",
" xanchor=\"center\",\n",
" x=0.5,\n",
" title=None\n",
" ),\n",
" \n",
" xaxis=dict(\n",
" title=\"Samples\", # Restored the label\n",
" showticklabels=False, # Keeps specific IDs hidden for cleanliness\n",
" ticks=\"\",\n",
" linecolor='black', # Adds a crisp base line\n",
" showgrid=False\n",
" ),\n",
" \n",
" yaxis=dict(\n",
" title=\"Probability\",\n",
" range=[0, 1],\n",
" tickformat=\".1f\",\n",
" linecolor='black',\n",
" gridcolor='lightgrey' # Subtle grid for probability reference\n",
" ),\n",
" \n",
" bargap=0\n",
")\n",
"\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec103b00",
"metadata": {},
"outputs": [],
"source": [
"result.keys()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b25f2086",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"143\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pair_id | \n",
" patient_id | \n",
" true_episode | \n",
" prob_C | \n",
" prob_L | \n",
" prob_I | \n",
" predicted_class | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" AR-024_P1 | \n",
" AR-024 | \n",
" 1.0 | \n",
" 3.471411e-07 | \n",
" 0.304471 | \n",
" 0.695529 | \n",
" I | \n",
"
\n",
" \n",
" | 1 | \n",
" AR-024_P1 | \n",
" AR-024 | \n",
" 2.0 | \n",
" 3.471411e-07 | \n",
" 0.304471 | \n",
" 0.695529 | \n",
" I | \n",
"
\n",
" \n",
" | 2 | \n",
" AR-024_P10 | \n",
" AR-024 | \n",
" 5.0 | \n",
" 3.380386e-09 | \n",
" 0.173901 | \n",
" 0.826099 | \n",
" I | \n",
"
\n",
" \n",
" | 3 | \n",
" AR-024_P10 | \n",
" AR-024 | \n",
" 4.0 | \n",
" 3.380386e-09 | \n",
" 0.173901 | \n",
" 0.826099 | \n",
" I | \n",
"
\n",
" \n",
" | 4 | \n",
" AR-024_P2 | \n",
" AR-024 | \n",
" 1.0 | \n",
" 9.909202e-04 | \n",
" 0.999007 | \n",
" 0.000002 | \n",
" L | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 783 | \n",
" Sero-277_P1 | \n",
" Sero-277 | \n",
" 1.0 | \n",
" 1.636915e-06 | \n",
" 0.992661 | \n",
" 0.007338 | \n",
" L | \n",
"
\n",
" \n",
" | 784 | \n",
" Sero-281_P1 | \n",
" Sero-281 | \n",
" 1.0 | \n",
" 2.164313e-08 | \n",
" 0.304484 | \n",
" 0.695516 | \n",
" I | \n",
"
\n",
" \n",
" | 785 | \n",
" Sero-281_P1 | \n",
" Sero-281 | \n",
" 2.0 | \n",
" 2.164313e-08 | \n",
" 0.304484 | \n",
" 0.695516 | \n",
" I | \n",
"
\n",
" \n",
" | 786 | \n",
" Sero-288_P1 | \n",
" Sero-288 | \n",
" 1.0 | \n",
" 3.749500e-08 | \n",
" 0.155791 | \n",
" 0.844209 | \n",
" I | \n",
"
\n",
" \n",
" | 787 | \n",
" Sero-288_P1 | \n",
" Sero-288 | \n",
" 2.0 | \n",
" 3.749500e-08 | \n",
" 0.155791 | \n",
" 0.844209 | \n",
" I | \n",
"
\n",
" \n",
"
\n",
"
788 rows × 7 columns
\n",
"
"
],
"text/plain": [
" pair_id patient_id true_episode prob_C prob_L prob_I \\\n",
"0 AR-024_P1 AR-024 1.0 3.471411e-07 0.304471 0.695529 \n",
"1 AR-024_P1 AR-024 2.0 3.471411e-07 0.304471 0.695529 \n",
"2 AR-024_P10 AR-024 5.0 3.380386e-09 0.173901 0.826099 \n",
"3 AR-024_P10 AR-024 4.0 3.380386e-09 0.173901 0.826099 \n",
"4 AR-024_P2 AR-024 1.0 9.909202e-04 0.999007 0.000002 \n",
".. ... ... ... ... ... ... \n",
"783 Sero-277_P1 Sero-277 1.0 1.636915e-06 0.992661 0.007338 \n",
"784 Sero-281_P1 Sero-281 1.0 2.164313e-08 0.304484 0.695516 \n",
"785 Sero-281_P1 Sero-281 2.0 2.164313e-08 0.304484 0.695516 \n",
"786 Sero-288_P1 Sero-288 1.0 3.749500e-08 0.155791 0.844209 \n",
"787 Sero-288_P1 Sero-288 2.0 3.749500e-08 0.155791 0.844209 \n",
"\n",
" predicted_class \n",
"0 I \n",
"1 I \n",
"2 I \n",
"3 I \n",
"4 L \n",
".. ... \n",
"783 L \n",
"784 I \n",
"785 I \n",
"786 I \n",
"787 I \n",
"\n",
"[788 rows x 7 columns]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from DeepSets import run_prediction\n",
"\n",
"result = run_prediction(real_data, mode='prediction')\n",
"result['results_table']"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64754c91",
"metadata": {},
"outputs": [],
"source": [
"preprocessed_data[['sample_id_paired', 'patient_id', 'true_episode']].drop_duplicates().reset_index(drop=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e5d6196",
"metadata": {},
"outputs": [],
"source": [
"from DeepSets import run_prediction\n",
"\n",
"result = run_prediction(real_data, mode='prediction')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ac9a6b0",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.metrics import r2_score\n",
"from DeepSets import DataPreprocessor, build_deepsets_tensors\n",
"\n",
"\n",
"def run_Prediction(data, mode='prediction'):\n",
"\n",
" # perform basic preprocess\n",
" preprocessed_tensor = (\n",
" data\n",
" .pipe(DataPreprocessor.removing_single_episode_patients)\n",
" .pipe(DataPreprocessor.calculate_population_Allele_frequencies, population='country')\n",
" .pipe(DataPreprocessor.calculate_MOIs)\n",
" .pipe(DataPreprocessor.paired_episode_assigner)\n",
" .pipe(DataPreprocessor.build_deepsets_tensors, mode=mode)\n",
" )\n",
" loaded_data = DataPreprocessor.load_tensor(preprocessed_tensor)\n",
" return loaded_data\n",
"\n",
"result = run_Prediction(real_data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50b46ac3",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"# reading allele dictionary\n",
"with open('allele_dict.json', 'r') as file:\n",
" allele_to_id = json.load(file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c5be94c",
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"from DeepSets import PvDeepSets\n",
"# 1. Define the device\n",
"device = torch.device(\"cpu\")\n",
"\n",
"# 2. Initialize the model with the same parameters used during training\n",
"# Make sure len(allele_to_id) matches the training setup!\n",
"n_alleles = len(allele_to_id) \n",
"model = PvDeepSets(n_alleles=n_alleles)\n",
"print(n_alleles)\n",
"# 3. Load the weights (state_dict)\n",
"# Replace \"pv_deepsets_weights.pth\" with your actual filename\n",
"model.load_state_dict(torch.load(\"../src/DeepSets/pv_deepsets_weights20260402.pth\", map_location=device))\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "581c0365",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.metrics import r2_score\n",
"\n",
"import numpy as np\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.metrics import r2_score\n",
"\n",
"def get_model_results(model, dataloader, device, threshold=0.5):\n",
" model.eval()\n",
" all_predicted = []\n",
" y_pred_filtered = []\n",
" undetermined_count = 0\n",
"\n",
" with torch.no_grad():\n",
" for X_alleles, allele_mask, marker_mask, priors, MOI in dataloader:\n",
" # ... (your existing GPU transfer code) ...\n",
" y_pred = model(X_alleles, allele_mask, marker_mask, priors, MOI)\n",
" \n",
" # Apply Softmax if your model doesn't already output probabilities\n",
" # probs = torch.softmax(y_pred, dim=1) \n",
" probs = y_pred \n",
"\n",
" # Get max probabilities and their indices\n",
" max_probs, preds = torch.max(probs, dim=1)\n",
"\n",
" for i in range(len(max_probs)):\n",
" if max_probs[i] >= threshold:\n",
" y_pred_filtered.append(preds[i].item())\n",
" else:\n",
" undetermined_count += 1\n",
"\n",
" all_predicted.append(y_pred.cpu().numpy())\n",
"\n",
" print(f\"Total undetermined samples removed: {undetermined_count}\")\n",
" return np.vstack(all_predicted), y_pred_filtered\n",
"\n",
"predicted_probs, y_pred_hard = get_model_results(model, result, device)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8f6bda0c",
"metadata": {},
"outputs": [],
"source": [
"y_pred_hard"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e6222332",
"metadata": {},
"outputs": [],
"source": [
"# Step 1: removing patients with only one episode\n",
"# Step 2: make all possible pair (including making episode 1&2)\n",
"# step 3: Calculate MOIs\n",
"# step 4: Calculate Afreq"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "PvRecNet",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.20"
}
},
"nbformat": 4,
"nbformat_minor": 5
}