spatialproteomics 0.8.5__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.
Files changed (221) hide show
  1. spatialproteomics-0.9.0/.gitignore +15 -0
  2. spatialproteomics-0.9.0/PKG-INFO +111 -0
  3. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/README.md +4 -1
  4. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/pyproject.toml +21 -15
  5. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/__init__.py +2 -4
  6. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/container.py +49 -49
  7. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/image_container/ImageContainer.py +10 -5
  8. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/la/label.py +107 -61
  9. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/nh/neighborhood.py +25 -15
  10. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/nh/utils.py +26 -21
  11. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pl/plot.py +34 -29
  12. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pl/utils.py +40 -2
  13. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pp/preprocessing.py +165 -87
  14. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pp/utils.py +65 -15
  15. spatialproteomics-0.9.0/spatialproteomics/tl/__init__.py +10 -0
  16. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/tl/tool.py +328 -59
  17. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/tl/utils.py +124 -12
  18. spatialproteomics-0.9.0/tests/__init__.py +0 -0
  19. spatialproteomics-0.9.0/tests/conftest.py +108 -0
  20. spatialproteomics-0.9.0/tests/image_container/test_image_container.py +71 -0
  21. spatialproteomics-0.9.0/tests/la/test_add_label_type.py +42 -0
  22. spatialproteomics-0.9.0/tests/la/test_add_labels.py +113 -0
  23. spatialproteomics-0.9.0/tests/la/test_format_labels.py +48 -0
  24. spatialproteomics-0.9.0/tests/la/test_label_properties.py +75 -0
  25. spatialproteomics-0.9.0/tests/la/test_label_select_deselect.py +95 -0
  26. spatialproteomics-0.9.0/tests/la/test_predict_cell_subtypes.py +188 -0
  27. spatialproteomics-0.9.0/tests/la/test_predict_cell_types_argmax.py +132 -0
  28. spatialproteomics-0.9.0/tests/la/test_remove_label_type.py +55 -0
  29. spatialproteomics-0.9.0/tests/la/test_remove_label_types_composition.py +24 -0
  30. spatialproteomics-0.9.0/tests/la/test_set_label_level.py +27 -0
  31. spatialproteomics-0.9.0/tests/la/test_threshold_label.py +69 -0
  32. spatialproteomics-0.9.0/tests/nh/test_add_neighborhood_obs.py +3 -0
  33. spatialproteomics-0.9.0/tests/nh/test_add_neighborhood_properties.py +16 -0
  34. spatialproteomics-0.9.0/tests/nh/test_cells_2_synchronization.py +75 -0
  35. spatialproteomics-0.9.0/tests/nh/test_compute_graph_features.py +5 -0
  36. spatialproteomics-0.9.0/tests/nh/test_compute_neighborhood_features.py +54 -0
  37. spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_delaunay.py +41 -0
  38. spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_knn.py +55 -0
  39. spatialproteomics-0.9.0/tests/nh/test_compute_neighborhoods_radius.py +52 -0
  40. spatialproteomics-0.9.0/tests/nh/test_nh_select_deselect.py +172 -0
  41. spatialproteomics-0.9.0/tests/nh/test_set_neighborhood_name.py +78 -0
  42. spatialproteomics-0.9.0/tests/pl/test_colorize.py +40 -0
  43. spatialproteomics-0.9.0/tests/pl/test_label_segmentation_mask.py +30 -0
  44. spatialproteomics-0.9.0/tests/pl/test_sample_colors.py +54 -0
  45. spatialproteomics-0.9.0/tests/pl/test_show.py +83 -0
  46. spatialproteomics-0.9.0/tests/pp/test_add_channel.py +85 -0
  47. spatialproteomics-0.9.0/tests/pp/test_add_layer.py +65 -0
  48. spatialproteomics-0.9.0/tests/pp/test_add_obs.py +125 -0
  49. spatialproteomics-0.9.0/tests/pp/test_add_quantification.py +93 -0
  50. spatialproteomics-0.9.0/tests/pp/test_add_segmentation.py +67 -0
  51. spatialproteomics-0.9.0/tests/pp/test_apply.py +9 -0
  52. spatialproteomics-0.9.0/tests/pp/test_convert_to_8bit.py +50 -0
  53. spatialproteomics-0.9.0/tests/pp/test_drop_channel.py +63 -0
  54. spatialproteomics-0.9.0/tests/pp/test_drop_layers.py +73 -0
  55. spatialproteomics-0.9.0/tests/pp/test_drop_observations.py +32 -0
  56. spatialproteomics-0.9.0/tests/pp/test_filter_by_obs.py +54 -0
  57. spatialproteomics-0.9.0/tests/pp/test_find_bright_cells.py +47 -0
  58. spatialproteomics-0.9.0/tests/pp/test_get_layer_as_df.py +22 -0
  59. spatialproteomics-0.9.0/tests/pp/test_grow_cells.py +47 -0
  60. spatialproteomics-0.9.0/tests/pp/test_handle_disconnected_cells.py +70 -0
  61. spatialproteomics-0.9.0/tests/pp/test_image_normalize.py +11 -0
  62. spatialproteomics-0.9.0/tests/pp/test_mask_cells.py +89 -0
  63. spatialproteomics-0.9.0/tests/pp/test_mask_region.py +74 -0
  64. spatialproteomics-0.9.0/tests/pp/test_merge_channels.py +89 -0
  65. spatialproteomics-0.9.0/tests/pp/test_merge_images.py +36 -0
  66. spatialproteomics-0.9.0/tests/pp/test_merge_segmentation.py +132 -0
  67. spatialproteomics-0.9.0/tests/pp/test_relabel_cells.py +32 -0
  68. spatialproteomics-0.9.0/tests/pp/test_remove_outlying_cells.py +36 -0
  69. spatialproteomics-0.9.0/tests/pp/test_rescale.py +61 -0
  70. spatialproteomics-0.9.0/tests/pp/test_slicing.py +141 -0
  71. spatialproteomics-0.9.0/tests/pp/test_threshold.py +240 -0
  72. spatialproteomics-0.9.0/tests/pp/test_threshold_against_snapshot.py +122 -0
  73. spatialproteomics-0.9.0/tests/pp/test_transform_expression_matrix.py +56 -0
  74. spatialproteomics-0.9.0/tests/scripts/generate_threshold_snapshot.py +100 -0
  75. spatialproteomics-0.9.0/tests/snapshots/threshold_snapshots.json +222 -0
  76. spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_predict_cell_subtypes_spatialdata.py +232 -0
  77. spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_predict_cell_types_argmax_spatialdata.py +61 -0
  78. spatialproteomics-0.9.0/tests/spatialdata_backend/la/test_threshold_label_spatialdata.py +22 -0
  79. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_add_obs_spatialdata.py +29 -0
  80. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_add_quantification_spatialdata.py +65 -0
  81. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_apply_spatialdata.py +15 -0
  82. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_filter_by_obs_spatialdata.py +63 -0
  83. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_grow_cells_spatialdata.py +55 -0
  84. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_merge_channels_spatialdata.py +43 -0
  85. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_threshold_spatialdata.py +218 -0
  86. spatialproteomics-0.9.0/tests/spatialdata_backend/pp/test_transform_expression_matrix_spatialdata.py +65 -0
  87. spatialproteomics-0.9.0/tests/spatialdata_backend/test_integration_spatialdata.py +40 -0
  88. spatialproteomics-0.9.0/tests/spatialdata_backend/test_read_from_spatialdata.py +22 -0
  89. spatialproteomics-0.9.0/tests/spatialdata_backend/tl/test_cellpose_spatialdata.py +12 -0
  90. spatialproteomics-0.9.0/tests/spatialdata_backend/tl/test_instanseg_spatialdata.py +12 -0
  91. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/_image/c/0/0/0 +0 -0
  92. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/_image/zarr.json +46 -0
  93. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/channels/c/0 +0 -0
  94. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/channels/zarr.json +41 -0
  95. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/x/c/0 +0 -0
  96. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/x/zarr.json +43 -0
  97. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/y/c/0 +0 -0
  98. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/y/zarr.json +43 -0
  99. spatialproteomics-0.9.0/tests/test_files/ds_image.zarr/zarr.json +6 -0
  100. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_image/c/0/0/0 +0 -0
  101. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_image/zarr.json +46 -0
  102. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_intensity/c/0/0 +0 -0
  103. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_intensity/zarr.json +48 -0
  104. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_layers/c/0/0 +0 -0
  105. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_layers/zarr.json +44 -0
  106. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_properties/c/0/0 +0 -0
  107. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_la_properties/zarr.json +44 -0
  108. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_obs/c/0/0 +0 -0
  109. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_obs/zarr.json +48 -0
  110. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_percentage_positive/c/0/0 +0 -0
  111. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_percentage_positive/zarr.json +48 -0
  112. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_segmentation/c/0/0 +0 -0
  113. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/_segmentation/zarr.json +46 -0
  114. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/cells/c/0 +0 -0
  115. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/cells/zarr.json +43 -0
  116. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/channels/c/0 +0 -0
  117. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/channels/zarr.json +41 -0
  118. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/features/c/0 +0 -0
  119. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/features/zarr.json +41 -0
  120. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_features/c/0 +0 -0
  121. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_features/zarr.json +41 -0
  122. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_props/c/0 +0 -0
  123. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/la_props/zarr.json +41 -0
  124. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/labels/c/0 +0 -0
  125. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/labels/zarr.json +43 -0
  126. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/x/c/0 +0 -0
  127. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/x/zarr.json +43 -0
  128. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/y/c/0 +0 -0
  129. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/y/zarr.json +43 -0
  130. spatialproteomics-0.9.0/tests/test_files/ds_labels.zarr/zarr.json +6 -0
  131. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_adjacency_matrix/c/0/0 +0 -0
  132. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_adjacency_matrix/zarr.json +46 -0
  133. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_image/c/0/0/0 +0 -0
  134. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_image/zarr.json +46 -0
  135. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_intensity/c/0/0 +0 -0
  136. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_intensity/zarr.json +48 -0
  137. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_layers/c/0/0 +0 -0
  138. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_layers/zarr.json +44 -0
  139. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_properties/c/0/0 +0 -0
  140. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_la_properties/zarr.json +44 -0
  141. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_neighborhoods/c/0/0 +0 -0
  142. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_neighborhoods/zarr.json +48 -0
  143. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_nh_properties/c/0/0 +0 -0
  144. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_nh_properties/zarr.json +44 -0
  145. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_obs/c/0/0 +0 -0
  146. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_obs/zarr.json +48 -0
  147. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_percentage_positive/c/0/0 +0 -0
  148. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_percentage_positive/zarr.json +48 -0
  149. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_segmentation/c/0/0 +0 -0
  150. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/_segmentation/zarr.json +46 -0
  151. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells/c/0 +0 -0
  152. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells/zarr.json +43 -0
  153. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells_2/c/0 +0 -0
  154. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/cells_2/zarr.json +43 -0
  155. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/channels/c/0 +0 -0
  156. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/channels/zarr.json +41 -0
  157. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/features/c/0 +0 -0
  158. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/features/zarr.json +41 -0
  159. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_features/c/0 +0 -0
  160. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_features/zarr.json +41 -0
  161. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_props/c/0 +0 -0
  162. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/la_props/zarr.json +41 -0
  163. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/labels/c/0 +0 -0
  164. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/labels/zarr.json +43 -0
  165. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/neighborhoods/c/0 +0 -0
  166. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/neighborhoods/zarr.json +43 -0
  167. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/nh_props/c/0 +0 -0
  168. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/nh_props/zarr.json +41 -0
  169. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/x/c/0 +0 -0
  170. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/x/zarr.json +43 -0
  171. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/y/c/0 +0 -0
  172. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/y/zarr.json +43 -0
  173. spatialproteomics-0.9.0/tests/test_files/ds_neighborhoods.zarr/zarr.json +6 -0
  174. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_image/c/0/0/0 +0 -0
  175. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_image/zarr.json +46 -0
  176. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_obs/c/0/0 +0 -0
  177. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_obs/zarr.json +48 -0
  178. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_segmentation/c/0/0 +0 -0
  179. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/_segmentation/zarr.json +46 -0
  180. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/cells/c/0 +0 -0
  181. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/cells/zarr.json +43 -0
  182. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/channels/c/0 +0 -0
  183. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/channels/zarr.json +41 -0
  184. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/features/c/0 +0 -0
  185. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/features/zarr.json +41 -0
  186. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/x/c/0 +0 -0
  187. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/x/zarr.json +43 -0
  188. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/y/c/0 +0 -0
  189. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/y/zarr.json +43 -0
  190. spatialproteomics-0.9.0/tests/test_files/ds_segmentation.zarr/zarr.json +6 -0
  191. spatialproteomics-0.9.0/tests/test_files/image.tiff +0 -0
  192. spatialproteomics-0.9.0/tests/test_files/segmentation.tiff +0 -0
  193. spatialproteomics-0.9.0/tests/test_public_api.py +6 -0
  194. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/tests/test_to_zarr.py +27 -0
  195. spatialproteomics-0.9.0/tests/tl/test_astir.py +61 -0
  196. spatialproteomics-0.9.0/tests/tl/test_cellpose.py +11 -0
  197. spatialproteomics-0.9.0/tests/tl/test_convert_to_anndata.py +84 -0
  198. spatialproteomics-0.9.0/tests/tl/test_convert_to_spatialdata.py +96 -0
  199. spatialproteomics-0.9.0/tests/tl/test_instanseg.py +26 -0
  200. spatialproteomics-0.8.5/PKG-INFO +0 -100
  201. spatialproteomics-0.8.5/setup.cfg +0 -4
  202. spatialproteomics-0.8.5/spatialproteomics/tl/__init__.py +0 -9
  203. spatialproteomics-0.8.5/spatialproteomics.egg-info/PKG-INFO +0 -100
  204. spatialproteomics-0.8.5/spatialproteomics.egg-info/SOURCES.txt +0 -35
  205. spatialproteomics-0.8.5/spatialproteomics.egg-info/dependency_links.txt +0 -1
  206. spatialproteomics-0.8.5/spatialproteomics.egg-info/requires.txt +0 -48
  207. spatialproteomics-0.8.5/spatialproteomics.egg-info/top_level.txt +0 -1
  208. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/LICENSE +0 -0
  209. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/base_logger.py +0 -0
  210. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/constants.py +0 -0
  211. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/image_container/__init__.py +0 -0
  212. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/la/__init__.py +0 -0
  213. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/la/utils.py +0 -0
  214. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/nh/__init__.py +0 -0
  215. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pl/__init__.py +0 -0
  216. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pp/__init__.py +0 -0
  217. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/pp/intensity.py +0 -0
  218. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/sd/__init__.py +0 -0
  219. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/spatialproteomics/sd/utils.py +0 -0
  220. {spatialproteomics-0.8.5 → spatialproteomics-0.9.0}/tests/test_container.py +0 -0
  221. {spatialproteomics-0.8.5 → 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/
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.5
2
+ Name: spatialproteomics
3
+ Version: 0.9.0
4
+ Summary: Spatialproteomics is an interoperable toolbox for analyzing highly multiplexed fluorescence image data
5
+ Author: Matthias Meyer-Bender, Harald Vohringer
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: cffi>=1.15.0
9
+ Requires-Dist: matplotlib>=3.8.0
10
+ Requires-Dist: numpy>=1.25
11
+ Requires-Dist: opencv-python>=4.11.0
12
+ Requires-Dist: pandas>=2.2.2
13
+ Requires-Dist: pyyaml>=6.0
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'
26
+ Provides-Extra: anndata
27
+ Requires-Dist: anndata>=0.10.0; extra == 'anndata'
28
+ Provides-Extra: astir
29
+ Requires-Dist: astir>=0.1.5; extra == 'astir'
30
+ Provides-Extra: cellpose
31
+ Requires-Dist: cellpose>=3.1.0; extra == 'cellpose'
32
+ Provides-Extra: dev
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
58
+
59
+ # spatialproteomics
60
+
61
+ [![PyPI version](https://badge.fury.io/py/spatialproteomics.svg)](https://badge.fury.io/py/spatialproteomics)
62
+
63
+ `Spatialproteomics` is an interoperable toolbox for analyzing highly multiplexed fluorescence image data. This analysis involves a sequence of steps, including segmentation, image processing, marker quantification, cell type classification, and neighborhood analysis.
64
+
65
+ <p align="center" width="100%">
66
+ <img src="docs/_static/img/figure_1.png" alt="Spatialproteomics orchestrates analysis workflows for highly multiplexed fluorescence images." style="width:70%;">
67
+ </p>
68
+
69
+ ## Principles
70
+
71
+ Multiplexed imaging data comprises at least 3 dimensions (i.e. `channels`, `x`, and `y`) and often contains additional data such as segmentation masks or cell type annotations associated with it. In `spatialproteomics`, we use `xarray` to create a data structure that keeps all of these data dimension in sync. This data structure can then be used to apply all sorts of operations to the data. Users can segment cells, perform different image processing steps, quantify protein expression, predict cell types, and plot their data in various ways. By providing researchers with those tools, `spatialproteomics` can be used to quickly explore highly multiplexed spatial proteomics data directly within jupyter notebooks.
72
+
73
+ <p align="center" width="100%">
74
+ <img src="docs/_static/img/supplementary_figure_1.png" alt="The spatialproteomics data structure enables synchronized subsetting across shared dimensions." style="width:70%;">
75
+ </p>
76
+
77
+ ## Getting Started
78
+
79
+ Please refer to the [documentation](https://sagar87.github.io/spatialproteomics) for details on the API and tutorials.
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
+
83
+ ## Installation
84
+
85
+ To install `spatialproteomics`, first create a python environment and install the package using
86
+
87
+ ```
88
+ pip install spatialproteomics
89
+ ```
90
+
91
+ The installation of the package should take less than a minute.
92
+
93
+ ## System Requirements
94
+ ### Hardware Requirements
95
+ `spatialproteomics` requires only a standard computer with enough RAM to support the in-memory operations. Certain steps of the pipeline, such as segmentation, benefit from using a GPU.
96
+
97
+ ### Software Requirements
98
+ The base version of `spatialproteomics` depends on the following packages:
99
+ ```
100
+ xarray
101
+ zarr
102
+ numpy
103
+ pandas
104
+ scikit-image
105
+ scikit-learn
106
+ opencv-python
107
+ matplotlib
108
+ ```
109
+
110
+ ## Citation
111
+ > Meyer-Bender, M., Voehringer, H., Schniederjohann, C., Koziel, S., Chung, E., Popova, E., ... & Huber, W. (2026). Spatialproteomics: an interoperable toolbox for analyzing highly multiplexed fluorescence image data. Nature Methods, 1-10.
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## Principles
12
12
 
13
- Multiplexed imaging data comprises at least 3 dimensions (i.e. `channels`, `x`, and `y`) and has often additional data such as segmentation masks or cell type annotations associated with it. In `spatialproteomics`, we use `xarray` to create a data structure that keeps all of these data dimension in sync. This data structure can then be used to apply all sorts of operations to the data. Users can segment cells, perform different image processing steps, quantify protein expression, predict cell types, and plot their data in various ways. By providing researchers with those tools, `spatialproteomics` can be used to quickly explore highly multiplexed spatial proteomics data directly within jupyter notebooks.
13
+ Multiplexed imaging data comprises at least 3 dimensions (i.e. `channels`, `x`, and `y`) and often contains additional data such as segmentation masks or cell type annotations associated with it. In `spatialproteomics`, we use `xarray` to create a data structure that keeps all of these data dimension in sync. This data structure can then be used to apply all sorts of operations to the data. Users can segment cells, perform different image processing steps, quantify protein expression, predict cell types, and plot their data in various ways. By providing researchers with those tools, `spatialproteomics` can be used to quickly explore highly multiplexed spatial proteomics data directly within jupyter notebooks.
14
14
 
15
15
  <p align="center" width="100%">
16
16
  <img src="docs/_static/img/supplementary_figure_1.png" alt="The spatialproteomics data structure enables synchronized subsetting across shared dimensions." style="width:70%;">
@@ -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.8.5"
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.10"
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>=2024.0.0",
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", # note that if you use spatialdata, you should use zarr>=3.0.0
19
- "numpy>=1.23",
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,11 +31,13 @@ docs = [
35
31
  "sphinx-multiversion>=0.2.4",
36
32
  "IPython>=8.0.0",
37
33
  ]
38
- spatialdata = ["spatialdata>=0.4.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"]
39
+ spotiflow = ["spotiflow"]
40
+ instanseg = ["instanseg-torch>=0.1.0"]
43
41
  dev = [
44
42
  "pytest>=7.1.2",
45
43
  "pytest-cov>=3.0.0",
@@ -48,12 +46,20 @@ dev = [
48
46
  "flake8>=5.0.4",
49
47
  "bandit>=1.7.4",
50
48
  "safety>=2.1.1",
49
+ "typing_extensions>=4.16", # to avoid anndata issues
51
50
  ]
52
- all = ["spatialdata", "cellpose", "stardist", "astir"]
51
+ all = ["spatialdata", "cellpose", "stardist", "astir", "spotiflow", "instanseg-torch>=0.1.0"]
53
52
 
54
53
  [build-system]
55
- requires = ["setuptools>=61.0,<81.0"]
56
- build-backend = "setuptools.build_meta"
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"]
57
63
 
58
64
 
59
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, mesmer, stardist
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
- "mesmer",
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
- # apply transform if exists
164
- if isinstance(transform, Identity):
165
- pass # Identity transform — do nothing
166
-
167
- elif isinstance(transform, Translation):
168
- shift_y, shift_x = transform.translation
169
- y_coords = y_coords + shift_y
170
- x_coords = x_coords + shift_x
171
-
172
- elif isinstance(transform, Affine):
173
- matrix = transform.matrix
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
- logger.warning(f"Unsupported transform {transform}, resetting coordinates for the spatialproteomics object.")
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 = len(spatial_data_object.tables.keys()) > 0
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
- obs = spatial_data_object.tables[table_key].obs
221
- if not consolidate_segmentation:
222
- assert (
223
- obs.shape[0] == len(np.unique(segmentation)) - 1
224
- ), f"The number of cells in the segmentation does not match the number of observations in the table.\nNumber of cells in the segmentation mask: {len(np.unique(segmentation)) - 1}\nNumber of observations: {obs.shape[0]}\nIf you wish to proceed regardless, set `consolidate_segmentation=True`, which will only keep cells appearing both in the segmentation mask and the table."
225
- else:
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
- # Step 2: Keep only valid IDs (appear in both)
232
- valid_ids = np.intersect1d(ids_in_segmentation, ids_in_obs, assume_unique=True)
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 3: Filter segmentation mask to keep only valid IDs
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 4: Filter obs to keep only cells present in segmentation
238
- obs[cell_id] = obs[cell_id].astype(int)
239
- obs = obs[obs[cell_id].isin(valid_ids)].copy()
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=not add_obs_from_sdata, reindex=False)
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 COLORS, Features, Layers
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 = np.random.choice(COLORS, size=k, replace=False)
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
- kmeans_df.append(self.objects[id].pp.get_layer_as_df()[[neighborhood_col]])
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)