|
105 | 105 | "print(\"Images per patient (std): \", sc_df.index.value_counts().std())"
|
106 | 106 | ]
|
107 | 107 | },
|
108 |
| - { |
109 |
| - "cell_type": "code", |
110 |
| - "execution_count": null, |
111 |
| - "metadata": {}, |
112 |
| - "outputs": [], |
113 |
| - "source": [ |
114 |
| - "patient_df" |
115 |
| - ] |
116 |
| - }, |
117 | 108 | {
|
118 | 109 | "cell_type": "markdown",
|
119 | 110 | "metadata": {},
|
|
198 | 189 | "metadata": {},
|
199 | 190 | "outputs": [],
|
200 | 191 | "source": [
|
201 |
| - "# entropy_plot.entropy_plot(patient_df)\n", |
202 | 192 | "entropy_plot.entropy_vs_myb(patient_df)"
|
203 | 193 | ]
|
204 | 194 | },
|
|
219 | 209 | ]
|
220 | 210 | },
|
221 | 211 | {
|
| 212 | + "attachments": {}, |
222 | 213 | "cell_type": "markdown",
|
223 | 214 | "metadata": {},
|
224 | 215 | "source": [
|
225 | 216 | "# Patients: algorithm performance\n",
|
226 | 217 | "### Define a patient\n",
|
227 |
| - "Put in a patient ID to look at the predictions" |
| 218 | + "Enter any patient ID to look at the predictions" |
228 | 219 | ]
|
229 | 220 | },
|
230 | 221 | {
|
|
299 | 290 | ]
|
300 | 291 | },
|
301 | 292 | {
|
| 293 | + "attachments": {}, |
302 | 294 | "cell_type": "markdown",
|
303 | 295 | "metadata": {},
|
304 | 296 | "source": [
|
305 | 297 | "### Show swarmplot\n",
|
306 |
| - "Swarmplot is interactive and shows cells upon mouseover. Classes of cells can be excluded by clicking the corresponding label in the legend on the right. This cell automatically stores a vector graphic in the folder ```output/swarmplots```, and calculates the distribution of cells in each quartile (see dataframe below interactive figure)" |
| 298 | + "The presented Swarmplot is interactive and shows cells upon mouseover. Classes of cells can be excluded by clicking the corresponding label in the legend on the right. This cell automatically stores a vector graphic in the folder ```output/swarmplots```, and calculates the distribution of cells in each quartile (see dataframe below interactive figure)" |
307 | 299 | ]
|
308 | 300 | },
|
309 | 301 | {
|
|
384 | 376 | "metadata": {},
|
385 | 377 | "outputs": [],
|
386 | 378 | "source": [
|
387 |
| - "# calculate occlusion and solitary cell predictions\n", |
| 379 | + "# calculate occlusion and solitary cell predictions as predicted in Fig. 3b\n", |
388 | 380 | "occlusion_values = sc_occlusion.calculate_change_on_occlusion(data_with_mappings_and_coordinates, result_folder_path, \n",
|
389 | 381 | " folders_cv_available, feature_prefix, lbl_conv_obj)\n",
|
390 | 382 | "\n",
|
391 | 383 | "bokeh_wrapper.init_sol_plot(occlusion_values)"
|
392 | 384 | ]
|
393 | 385 | },
|
394 | 386 | {
|
| 387 | + "attachments": {}, |
395 | 388 | "cell_type": "markdown",
|
396 | 389 | "metadata": {},
|
397 | 390 | "source": [
|
398 | 391 | "# UMAP embedding\n",
|
399 | 392 | "\n",
|
400 |
| - "The interactive UMAP figures require quite a lot of RAM and computing power. To calculate the occlusion values, the use of CUDA-capable GPUs is highly recommended and will greatly speed up the process.\n", |
| 393 | + "The interactive UMAP figures require quite a lot of RAM and computing power. To calculate the occlusion values, the use of CUDA-capable GPUs is highly recommended and will greatly speed up the process. From here on out, we recommend 32GB of RAM, otherwise the kernel will most likely crash.\n", |
401 | 394 | "\n",
|
402 | 395 | "1. Calculate or load the UMAP embedding (not necessary, if an old gzip file should be loaded)"
|
403 | 396 | ]
|
|
411 | 404 | "outputs": [],
|
412 | 405 | "source": [
|
413 | 406 | "# sample cells randomly for embedding\n",
|
414 |
| - "fold_filter = 0\n", |
| 407 | + "fold_filter = 2\n", |
415 | 408 | "sc_umap_sample = sc_df.loc[sc_df['fold'] == fold_filter].sample(frac=1, random_state=1).copy()\n",
|
416 | 409 | "\n",
|
417 |
| - "sc_df_umap = umap_embedding.select_embedding(sc_umap_sample)" |
| 410 | + "sc_df_umap = umap_embedding.generate_embedding(sc_umap_sample, save=False)" |
418 | 411 | ]
|
419 | 412 | },
|
420 | 413 | {
|
|
587 | 580 | "image_excerpt.plot(tmp_frame, show_scalebar=False, show_coordinates=False, cols=cols, path_save=path_save, show_patient_class=False)"
|
588 | 581 | ]
|
589 | 582 | },
|
590 |
| - { |
591 |
| - "cell_type": "code", |
592 |
| - "execution_count": null, |
593 |
| - "metadata": {}, |
594 |
| - "outputs": [], |
595 |
| - "source": [ |
596 |
| - "tmp_frame" |
597 |
| - ] |
598 |
| - }, |
599 | 583 | {
|
600 | 584 | "cell_type": "markdown",
|
601 | 585 | "metadata": {},
|
|
662 | 646 | " bokeh_wrapper.export_umap(sc_prepared, data_column=\"solitary_softmax_{}\".format(class_lbl),grayscatter=True, \n",
|
663 | 647 | " dotsize=10, path_save=path_save)"
|
664 | 648 | ]
|
665 |
| - }, |
666 |
| - { |
667 |
| - "cell_type": "code", |
668 |
| - "execution_count": null, |
669 |
| - "metadata": {}, |
670 |
| - "outputs": [], |
671 |
| - "source": [] |
672 |
| - }, |
673 |
| - { |
674 |
| - "cell_type": "code", |
675 |
| - "execution_count": null, |
676 |
| - "metadata": {}, |
677 |
| - "outputs": [], |
678 |
| - "source": [ |
679 |
| - "patient_df" |
680 |
| - ] |
681 |
| - }, |
682 |
| - { |
683 |
| - "cell_type": "code", |
684 |
| - "execution_count": null, |
685 |
| - "metadata": {}, |
686 |
| - "outputs": [], |
687 |
| - "source": [ |
688 |
| - "import matplotlib.colors as mpt_colors\n", |
689 |
| - "import matplotlib.pyplot as plt\n", |
690 |
| - "from matplotlib import cm\n", |
691 |
| - "import font_matching\n", |
692 |
| - "\n", |
693 |
| - "# filter by fold\n", |
694 |
| - "patient_df_f0 = patient_df.loc[patient_df['fold'] == 0]\n", |
695 |
| - " \n", |
696 |
| - "clusterplot_structure = {}\n", |
697 |
| - " \n", |
698 |
| - "# for every entity, iterate in order:\n", |
699 |
| - "for entity in ['AML-PML-RARA', 'AML-NPM1', 'AML-CBFB-MYH11', 'AML-RUNX1-RUNX1T1', 'SCD']:\n", |
700 |
| - " patient_df_f0_ent = patient_df_f0.loc[patient_df_f0['gt_label'] == entity]\n", |
701 |
| - " clusterplot_structure[entity] = patient_df_f0_ent.sort_values(by='mil_prediction_{}'.format(entity), ascending=False).index\n", |
702 |
| - " \n", |
703 |
| - "# find maximum length for grid subplots\n", |
704 |
| - "max_len = max([len(x) for x in clusterplot_structure.values()])\n", |
705 |
| - "fig, ax = plt.subplots(max_len, 5, figsize=(10, max_len/2), constrained_layout=True)\n", |
706 |
| - "\n", |
707 |
| - "for a in ax.flatten():\n", |
708 |
| - " a.spines['top'].set_visible(False)\n", |
709 |
| - " a.spines['right'].set_visible(False)\n", |
710 |
| - " a.spines['bottom'].set_visible(False)\n", |
711 |
| - " a.spines['left'].set_visible(False)\n", |
712 |
| - " \n", |
713 |
| - " a.set_xticks([])\n", |
714 |
| - " a.set_yticks([])\n", |
715 |
| - "\n", |
716 |
| - "column_counter = 0\n", |
717 |
| - "for entity in ['AML-PML-RARA', 'AML-NPM1', 'AML-CBFB-MYH11', 'AML-RUNX1-RUNX1T1', 'SCD']:\n", |
718 |
| - " row_counter = 0\n", |
719 |
| - " for patient in clusterplot_structure[entity]:\n", |
720 |
| - " bokeh_wrapper.sol_att_bar_plot(sc_prepared.loc[patient], ax[row_counter, column_counter])\n", |
721 |
| - " if(row_counter == 0):\n", |
722 |
| - " ax[row_counter, column_counter].set_title(font_matching.edit(entity))\n", |
723 |
| - " row_counter += 1\n", |
724 |
| - " \n", |
725 |
| - " column_counter += 1\n", |
726 |
| - "print(\"Plotting...\") \n", |
727 |
| - "plt.show()\n", |
728 |
| - "print(\"Done!\")" |
729 |
| - ] |
730 |
| - }, |
731 |
| - { |
732 |
| - "cell_type": "code", |
733 |
| - "execution_count": null, |
734 |
| - "metadata": {}, |
735 |
| - "outputs": [], |
736 |
| - "source": [] |
737 | 649 | }
|
738 | 650 | ],
|
739 | 651 | "metadata": {
|
|
0 commit comments