spatialproteomics 0.8.6__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spatialproteomics-0.9.0/.gitignore +15 -0
- {spatialproteomics-0.8.6/spatialproteomics.egg-info → spatialproteomics-0.9.0}/PKG-INFO +49 -41
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/README.md +3 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/pyproject.toml +19 -15
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/__init__.py +2 -4
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/container.py +49 -49
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/image_container/ImageContainer.py +10 -5
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/la/label.py +104 -60
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/nh/neighborhood.py +25 -15
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/nh/utils.py +26 -21
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pl/plot.py +34 -29
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pl/utils.py +40 -2
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pp/preprocessing.py +165 -87
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pp/utils.py +65 -15
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/tl/__init__.py +2 -2
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/tl/tool.py +160 -58
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/tl/utils.py +86 -11
- spatialproteomics-0.9.0/tests/__init__.py +0 -0
- spatialproteomics-0.9.0/tests/conftest.py +108 -0
- spatialproteomics-0.9.0/tests/image_container/test_image_container.py +71 -0
- spatialproteomics-0.9.0/tests/la/test_add_label_type.py +42 -0
- spatialproteomics-0.9.0/tests/la/test_add_labels.py +113 -0
- spatialproteomics-0.9.0/tests/la/test_format_labels.py +48 -0
- spatialproteomics-0.9.0/tests/la/test_label_properties.py +75 -0
- spatialproteomics-0.9.0/tests/la/test_label_select_deselect.py +95 -0
- spatialproteomics-0.9.0/tests/la/test_predict_cell_subtypes.py +188 -0
- spatialproteomics-0.9.0/tests/la/test_predict_cell_types_argmax.py +132 -0
- spatialproteomics-0.9.0/tests/la/test_remove_label_type.py +55 -0
- spatialproteomics-0.9.0/tests/la/test_remove_label_types_composition.py +24 -0
- spatialproteomics-0.9.0/tests/la/test_set_label_level.py +27 -0
- spatialproteomics-0.9.0/tests/la/test_threshold_label.py +69 -0
- spatialproteomics-0.9.0/tests/nh/test_add_neighborhood_obs.py +3 -0
- spatialproteomics-0.9.0/tests/nh/test_add_neighborhood_properties.py +16 -0
- spatialproteomics-0.9.0/tests/nh/test_cells_2_synchronization.py +75 -0
- spatialproteomics-0.9.0/tests/nh/test_compute_graph_features.py +5 -0
- spatialproteomics-0.9.0/tests/nh/test_compute_neighborhood_features.py +54 -0
- spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_delaunay.py +41 -0
- spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_knn.py +55 -0
- spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_radius.py +52 -0
- spatialproteomics-0.9.0/tests/nh/test_nh_select_deselect.py +172 -0
- spatialproteomics-0.9.0/tests/nh/test_set_neighborhood_name.py +78 -0
- spatialproteomics-0.9.0/tests/pl/test_colorize.py +40 -0
- spatialproteomics-0.9.0/tests/pl/test_label_segmentation_mask.py +30 -0
- spatialproteomics-0.9.0/tests/pl/test_sample_colors.py +54 -0
- spatialproteomics-0.9.0/tests/pl/test_show.py +83 -0
- spatialproteomics-0.9.0/tests/pp/test_add_channel.py +85 -0
- spatialproteomics-0.9.0/tests/pp/test_add_layer.py +65 -0
- spatialproteomics-0.9.0/tests/pp/test_add_obs.py +125 -0
- spatialproteomics-0.9.0/tests/pp/test_add_quantification.py +93 -0
- spatialproteomics-0.9.0/tests/pp/test_add_segmentation.py +67 -0
- spatialproteomics-0.9.0/tests/pp/test_apply.py +9 -0
- spatialproteomics-0.9.0/tests/pp/test_convert_to_8bit.py +50 -0
- spatialproteomics-0.9.0/tests/pp/test_drop_channel.py +63 -0
- spatialproteomics-0.9.0/tests/pp/test_drop_layers.py +73 -0
- spatialproteomics-0.9.0/tests/pp/test_drop_observations.py +32 -0
- spatialproteomics-0.9.0/tests/pp/test_filter_by_obs.py +54 -0
- spatialproteomics-0.9.0/tests/pp/test_find_bright_cells.py +47 -0
- spatialproteomics-0.9.0/tests/pp/test_get_layer_as_df.py +22 -0
- spatialproteomics-0.9.0/tests/pp/test_grow_cells.py +47 -0
- spatialproteomics-0.9.0/tests/pp/test_handle_disconnected_cells.py +70 -0
- spatialproteomics-0.9.0/tests/pp/test_image_normalize.py +11 -0
- spatialproteomics-0.9.0/tests/pp/test_mask_cells.py +89 -0
- spatialproteomics-0.9.0/tests/pp/test_mask_region.py +74 -0
- spatialproteomics-0.9.0/tests/pp/test_merge_channels.py +89 -0
- spatialproteomics-0.9.0/tests/pp/test_merge_images.py +36 -0
- spatialproteomics-0.9.0/tests/pp/test_merge_segmentation.py +132 -0
- spatialproteomics-0.9.0/tests/pp/test_relabel_cells.py +32 -0
- spatialproteomics-0.9.0/tests/pp/test_remove_outlying_cells.py +36 -0
- spatialproteomics-0.9.0/tests/pp/test_rescale.py +61 -0
- spatialproteomics-0.9.0/tests/pp/test_slicing.py +141 -0
- spatialproteomics-0.9.0/tests/pp/test_threshold.py +240 -0
- spatialproteomics-0.9.0/tests/pp/test_threshold_against_snapshot.py +122 -0
- spatialproteomics-0.9.0/tests/pp/test_transform_expression_matrix.py +56 -0
- spatialproteomics-0.9.0/tests/scripts/generate_threshold_snapshot.py +100 -0
- spatialproteomics-0.9.0/tests/snapshots/threshold_snapshots.json +222 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_predict_cell_subtypes_spatialdata.py +232 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_predict_cell_types_argmax_spatialdata.py +61 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_threshold_label_spatialdata.py +22 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_add_obs_spatialdata.py +29 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_add_quantification_spatialdata.py +65 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_apply_spatialdata.py +15 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_filter_by_obs_spatialdata.py +63 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_grow_cells_spatialdata.py +55 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_merge_channels_spatialdata.py +43 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_threshold_spatialdata.py +218 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_transform_expression_matrix_spatialdata.py +65 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/test_integration_spatialdata.py +40 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/test_read_from_spatialdata.py +22 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/tl/test_cellpose_spatialdata.py +12 -0
- spatialproteomics-0.9.0/tests/spatialdata_backend/tl/test_instanseg_spatialdata.py +12 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/_image/c/0/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/_image/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/channels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/channels/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/x/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/x/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/y/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/y/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/zarr.json +6 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_image/c/0/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_image/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_intensity/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_intensity/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_layers/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_layers/zarr.json +44 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_properties/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_properties/zarr.json +44 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_obs/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_obs/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_percentage_positive/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_percentage_positive/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_segmentation/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_segmentation/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/cells/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/cells/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/channels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/channels/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/features/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/features/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_features/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_features/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_props/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_props/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/labels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/labels/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/x/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/x/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/y/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/y/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/zarr.json +6 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_adjacency_matrix/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_adjacency_matrix/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_image/c/0/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_image/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_intensity/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_intensity/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_layers/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_layers/zarr.json +44 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_properties/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_properties/zarr.json +44 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_neighborhoods/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_neighborhoods/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_nh_properties/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_nh_properties/zarr.json +44 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_obs/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_obs/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_percentage_positive/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_percentage_positive/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_segmentation/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_segmentation/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells_2/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells_2/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/channels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/channels/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/features/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/features/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_features/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_features/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_props/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_props/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/labels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/labels/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/neighborhoods/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/neighborhoods/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/nh_props/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/nh_props/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/x/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/x/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/y/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/y/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/zarr.json +6 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_image/c/0/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_image/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_obs/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_obs/zarr.json +48 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_segmentation/c/0/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_segmentation/zarr.json +46 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/cells/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/cells/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/channels/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/channels/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/features/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/features/zarr.json +41 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/x/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/x/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/y/c/0 +0 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/y/zarr.json +43 -0
- spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/zarr.json +6 -0
- spatialproteomics-0.9.0/tests/test_files/image.tiff +0 -0
- spatialproteomics-0.9.0/tests/test_files/segmentation.tiff +0 -0
- spatialproteomics-0.9.0/tests/test_public_api.py +6 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/tests/test_to_zarr.py +27 -0
- spatialproteomics-0.9.0/tests/tl/test_astir.py +61 -0
- spatialproteomics-0.9.0/tests/tl/test_cellpose.py +11 -0
- spatialproteomics-0.9.0/tests/tl/test_convert_to_anndata.py +84 -0
- spatialproteomics-0.9.0/tests/tl/test_convert_to_spatialdata.py +96 -0
- spatialproteomics-0.9.0/tests/tl/test_instanseg.py +26 -0
- spatialproteomics-0.8.6/PKG-INFO +0 -103
- spatialproteomics-0.8.6/setup.cfg +0 -4
- spatialproteomics-0.8.6/spatialproteomics.egg-info/SOURCES.txt +0 -35
- spatialproteomics-0.8.6/spatialproteomics.egg-info/dependency_links.txt +0 -1
- spatialproteomics-0.8.6/spatialproteomics.egg-info/requires.txt +0 -52
- spatialproteomics-0.8.6/spatialproteomics.egg-info/top_level.txt +0 -1
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/LICENSE +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/base_logger.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/constants.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/image_container/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/la/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/la/utils.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/nh/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pl/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pp/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/pp/intensity.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/sd/__init__.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/spatialproteomics/sd/utils.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/tests/test_container.py +0 -0
- {spatialproteomics-0.8.6 → spatialproteomics-0.9.0}/tests/test_integration.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
__pycache__
|
|
2
|
+
.pytest_cache
|
|
3
|
+
format.sh
|
|
4
|
+
tests/test_files/test2.zarr
|
|
5
|
+
data
|
|
6
|
+
Dev.ipynb
|
|
7
|
+
Dev-checkpoint.ipynb
|
|
8
|
+
.ipynb_checkpoints
|
|
9
|
+
.DS_Store
|
|
10
|
+
docs/notebooks/Interactivity.py
|
|
11
|
+
docs/notebooks/.ipynb_checkpoints
|
|
12
|
+
*.egg-info/
|
|
13
|
+
*.egg
|
|
14
|
+
dist/
|
|
15
|
+
build/
|
|
@@ -1,55 +1,60 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: spatialproteomics
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Spatialproteomics is an interoperable toolbox for analyzing highly multiplexed fluorescence image data
|
|
5
5
|
Author: Matthias Meyer-Bender, Harald Vohringer
|
|
6
|
-
Requires-Python: >=3.10
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
6
|
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.11
|
|
9
8
|
Requires-Dist: cffi>=1.15.0
|
|
10
|
-
Requires-Dist: xarray>=2024.0.0
|
|
11
|
-
Requires-Dist: scikit-image>=0.25
|
|
12
9
|
Requires-Dist: matplotlib>=3.8.0
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist: scikit-learn>=1.4.2
|
|
15
|
-
Requires-Dist: zarr
|
|
16
|
-
Requires-Dist: numpy>=1.23
|
|
10
|
+
Requires-Dist: numpy>=1.25
|
|
17
11
|
Requires-Dist: opencv-python>=4.11.0
|
|
12
|
+
Requires-Dist: pandas>=2.2.2
|
|
18
13
|
Requires-Dist: pyyaml>=6.0
|
|
19
|
-
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
|
|
31
|
-
Requires-Dist: stardist>=0.9.1; extra == "stardist"
|
|
14
|
+
Requires-Dist: scikit-image>=0.25
|
|
15
|
+
Requires-Dist: scikit-learn>=1.4.2
|
|
16
|
+
Requires-Dist: tqdm>=4.64.0
|
|
17
|
+
Requires-Dist: xarray>=2025.6.0
|
|
18
|
+
Requires-Dist: zarr>=3.0.0
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: astir; extra == 'all'
|
|
21
|
+
Requires-Dist: cellpose; extra == 'all'
|
|
22
|
+
Requires-Dist: instanseg-torch>=0.1.0; extra == 'all'
|
|
23
|
+
Requires-Dist: spatialdata; extra == 'all'
|
|
24
|
+
Requires-Dist: spotiflow; extra == 'all'
|
|
25
|
+
Requires-Dist: stardist; extra == 'all'
|
|
32
26
|
Provides-Extra: anndata
|
|
33
|
-
Requires-Dist: anndata; extra ==
|
|
27
|
+
Requires-Dist: anndata>=0.10.0; extra == 'anndata'
|
|
34
28
|
Provides-Extra: astir
|
|
35
|
-
Requires-Dist: astir>=0.1.5; extra ==
|
|
36
|
-
Provides-Extra:
|
|
37
|
-
Requires-Dist:
|
|
29
|
+
Requires-Dist: astir>=0.1.5; extra == 'astir'
|
|
30
|
+
Provides-Extra: cellpose
|
|
31
|
+
Requires-Dist: cellpose>=3.1.0; extra == 'cellpose'
|
|
38
32
|
Provides-Extra: dev
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist:
|
|
42
|
-
Requires-Dist: isort>=5.10.1; extra ==
|
|
43
|
-
Requires-Dist:
|
|
44
|
-
Requires-Dist:
|
|
45
|
-
Requires-Dist: safety>=2.1.1; extra ==
|
|
46
|
-
Requires-Dist:
|
|
47
|
-
Provides-Extra:
|
|
48
|
-
Requires-Dist:
|
|
49
|
-
Requires-Dist:
|
|
50
|
-
Requires-Dist:
|
|
51
|
-
Requires-Dist:
|
|
52
|
-
|
|
33
|
+
Requires-Dist: bandit>=1.7.4; extra == 'dev'
|
|
34
|
+
Requires-Dist: black[jupyter]>=22.6.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: flake8>=5.0.4; extra == 'dev'
|
|
36
|
+
Requires-Dist: isort>=5.10.1; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest>=7.1.2; extra == 'dev'
|
|
39
|
+
Requires-Dist: safety>=2.1.1; extra == 'dev'
|
|
40
|
+
Requires-Dist: typing-extensions>=4.16; extra == 'dev'
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: ipython>=8.0.0; extra == 'docs'
|
|
43
|
+
Requires-Dist: nbsphinx>=0.9; extra == 'docs'
|
|
44
|
+
Requires-Dist: sphinx-book-theme>=0.0.39; extra == 'docs'
|
|
45
|
+
Requires-Dist: sphinx-multiversion>=0.2.4; extra == 'docs'
|
|
46
|
+
Requires-Dist: sphinx>=7.0.0; extra == 'docs'
|
|
47
|
+
Requires-Dist: sphinxcontrib-napoleon==0.7; extra == 'docs'
|
|
48
|
+
Provides-Extra: instanseg
|
|
49
|
+
Requires-Dist: instanseg-torch>=0.1.0; extra == 'instanseg'
|
|
50
|
+
Provides-Extra: spatialdata
|
|
51
|
+
Requires-Dist: spatialdata>=0.7.3; extra == 'spatialdata'
|
|
52
|
+
Requires-Dist: zarr>=3.1.2; extra == 'spatialdata'
|
|
53
|
+
Provides-Extra: spotiflow
|
|
54
|
+
Requires-Dist: spotiflow; extra == 'spotiflow'
|
|
55
|
+
Provides-Extra: stardist
|
|
56
|
+
Requires-Dist: stardist>=0.9.1; extra == 'stardist'
|
|
57
|
+
Description-Content-Type: text/markdown
|
|
53
58
|
|
|
54
59
|
# spatialproteomics
|
|
55
60
|
|
|
@@ -73,6 +78,8 @@ Multiplexed imaging data comprises at least 3 dimensions (i.e. `channels`, `x`,
|
|
|
73
78
|
|
|
74
79
|
Please refer to the [documentation](https://sagar87.github.io/spatialproteomics) for details on the API and tutorials.
|
|
75
80
|
|
|
81
|
+
If you work with an AI coding assistant, point it to [llms.txt](https://sagar87.github.io/spatialproteomics/llms.txt) (an index of the documentation in Markdown) or [llms-full.txt](https://sagar87.github.io/spatialproteomics/llms-full.txt) (the complete documentation in a single file). Contributors using coding agents will find repository instructions in [AGENTS.md](AGENTS.md).
|
|
82
|
+
|
|
76
83
|
## Installation
|
|
77
84
|
|
|
78
85
|
To install `spatialproteomics`, first create a python environment and install the package using
|
|
@@ -93,6 +100,7 @@ The base version of `spatialproteomics` depends on the following packages:
|
|
|
93
100
|
xarray
|
|
94
101
|
zarr
|
|
95
102
|
numpy
|
|
103
|
+
pandas
|
|
96
104
|
scikit-image
|
|
97
105
|
scikit-learn
|
|
98
106
|
opencv-python
|
|
@@ -20,6 +20,8 @@ Multiplexed imaging data comprises at least 3 dimensions (i.e. `channels`, `x`,
|
|
|
20
20
|
|
|
21
21
|
Please refer to the [documentation](https://sagar87.github.io/spatialproteomics) for details on the API and tutorials.
|
|
22
22
|
|
|
23
|
+
If you work with an AI coding assistant, point it to [llms.txt](https://sagar87.github.io/spatialproteomics/llms.txt) (an index of the documentation in Markdown) or [llms-full.txt](https://sagar87.github.io/spatialproteomics/llms-full.txt) (the complete documentation in a single file). Contributors using coding agents will find repository instructions in [AGENTS.md](AGENTS.md).
|
|
24
|
+
|
|
23
25
|
## Installation
|
|
24
26
|
|
|
25
27
|
To install `spatialproteomics`, first create a python environment and install the package using
|
|
@@ -40,6 +42,7 @@ The base version of `spatialproteomics` depends on the following packages:
|
|
|
40
42
|
xarray
|
|
41
43
|
zarr
|
|
42
44
|
numpy
|
|
45
|
+
pandas
|
|
43
46
|
scikit-image
|
|
44
47
|
scikit-learn
|
|
45
48
|
opencv-python
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "spatialproteomics"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.9.0"
|
|
4
4
|
description = "Spatialproteomics is an interoperable toolbox for analyzing highly multiplexed fluorescence image data"
|
|
5
5
|
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
7
|
authors = [
|
|
8
8
|
{name="Matthias Meyer-Bender"},
|
|
9
9
|
{name="Harald Vohringer"}
|
|
10
10
|
]
|
|
11
11
|
dependencies = [
|
|
12
12
|
"cffi>=1.15.0",
|
|
13
|
-
"xarray>=
|
|
13
|
+
"xarray>=2025.6.0",
|
|
14
14
|
"scikit-image>=0.25",
|
|
15
15
|
"matplotlib>=3.8.0",
|
|
16
16
|
"tqdm>=4.64.0",
|
|
17
17
|
"scikit-learn>=1.4.2",
|
|
18
|
-
"zarr", #
|
|
19
|
-
"numpy>=1.
|
|
18
|
+
"zarr>=3.0.0", # zarr-python 3 reads and writes both zarr format v2 and v3
|
|
19
|
+
"numpy>=1.25",
|
|
20
20
|
"opencv-python>=4.11.0",
|
|
21
|
+
"pandas>=2.2.2",
|
|
21
22
|
"pyyaml>=6.0"
|
|
22
23
|
]
|
|
23
24
|
|
|
24
|
-
[tool.setuptools.packages.find]
|
|
25
|
-
where = ["."]
|
|
26
|
-
include = ["spatialproteomics*"]
|
|
27
|
-
|
|
28
|
-
|
|
29
25
|
[project.optional-dependencies]
|
|
30
26
|
docs = [
|
|
31
27
|
"Sphinx>=7.0.0",
|
|
@@ -35,12 +31,13 @@ docs = [
|
|
|
35
31
|
"sphinx-multiversion>=0.2.4",
|
|
36
32
|
"IPython>=8.0.0",
|
|
37
33
|
]
|
|
38
|
-
spatialdata = ["spatialdata>=0.
|
|
34
|
+
spatialdata = ["spatialdata>=0.7.3", "zarr>=3.1.2"] # spatialdata needs zarr>=3.1.2 but does not declare it
|
|
39
35
|
cellpose = ["cellpose>=3.1.0"]
|
|
40
36
|
stardist = ["stardist>=0.9.1"]
|
|
41
|
-
anndata = ["anndata"]
|
|
37
|
+
anndata = ["anndata>=0.10.0"]
|
|
42
38
|
astir = ["astir>=0.1.5"]
|
|
43
39
|
spotiflow = ["spotiflow"]
|
|
40
|
+
instanseg = ["instanseg-torch>=0.1.0"]
|
|
44
41
|
dev = [
|
|
45
42
|
"pytest>=7.1.2",
|
|
46
43
|
"pytest-cov>=3.0.0",
|
|
@@ -51,11 +48,18 @@ dev = [
|
|
|
51
48
|
"safety>=2.1.1",
|
|
52
49
|
"typing_extensions>=4.16", # to avoid anndata issues
|
|
53
50
|
]
|
|
54
|
-
all = ["spatialdata", "cellpose", "stardist", "astir"]
|
|
51
|
+
all = ["spatialdata", "cellpose", "stardist", "astir", "spotiflow", "instanseg-torch>=0.1.0"]
|
|
55
52
|
|
|
56
53
|
[build-system]
|
|
57
|
-
requires = ["
|
|
58
|
-
build-backend = "
|
|
54
|
+
requires = ["hatchling>=1.26"]
|
|
55
|
+
build-backend = "hatchling.build"
|
|
56
|
+
|
|
57
|
+
[tool.hatch.build.targets.wheel]
|
|
58
|
+
packages = ["spatialproteomics"]
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.sdist]
|
|
61
|
+
# only ship the package and the tests, not the docs (notebooks with outputs) or the data folder
|
|
62
|
+
include = ["spatialproteomics", "tests", "README.md", "LICENSE"]
|
|
59
63
|
|
|
60
64
|
|
|
61
65
|
[tool.black]
|
|
@@ -48,7 +48,7 @@ from .pp import (
|
|
|
48
48
|
threshold,
|
|
49
49
|
transform_expression_matrix,
|
|
50
50
|
)
|
|
51
|
-
from .tl import ToolAccessor, astir, cellpose,
|
|
51
|
+
from .tl import ToolAccessor, astir, cellpose, instanseg, stardist
|
|
52
52
|
|
|
53
53
|
__all__ = [
|
|
54
54
|
"load_image_data",
|
|
@@ -57,19 +57,17 @@ __all__ = [
|
|
|
57
57
|
"PreprocessingAccessor",
|
|
58
58
|
"LabelAccessor",
|
|
59
59
|
"PlotAccessor",
|
|
60
|
-
"SegmentationAccessor",
|
|
61
60
|
"ToolAccessor",
|
|
62
61
|
"NeighborhoodAccessor",
|
|
63
62
|
"Layers",
|
|
64
63
|
"Dims",
|
|
65
64
|
"Features",
|
|
66
65
|
"Props",
|
|
67
|
-
"merge_segmentation",
|
|
68
66
|
"percentage_positive",
|
|
69
67
|
"is_positive",
|
|
70
68
|
"cellpose",
|
|
71
69
|
"stardist",
|
|
72
|
-
"
|
|
70
|
+
"instanseg",
|
|
73
71
|
"add_observations",
|
|
74
72
|
"add_quantification",
|
|
75
73
|
"apply",
|
|
@@ -125,6 +125,7 @@ def read_from_spatialdata(
|
|
|
125
125
|
spatial_data_object (spatialdata.SpatialData, str): The spatialdata object to read data from. If str, spatialdata is used to read the file from that path.
|
|
126
126
|
image_key (str): The key of the image in the spatialdata object.
|
|
127
127
|
segmentation_key (str): The key of the segmentation in the spatialdata object.
|
|
128
|
+
table_key (str): The key of the table in the spatialdata object. If it does not exist, the observations are computed from the segmentation.
|
|
128
129
|
data_key (Optional[str], optional): The key for the image data in the spatialdata object. If None, the image_key will be used. Defaults to None.
|
|
129
130
|
consolidate_segmentation (bool, optional): If True, the segmentation will be consolidated to only include cells that are present in the table. Defaults to False.
|
|
130
131
|
cell_id (Optional[str], optional): The column name for the cell ID in the table. Defaults to "id".
|
|
@@ -132,12 +133,7 @@ def read_from_spatialdata(
|
|
|
132
133
|
spatialproteomics_object (xr.Dataset): The spatialproteomics object.
|
|
133
134
|
"""
|
|
134
135
|
import spatialdata
|
|
135
|
-
from spatialdata.transformations import
|
|
136
|
-
Affine,
|
|
137
|
-
Identity,
|
|
138
|
-
Translation,
|
|
139
|
-
get_transformation,
|
|
140
|
-
)
|
|
136
|
+
from spatialdata.transformations import get_transformation
|
|
141
137
|
|
|
142
138
|
if isinstance(spatial_data_object, str):
|
|
143
139
|
spatial_data_object = spatialdata.read_zarr(spatial_data_object)
|
|
@@ -160,30 +156,20 @@ def read_from_spatialdata(
|
|
|
160
156
|
y_coords = np.arange(image.shape[1])
|
|
161
157
|
x_coords = np.arange(image.shape[2])
|
|
162
158
|
|
|
163
|
-
#
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
a, b, c = matrix[0, :]
|
|
176
|
-
d, e, f = matrix[1, :]
|
|
177
|
-
|
|
178
|
-
if not np.isclose(b, 0) or not np.isclose(d, 0):
|
|
179
|
-
logger.warning(
|
|
180
|
-
"Affine transformation has shear components, which are not supported in spatialproteomics. Resetting coordinates to start from 0."
|
|
181
|
-
)
|
|
182
|
-
else:
|
|
183
|
-
x_coords = a * x_coords + c
|
|
184
|
-
y_coords = e * y_coords + f
|
|
159
|
+
# express any transform (Identity, Translation, Scale, Affine, Sequence, ...) as a 2D x/y affine.
|
|
160
|
+
# do not read transform.matrix directly: after a zarr round trip spatialdata stores the affine on
|
|
161
|
+
# the element axes, e.g. (c, y, x -> c, x, y), so the raw matrix is 4x4 and its row order varies.
|
|
162
|
+
matrix = transform.to_affine_matrix(input_axes=("x", "y"), output_axes=("x", "y"))
|
|
163
|
+
a, b, c = matrix[0, :]
|
|
164
|
+
d, e, f = matrix[1, :]
|
|
165
|
+
if not np.isclose(b, 0) or not np.isclose(d, 0):
|
|
166
|
+
logger.warning(
|
|
167
|
+
"Affine transformation has shear components, which are not supported in spatialproteomics. "
|
|
168
|
+
"Resetting coordinates to start from 0."
|
|
169
|
+
)
|
|
185
170
|
else:
|
|
186
|
-
|
|
171
|
+
x_coords = a * x_coords + c
|
|
172
|
+
y_coords = e * y_coords + f
|
|
187
173
|
|
|
188
174
|
# create the spatialproteomics object
|
|
189
175
|
obj = load_image_data(image, channel_coords=markers, x_coords=x_coords, y_coords=y_coords)
|
|
@@ -213,35 +199,49 @@ def read_from_spatialdata(
|
|
|
213
199
|
) # Cast back to original dtype
|
|
214
200
|
|
|
215
201
|
# if there are obs in the spatialdata object, we just use those and do not recompute them
|
|
216
|
-
add_obs_from_sdata =
|
|
202
|
+
add_obs_from_sdata = table_key in spatial_data_object.tables
|
|
203
|
+
if not add_obs_from_sdata and len(spatial_data_object.tables.keys()) > 0:
|
|
204
|
+
logger.warning(
|
|
205
|
+
f"Table key {table_key} not found in spatial data object (available keys: {list(spatial_data_object.tables.keys())}). "
|
|
206
|
+
"Computing the observations from the segmentation instead."
|
|
207
|
+
)
|
|
217
208
|
|
|
218
|
-
# obs (from anndata)
|
|
219
209
|
if add_obs_from_sdata:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
# Consolidate segmentation to only include cells that are present in the table and the segmentation mask
|
|
227
|
-
# Step 1: Get IDs in both segmentation and obs
|
|
228
|
-
ids_in_segmentation = np.unique(segmentation).astype(int)
|
|
229
|
-
ids_in_obs = obs[cell_id].astype(int).unique()
|
|
210
|
+
# copying, so that the table of the input object is not modified
|
|
211
|
+
obs = spatial_data_object.tables[table_key].obs.copy()
|
|
212
|
+
assert (
|
|
213
|
+
cell_id in obs.columns
|
|
214
|
+
), f"Column {cell_id} not found in the table. It is required to match the rows of the table to the cells in the segmentation mask. Available columns: {list(obs.columns)}."
|
|
215
|
+
obs[cell_id] = obs[cell_id].astype(int)
|
|
230
216
|
|
|
231
|
-
|
|
232
|
-
|
|
217
|
+
if consolidate_segmentation:
|
|
218
|
+
# Consolidate segmentation to only include cells that are present in the table and the segmentation mask
|
|
219
|
+
# Step 1: Keep only valid IDs (appear in both the segmentation and the table)
|
|
220
|
+
valid_ids = np.intersect1d(np.unique(segmentation).astype(int), obs[cell_id].unique())
|
|
233
221
|
|
|
234
|
-
# Step
|
|
222
|
+
# Step 2: Filter segmentation mask to keep only valid IDs
|
|
235
223
|
segmentation = np.where(np.isin(segmentation, valid_ids), segmentation, 0)
|
|
236
224
|
|
|
237
|
-
# Step
|
|
238
|
-
obs
|
|
239
|
-
|
|
225
|
+
# Step 3: Filter obs to keep only cells present in segmentation
|
|
226
|
+
obs = obs[obs[cell_id].isin(valid_ids)]
|
|
227
|
+
|
|
228
|
+
obj = obj.pp.add_segmentation(segmentation, add_obs=False, reindex=False)
|
|
229
|
+
|
|
230
|
+
# the cells coordinate is sorted by cell id, while the rows of the table can be in any order
|
|
231
|
+
# hence we align the table to the cells by their id instead of relying on the row order
|
|
232
|
+
cells = obj.coords[Dims.CELLS].values
|
|
233
|
+
table_ids = obs[cell_id].values
|
|
234
|
+
cells_without_row = np.setdiff1d(cells, table_ids)
|
|
235
|
+
rows_without_cell = np.setdiff1d(table_ids, cells)
|
|
236
|
+
has_duplicates = obs[cell_id].duplicated().any()
|
|
237
|
+
assert (
|
|
238
|
+
len(cells_without_row) == 0 and len(rows_without_cell) == 0 and not has_duplicates
|
|
239
|
+
), f"The cell ids in the table do not match the cells in the segmentation mask.\nCells in the segmentation mask without a row in the table: {len(cells_without_row)}\nRows in the table without a cell in the segmentation mask: {len(rows_without_cell)}\nDuplicate ids in the table: {has_duplicates}\nIf you wish to proceed regardless, set `consolidate_segmentation=True`, which will only keep cells appearing both in the segmentation mask and the table."
|
|
240
|
+
obs = obs.set_index(cell_id, drop=False).loc[cells].rename_axis(None)
|
|
240
241
|
|
|
241
|
-
obj = obj.pp.add_segmentation(segmentation, add_obs=not add_obs_from_sdata, reindex=False)
|
|
242
242
|
# next to adding the obs from the dataframe, we also add default obs to the object to ensure that obs includes the centroids
|
|
243
243
|
obj = obj.pp.add_obs_from_dataframe(obs).pp.add_observations()
|
|
244
244
|
else:
|
|
245
|
-
obj = obj.pp.add_segmentation(segmentation, add_obs=
|
|
245
|
+
obj = obj.pp.add_segmentation(segmentation, add_obs=True, reindex=False)
|
|
246
246
|
|
|
247
247
|
return obj
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from typing import Dict
|
|
2
2
|
|
|
3
|
-
import numpy as np
|
|
4
3
|
import pandas as pd
|
|
5
4
|
import xarray as xr
|
|
6
5
|
from sklearn.cluster import KMeans
|
|
7
6
|
from sklearn.preprocessing import StandardScaler
|
|
8
7
|
|
|
9
|
-
from ..constants import
|
|
8
|
+
from ..constants import Features, Layers
|
|
9
|
+
from ..pl.utils import _sample_colors
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class ImageContainer:
|
|
@@ -114,7 +114,7 @@ class ImageContainer:
|
|
|
114
114
|
self.kmeans_df = kmeans_df
|
|
115
115
|
|
|
116
116
|
# === ADDING CLUSTERS TO OBJECTS ===
|
|
117
|
-
colors =
|
|
117
|
+
colors = _sample_colors(k)
|
|
118
118
|
for id, sp_obj in self.objects.items():
|
|
119
119
|
# obtaining the number of cells contained in the object we are currently looking at
|
|
120
120
|
num_cells = sp_obj.sizes["cells"]
|
|
@@ -160,7 +160,7 @@ class ImageContainer:
|
|
|
160
160
|
self._compute_dataframes_from_existing_neighborhoods(neighborhood_col=neighborhood_col)
|
|
161
161
|
|
|
162
162
|
# computing the composition of neighborhoods (grouping by the neighborhood labels and summing them up)
|
|
163
|
-
neighborhood_composition = self.neighborhood_df
|
|
163
|
+
neighborhood_composition = self.neighborhood_df.copy()
|
|
164
164
|
neighborhood_composition[Features.NEIGHBORHOODS] = self.kmeans_df[Features.NEIGHBORHOODS].values
|
|
165
165
|
|
|
166
166
|
neighborhood_composition = neighborhood_composition.groupby(Features.NEIGHBORHOODS).mean()
|
|
@@ -189,7 +189,12 @@ class ImageContainer:
|
|
|
189
189
|
assert (
|
|
190
190
|
neighborhood_col in self.objects[id].pp.get_layer_as_df().columns
|
|
191
191
|
), f"Column {neighborhood_col} not found in the object. Please set the column with the parameter 'neighborhood_col'. Available columns are {self.objects[id].pp.get_layer_as_df().columns}"
|
|
192
|
-
|
|
192
|
+
# the column is renamed, so that the cluster annotations can be accessed in the same way as after compute_neighborhoods()
|
|
193
|
+
kmeans_df.append(
|
|
194
|
+
self.objects[id]
|
|
195
|
+
.pp.get_layer_as_df()[[neighborhood_col]]
|
|
196
|
+
.rename(columns={neighborhood_col: Features.NEIGHBORHOODS})
|
|
197
|
+
)
|
|
193
198
|
|
|
194
199
|
# replacing nans with 0s (this means that the ct was never called in that specific sample)
|
|
195
200
|
neighborhood_df = pd.concat(neighborhood_df).fillna(0)
|