From 828683924f316c77e96a90db7227cc1a25bb0c58 Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Tue, 10 Dec 2024 08:56:44 +0100 Subject: [PATCH 1/6] SC_40 issue with coordinate system cluster intensity --- README.md | 8 +++---- .../pixel_clustering/_cluster_intensity.py | 21 +++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ac12af3..033bcbd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Note: This package is still under very active development. ## Installation -Check out the docs for [installation instructions](docs/installation.md). +Check out the docs for [installation instructions](https://github.com/saeyslab/harpy/blob/main/docs/installation.md). ## Tutorials @@ -25,11 +25,11 @@ Tutorials are available [here](https://harpy.readthedocs.io/en/latest/). ## Usage -[Learn](docs/usage.md) how Harpy can be integrated into your workflow in different ways. +[Learn](https://github.com/saeyslab/harpy/blob/main/docs/usage.md) how Harpy can be integrated into your workflow in different ways. ## Contributing -See [here](docs/contributing.md) for info on how to contribute to Harpy. +See [here](https://github.com/saeyslab/harpy/blob/main/docs/contributing.md) for info on how to contribute to Harpy. ## References @@ -37,7 +37,7 @@ See [here](docs/contributing.md) for info on how to contribute to Harpy. ## License -Check license under license. Harpy is free for academic usage. +Check the [license](https://github.com/saeyslab/harpy/blob/main/LICENSE). Harpy is free for academic usage. For commercial usage, please contact Saeyslab. ## Issues diff --git a/src/harpy/table/pixel_clustering/_cluster_intensity.py b/src/harpy/table/pixel_clustering/_cluster_intensity.py index e90ac17..2f30713 100644 --- a/src/harpy/table/pixel_clustering/_cluster_intensity.py +++ b/src/harpy/table/pixel_clustering/_cluster_intensity.py @@ -27,6 +27,7 @@ def cluster_intensity( img_layer: str | Iterable[str], labels_layer: str | Iterable[str], output_layer: str, + to_coordinate_system: str | Iterable[str] = "global", channels: int | str | Iterable[int] | Iterable[str] | None = None, chunks: str | int | tuple[int, ...] | None = 10000, overwrite=False, @@ -50,6 +51,10 @@ def cluster_intensity( The labels layer in `sdata` that contains the SOM cluster IDs. I.e. the `output_layer_clusters` labels layer obtained through `harpy.im.flowsom`. output_layer The output table layer in `sdata` where results are stored. + to_coordinate_system + The coordinate system that holds `img_layer` and `labels_layer`. + If `img_layer` and `labels_layer` are provided as a list, + elements in `to_coordinate_system` are the respective coordinate systems that holds the elements in `img_layer` and `labels_layer`. channels Specifies the channels to be included in the intensity calculation. chunks @@ -63,6 +68,8 @@ def cluster_intensity( Raises ------ + AssertionError + If number of provided `img_layer`, `labels_layer` and `to_coordinate_system` is not equal. AssertionError If some labels in `labels_layer` are not found in the provided mapping pandas Series. @@ -76,10 +83,19 @@ def cluster_intensity( if isinstance(labels_layer, Iterable) and not isinstance(labels_layer, str) else [labels_layer] ) + to_coordinate_system = ( + list(to_coordinate_system) + if isinstance(to_coordinate_system, Iterable) and not isinstance(to_coordinate_system, str) + else [to_coordinate_system] + ) - assert len(img_layer) == len(labels_layer) + assert ( + len(img_layer) == len(labels_layer) == len(to_coordinate_system) + ), "The number of provided 'img_layer', 'labels_layer' and 'to_coordinate_system' should be equal." - for i, (_img_layer, _labels_layer) in enumerate(zip(img_layer, labels_layer)): + for i, (_img_layer, _labels_layer, _to_coordinate_system) in enumerate( + zip(img_layer, labels_layer, to_coordinate_system) + ): se = _get_spatial_element(sdata, layer=_labels_layer) labels = da.unique(se.data).compute() @@ -100,6 +116,7 @@ def cluster_intensity( labels_layer=_labels_layer, output_layer=output_layer, channels=channels, + to_coordinate_system=_to_coordinate_system, chunks=chunks, append=append, overwrite=overwrite, From 2b2bd5e3cfc95b9896e4c505d2b9e2bb6ee40307 Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Tue, 10 Dec 2024 09:12:44 +0100 Subject: [PATCH 2/6] SC_40 update notebook --- ...lowSOM_for_pixel_and_cell_clustering.ipynb | 1374 ++++++++++++----- 1 file changed, 973 insertions(+), 401 deletions(-) diff --git a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb index 114df67..d379539 100644 --- a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb +++ b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb @@ -9,15 +9,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "metadata": {}, "outputs": [ { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/dask/dataframe/__init__.py:31: FutureWarning: The legacy Dask DataFrame implementation is deprecated and will be removed in a future version. Set the configuration option `dataframe.query-planning` to `True` or None to enable the new Dask Dataframe implementation and silence this warning.\n", + " warnings.warn(\n" ] } ], @@ -41,41 +41,43 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:18:53,290 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:53,348 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", - "2024-06-14 10:18:53,351 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:53,357 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", - "2024-06-14 10:18:53,359 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:53,365 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", - "2024-06-14 10:18:53,394 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n" + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n", + "2024-12-10 08:57:55,787 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:55,865 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", + "2024-12-10 08:57:55,867 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:55,871 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", + "2024-12-10 08:57:55,873 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:55,877 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", + "2024-12-10 08:57:55,895 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "/Users/benjaminr/.cache/huggingface/datasets/downloads/extracted/ccde124668e88cec60561ae6aa0b5dd0317fef8e1096373c8ac24b309eefd749/post_clustering\n" + "/Users/arnedf/.cache/huggingface/datasets/downloads/extracted/ed276a09a07145a5c25cd3c0a3fd99368fc2f3387300f55927c0b600c043de39/post_clustering\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:18:53,518 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", - "2024-06-14 10:18:53,520 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:53,550 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", - "2024-06-14 10:18:53,571 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:53,580 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/anndata/_core/anndata.py:183: ImplicitModificationWarning: Transforming to str index.\n", + "2024-12-10 08:57:55,994 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", + "2024-12-10 08:57:55,996 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:56,001 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", + "2024-12-10 08:57:56,003 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:56,008 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning: Transforming to str index.\n", " warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:929: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1046: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.\n", " adata.uns[cls.ATTRS_KEY] = attr\n" ] }, @@ -84,13 +86,13 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ └── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ └── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ └── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ └── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", @@ -98,7 +100,7 @@ " raw_image_fov0 (Images), raw_image_fov1 (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels)" ] }, - "execution_count": 5, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -110,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -136,17 +138,17 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:18:54,056 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:54,549 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", - "2024-06-14 10:18:54,552 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:54,890 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" + "2024-12-10 08:57:56,538 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:57,323 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", + "2024-12-10 08:57:57,325 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:57:58,103 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" ] }, { @@ -154,15 +156,15 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ ├── 'raw_image_fov0_processed': SpatialImage[cyx] (16, 512, 512)\n", - "│ ├── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", - "│ └── 'raw_image_fov1_processed': SpatialImage[cyx] (16, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ ├── 'raw_image_fov0_processed': DataArray[cyx] (16, 512, 512)\n", + "│ ├── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", + "│ └── 'raw_image_fov1_processed': DataArray[cyx] (16, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ └── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ └── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", @@ -170,7 +172,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels)" ] }, - "execution_count": 7, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -190,24 +192,24 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-06-14 10:18:55.164\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-06-14 10:18:55.165\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-06-14 10:18:58.077\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-06-14 10:18:58,601 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:59,231 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-06-14 10:18:59,232 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:18:59,625 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", - "2024-06-14 10:18:59,627 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:19:00,514 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", - "2024-06-14 10:19:00,515 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is (c, (z), y, x)\n", - "2024-06-14 10:19:01,370 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" + "\u001b[32m2024-12-10 08:57:58.266\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 08:57:58.267\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 08:58:00.099\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 08:58:00,448 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:58:00,946 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 08:58:00,947 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:58:01,236 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", + "2024-12-10 08:58:01,290 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:58:01,972 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-10 08:58:01,972 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 08:58:02,604 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" ] }, { @@ -215,19 +217,19 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ ├── 'raw_image_fov0_processed': SpatialImage[cyx] (16, 512, 512)\n", - "│ ├── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", - "│ └── 'raw_image_fov1_processed': SpatialImage[cyx] (16, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ ├── 'raw_image_fov0_processed': DataArray[cyx] (16, 512, 512)\n", + "│ ├── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", + "│ └── 'raw_image_fov1_processed': DataArray[cyx] (16, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'raw_image_fov0_flowsom_clusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov0_flowsom_metaclusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov1_flowsom_clusters': SpatialImage[yx] (1024, 1024)\n", - "│ └── 'raw_image_fov1_flowsom_metaclusters': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'raw_image_fov0_flowsom_clusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov0_flowsom_metaclusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov1_flowsom_clusters': DataArray[yx] (1024, 1024)\n", + "│ └── 'raw_image_fov1_flowsom_metaclusters': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", @@ -235,7 +237,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 8, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -259,26 +261,26 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/Users/benjaminr/Documents/GitHub/harpy/src/harpy/table/_allocation_intensity.py:210: ImplicitModificationWarning: Setting element `.obsm['spatial']` of view, initializing view as actual.\n", - " adata.obsm[\"spatial\"] = coordinates\n", - "/Users/benjaminr/Documents/GitHub/harpy/src/harpy/table/_allocation_intensity.py:210: ImplicitModificationWarning: Setting element `.obsm['spatial']` of view, initializing view as actual.\n", - " adata.obsm[\"spatial\"] = coordinates\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", + "/Users/arnedf/VIB/harpy/src/harpy/table/_allocation_intensity.py:217: ImplicitModificationWarning: Setting element `.obsm['spatial']` of view, initializing view as actual.\n", + " adata.obsm[_SPATIAL] = coordinates\n", + "/Users/arnedf/VIB/harpy/src/harpy/table/_allocation_intensity.py:217: ImplicitModificationWarning: Setting element `.obsm['spatial']` of view, initializing view as actual.\n", + " adata.obsm[_SPATIAL] = coordinates\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "2024-06-14 10:19:02,922 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-06-14 10:19:02,929 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", - "/Users/benjaminr/Documents/GitHub/harpy/src/harpy/table/_manager.py:33: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", - " adata = spatialdata.models.TableModel.parse(\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", + "2024-12-10 09:04:14,876 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 09:04:14,893 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", + " return convert_region_column_to_categorical(adata)\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] }, @@ -287,19 +289,19 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ ├── 'raw_image_fov0_processed': SpatialImage[cyx] (16, 512, 512)\n", - "│ ├── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", - "│ └── 'raw_image_fov1_processed': SpatialImage[cyx] (16, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ ├── 'raw_image_fov0_processed': DataArray[cyx] (16, 512, 512)\n", + "│ ├── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", + "│ └── 'raw_image_fov1_processed': DataArray[cyx] (16, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'raw_image_fov0_flowsom_clusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov0_flowsom_metaclusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov1_flowsom_clusters': SpatialImage[yx] (1024, 1024)\n", - "│ └── 'raw_image_fov1_flowsom_metaclusters': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'raw_image_fov0_flowsom_clusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov0_flowsom_metaclusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov1_flowsom_clusters': DataArray[yx] (1024, 1024)\n", + "│ └── 'raw_image_fov1_flowsom_metaclusters': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " ├── 'counts_clusters': AnnData (100, 16)\n", " └── 'table': AnnData (1414, 22)\n", @@ -308,7 +310,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 9, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -319,7 +321,7 @@ " mapping=mapping,\n", " img_layer=[\"raw_image_fov0_processed\", \"raw_image_fov1_processed\"],\n", " labels_layer=[\"raw_image_fov0_flowsom_clusters\", \"raw_image_fov1_flowsom_clusters\"],\n", - " # labels_layer=\"raw_image_fov0_flowsom_clusters\",\n", + " to_coordinate_system=[ \"global\", \"global\" ],\n", " output_layer=\"counts_clusters\",\n", " overwrite=True,\n", ")\n", @@ -329,25 +331,25 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:19:03,234 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", - "2024-06-14 10:19:03,241 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", - "/Users/benjaminr/Documents/GitHub/harpy/src/harpy/table/_manager.py:33: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", - " adata = spatialdata.models.TableModel.parse(\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", + "2024-12-10 09:04:24,536 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", + "2024-12-10 09:04:24,552 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", + " return convert_region_column_to_categorical(adata)\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "\u001b[32m2024-06-14 10:19:03.270\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-06-14 10:19:03.271\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-06-14 10:19:03.302\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-06-14 10:19:03,514 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", - "2024-06-14 10:19:03,535 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", + "\u001b[32m2024-12-10 09:04:24.598\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 09:04:24.599\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 09:04:24.622\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 09:04:24,755 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", + "2024-12-10 09:04:24,770 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] }, @@ -356,19 +358,19 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ ├── 'raw_image_fov0_processed': SpatialImage[cyx] (16, 512, 512)\n", - "│ ├── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", - "│ └── 'raw_image_fov1_processed': SpatialImage[cyx] (16, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ ├── 'raw_image_fov0_processed': DataArray[cyx] (16, 512, 512)\n", + "│ ├── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", + "│ └── 'raw_image_fov1_processed': DataArray[cyx] (16, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'raw_image_fov0_flowsom_clusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov0_flowsom_metaclusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov1_flowsom_clusters': SpatialImage[yx] (1024, 1024)\n", - "│ └── 'raw_image_fov1_flowsom_metaclusters': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'raw_image_fov0_flowsom_clusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov0_flowsom_metaclusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov1_flowsom_clusters': DataArray[yx] (1024, 1024)\n", + "│ └── 'raw_image_fov1_flowsom_metaclusters': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " ├── 'counts_clusters': AnnData (100, 16)\n", " ├── 'table': AnnData (1414, 22)\n", @@ -378,7 +380,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 10, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -401,17 +403,17 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:19:03,666 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-06-14 10:19:03,670 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-06-14 10:19:03,670 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", - "/opt/homebrew/Caskroom/mambaforge/base/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:122: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", + "2024-12-10 09:04:29,950 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:04:29,955 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:04:29,967 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", + "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] }, @@ -420,19 +422,19 @@ "text/plain": [ "SpatialData object\n", "├── Images\n", - "│ ├── 'raw_image_fov0': SpatialImage[cyx] (22, 512, 512)\n", - "│ ├── 'raw_image_fov0_processed': SpatialImage[cyx] (16, 512, 512)\n", - "│ ├── 'raw_image_fov1': SpatialImage[cyx] (22, 1024, 1024)\n", - "│ └── 'raw_image_fov1_processed': SpatialImage[cyx] (16, 1024, 1024)\n", + "│ ├── 'raw_image_fov0': DataArray[cyx] (22, 512, 512)\n", + "│ ├── 'raw_image_fov0_processed': DataArray[cyx] (16, 512, 512)\n", + "│ ├── 'raw_image_fov1': DataArray[cyx] (22, 1024, 1024)\n", + "│ └── 'raw_image_fov1_processed': DataArray[cyx] (16, 1024, 1024)\n", "├── Labels\n", - "│ ├── 'label_nuclear_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_nuclear_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'label_whole_fov0': SpatialImage[yx] (512, 512)\n", - "│ ├── 'label_whole_fov1': SpatialImage[yx] (1024, 1024)\n", - "│ ├── 'raw_image_fov0_flowsom_clusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov0_flowsom_metaclusters': SpatialImage[yx] (512, 512)\n", - "│ ├── 'raw_image_fov1_flowsom_clusters': SpatialImage[yx] (1024, 1024)\n", - "│ └── 'raw_image_fov1_flowsom_metaclusters': SpatialImage[yx] (1024, 1024)\n", + "│ ├── 'label_nuclear_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_nuclear_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'label_whole_fov0': DataArray[yx] (512, 512)\n", + "│ ├── 'label_whole_fov1': DataArray[yx] (1024, 1024)\n", + "│ ├── 'raw_image_fov0_flowsom_clusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov0_flowsom_metaclusters': DataArray[yx] (512, 512)\n", + "│ ├── 'raw_image_fov1_flowsom_clusters': DataArray[yx] (1024, 1024)\n", + "│ └── 'raw_image_fov1_flowsom_metaclusters': DataArray[yx] (1024, 1024)\n", "└── Tables\n", " ├── 'counts_clusters': AnnData (100, 16)\n", " ├── 'table': AnnData (1414, 22)\n", @@ -442,7 +444,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 11, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -462,16 +464,16 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-06-14 10:19:03,790 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-06-14 10:19:03,793 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-06-14 10:19:03,796 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" + "2024-12-10 09:04:58,581 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:04:58,582 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:04:58,584 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" ] }, { @@ -540,114 +542,114 @@ " \n", " \n", " \n", - " 1_counts_clusters_c87db112\n", - " 2.957331\n", - " 4.494543\n", - " 3.305711\n", - " 4.343360\n", - " 1.849581\n", - " 5.298170\n", - " 3.745769\n", - " 2.057324\n", - " 2.595093\n", - " 1.275055\n", - " 7.540906\n", - " 7.779709\n", - " 1.745743\n", - " 1.576688\n", - " 4.947849\n", - " 89.713973\n", - " 5\n", + " 1_counts_clusters_2d02715e\n", + " 37.843970\n", + " 2.887842\n", + " 97.043740\n", + " 5.178658\n", + " 1.315880\n", + " 0.589464\n", + " 30.252512\n", + " 1.639205\n", + " 2.432772\n", + " 2.077082\n", + " 7.781796\n", + " 4.139287\n", + " 1.638660\n", + " 2.509107\n", + " 2.552425\n", + " 7.210590\n", + " 2\n", + " 1\n", + " 9930\n", + " \n", + " \n", + " 2_counts_clusters_2d02715e\n", + " 38.690112\n", + " 9.945175\n", + " 49.737972\n", + " 5.014744\n", + " 8.713191\n", + " 1.219908\n", + " 56.096997\n", + " 2.077967\n", + " 4.129621\n", + " 2.686037\n", + " 5.455420\n", + " 5.524063\n", + " 2.271283\n", + " 3.385231\n", + " 0.894532\n", + " 8.693713\n", " 1\n", - " 9050\n", - " \n", - " \n", - " 2_counts_clusters_c87db112\n", - " 9.223635\n", - " 13.199765\n", - " 5.344522\n", - " 6.280923\n", - " 10.007229\n", - " 2.288556\n", - " 24.313907\n", - " 4.365400\n", - " 6.206642\n", - " 2.654662\n", - " 8.120834\n", - " 9.743484\n", - " 4.143529\n", - " 6.264831\n", - " 3.418407\n", - " 50.938679\n", - " 5\n", " 2\n", - " 9495\n", - " \n", - " \n", - " 3_counts_clusters_c87db112\n", - " 6.237812\n", - " 9.367096\n", - " 5.586749\n", - " 12.584922\n", - " 3.089530\n", - " 3.213206\n", - " 8.372398\n", - " 6.089461\n", - " 9.301675\n", - " 4.037615\n", - " 22.116019\n", - " 14.121541\n", - " 9.079312\n", - " 5.893481\n", - " 8.240330\n", - " 34.542586\n", - " 5\n", + " 12134\n", + " \n", + " \n", + " 3_counts_clusters_2d02715e\n", + " 73.091492\n", + " 17.922896\n", + " 18.220559\n", + " 4.631251\n", + " 4.585831\n", + " 1.025564\n", + " 52.106125\n", + " 2.153796\n", + " 4.097220\n", + " 2.331725\n", + " 7.267913\n", + " 6.139904\n", + " 2.960410\n", + " 2.698596\n", + " 1.826165\n", + " 9.665717\n", + " 1\n", " 3\n", - " 13887\n", - " \n", - " \n", - " 4_counts_clusters_c87db112\n", - " 18.534875\n", - " 4.432272\n", - " 49.607468\n", - " 7.216803\n", - " 1.551463\n", - " 0.690981\n", - " 17.769115\n", - " 2.776675\n", - " 3.575007\n", - " 2.577310\n", - " 29.798437\n", - " 17.675432\n", - " 2.835710\n", - " 3.067414\n", - " 6.869558\n", - " 9.590902\n", + " 5392\n", + " \n", + " \n", + " 4_counts_clusters_2d02715e\n", + " 76.282287\n", + " 61.344410\n", + " 2.660174\n", + " 3.988683\n", + " 3.950231\n", + " 0.583871\n", + " 39.929262\n", + " 1.899014\n", + " 2.709320\n", + " 1.705489\n", + " 7.024916\n", + " 4.346849\n", + " 2.103179\n", + " 2.492270\n", + " 1.044199\n", + " 5.976883\n", " 9\n", " 4\n", - " 10893\n", - " \n", - " \n", - " 5_counts_clusters_c87db112\n", - " 30.877554\n", - " 3.149300\n", - " 95.926183\n", - " 6.370782\n", - " 1.371339\n", - " 0.650704\n", - " 27.585160\n", - " 2.047785\n", - " 2.841191\n", - " 2.113751\n", - " 9.091455\n", - " 5.126966\n", - " 1.822619\n", - " 3.226701\n", - " 2.975826\n", - " 8.591069\n", + " 12617\n", + " \n", + " \n", + " 5_counts_clusters_2d02715e\n", + " 47.305260\n", + " 59.382376\n", + " 3.534356\n", + " 5.237534\n", + " 8.039006\n", + " 0.985423\n", + " 55.497515\n", + " 2.064406\n", + " 4.395945\n", + " 2.033076\n", + " 4.772678\n", + " 4.934692\n", + " 2.381851\n", + " 4.444559\n", + " 0.383196\n", + " 5.731354\n", " 9\n", " 5\n", - " 10411\n", + " 16815\n", " \n", " \n", " ...\n", @@ -672,114 +674,114 @@ " ...\n", " \n", " \n", - " 96_counts_clusters_c87db112\n", - " 2.338454\n", - " 9.962485\n", - " 2.193743\n", - " 62.699224\n", - " 0.810325\n", - " 0.677078\n", - " 9.805510\n", - " 3.943257\n", - " 9.179419\n", - " 1.048139\n", - " 40.200144\n", - " 11.909424\n", - " 1.028891\n", - " 8.213371\n", - " 3.419144\n", - " 4.546988\n", - " 2\n", + " 96_counts_clusters_2d02715e\n", + " 3.381922\n", + " 10.202954\n", + " 2.722567\n", + " 19.882297\n", + " 2.628480\n", + " 1.435061\n", + " 12.535290\n", + " 6.423287\n", + " 7.808438\n", + " 1.716372\n", + " 37.751931\n", + " 11.812116\n", + " 2.634270\n", + " 31.108982\n", + " 6.185559\n", + " 9.853439\n", + " 5\n", " 96\n", - " 13135\n", - " \n", - " \n", - " 97_counts_clusters_c87db112\n", - " 2.924828\n", - " 14.908827\n", - " 2.606520\n", - " 75.980420\n", - " 1.187327\n", - " 1.034916\n", - " 13.934763\n", - " 6.531429\n", - " 14.983489\n", - " 1.084566\n", - " 12.627397\n", - " 9.501719\n", - " 1.691567\n", - " 14.328754\n", - " 5.775819\n", - " 8.412790\n", - " 18\n", + " 11251\n", + " \n", + " \n", + " 97_counts_clusters_2d02715e\n", + " 2.470278\n", + " 8.337522\n", + " 2.250204\n", + " 45.239891\n", + " 0.850247\n", + " 0.568664\n", + " 8.317586\n", + " 3.651513\n", + " 7.229076\n", + " 1.053102\n", + " 55.057834\n", + " 11.486410\n", + " 1.136371\n", + " 6.642796\n", + " 3.817631\n", + " 4.767680\n", + " 5\n", " 97\n", - " 18881\n", - " \n", - " \n", - " 98_counts_clusters_c87db112\n", - " 2.663261\n", - " 14.675678\n", - " 2.450740\n", - " 49.446807\n", - " 0.936380\n", - " 0.965804\n", - " 15.280870\n", - " 6.356314\n", - " 12.865684\n", - " 1.003338\n", - " 11.538158\n", - " 7.572785\n", - " 1.616540\n", - " 45.161700\n", - " 4.578395\n", - " 9.472542\n", - " 2\n", + " 13194\n", + " \n", + " \n", + " 98_counts_clusters_2d02715e\n", + " 3.030046\n", + " 12.170709\n", + " 2.506028\n", + " 59.447868\n", + " 1.032256\n", + " 0.860999\n", + " 11.455320\n", + " 4.825058\n", + " 9.948482\n", + " 1.224571\n", + " 33.234845\n", + " 12.156787\n", + " 1.475615\n", + " 9.946127\n", + " 4.933891\n", + " 6.348947\n", + " 5\n", " 98\n", - " 9606\n", - " \n", - " \n", - " 99_counts_clusters_c87db112\n", - " 2.786221\n", - " 16.886792\n", - " 2.544968\n", - " 57.760554\n", - " 1.510566\n", - " 0.621739\n", - " 9.873467\n", - " 9.815158\n", - " 48.120955\n", - " 1.054896\n", - " 9.604530\n", - " 7.028433\n", - " 1.367574\n", - " 9.942413\n", - " 3.265405\n", - " 11.612421\n", - " 8\n", + " 15672\n", + " \n", + " \n", + " 99_counts_clusters_2d02715e\n", + " 3.106052\n", + " 14.744514\n", + " 2.634652\n", + " 77.775664\n", + " 1.103696\n", + " 0.984863\n", + " 14.039679\n", + " 5.912146\n", + " 12.283513\n", + " 1.081740\n", + " 13.259535\n", + " 10.251130\n", + " 1.735470\n", + " 12.797073\n", + " 6.092375\n", + " 8.267192\n", + " 5\n", " 99\n", - " 10220\n", - " \n", - " \n", - " 100_counts_clusters_c87db112\n", - " 1.501354\n", - " 12.916443\n", - " 1.732045\n", - " 106.018177\n", - " 0.495795\n", - " 0.495713\n", - " 10.607854\n", - " 5.464689\n", - " 14.148630\n", - " 0.671717\n", - " 10.156424\n", - " 7.053110\n", - " 0.598646\n", - " 11.385688\n", - " 3.044625\n", - " 5.240363\n", + " 16393\n", + " \n", + " \n", + " 100_counts_clusters_2d02715e\n", + " 1.480684\n", + " 13.220733\n", + " 1.721745\n", + " 106.230223\n", + " 0.480134\n", + " 0.498194\n", + " 10.636129\n", + " 5.904330\n", + " 14.462784\n", + " 0.657815\n", + " 9.449697\n", + " 6.441781\n", + " 0.566056\n", + " 12.013471\n", + " 2.820398\n", + " 5.216806\n", " 18\n", " 100\n", - " 10450\n", + " 10009\n", " \n", " \n", "\n", @@ -789,78 +791,78 @@ "text/plain": [ "channels CD3 CD4 CD8 CD14 \\\n", "cells \n", - "1_counts_clusters_c87db112 2.957331 4.494543 3.305711 4.343360 \n", - "2_counts_clusters_c87db112 9.223635 13.199765 5.344522 6.280923 \n", - "3_counts_clusters_c87db112 6.237812 9.367096 5.586749 12.584922 \n", - "4_counts_clusters_c87db112 18.534875 4.432272 49.607468 7.216803 \n", - "5_counts_clusters_c87db112 30.877554 3.149300 95.926183 6.370782 \n", + "1_counts_clusters_2d02715e 37.843970 2.887842 97.043740 5.178658 \n", + "2_counts_clusters_2d02715e 38.690112 9.945175 49.737972 5.014744 \n", + "3_counts_clusters_2d02715e 73.091492 17.922896 18.220559 4.631251 \n", + "4_counts_clusters_2d02715e 76.282287 61.344410 2.660174 3.988683 \n", + "5_counts_clusters_2d02715e 47.305260 59.382376 3.534356 5.237534 \n", "... ... ... ... ... \n", - "96_counts_clusters_c87db112 2.338454 9.962485 2.193743 62.699224 \n", - "97_counts_clusters_c87db112 2.924828 14.908827 2.606520 75.980420 \n", - "98_counts_clusters_c87db112 2.663261 14.675678 2.450740 49.446807 \n", - "99_counts_clusters_c87db112 2.786221 16.886792 2.544968 57.760554 \n", - "100_counts_clusters_c87db112 1.501354 12.916443 1.732045 106.018177 \n", + "96_counts_clusters_2d02715e 3.381922 10.202954 2.722567 19.882297 \n", + "97_counts_clusters_2d02715e 2.470278 8.337522 2.250204 45.239891 \n", + "98_counts_clusters_2d02715e 3.030046 12.170709 2.506028 59.447868 \n", + "99_counts_clusters_2d02715e 3.106052 14.744514 2.634652 77.775664 \n", + "100_counts_clusters_2d02715e 1.480684 13.220733 1.721745 106.230223 \n", "\n", - "channels CD20 CD31 CD45 CD68 \\\n", - "cells \n", - "1_counts_clusters_c87db112 1.849581 5.298170 3.745769 2.057324 \n", - "2_counts_clusters_c87db112 10.007229 2.288556 24.313907 4.365400 \n", - "3_counts_clusters_c87db112 3.089530 3.213206 8.372398 6.089461 \n", - "4_counts_clusters_c87db112 1.551463 0.690981 17.769115 2.776675 \n", - "5_counts_clusters_c87db112 1.371339 0.650704 27.585160 2.047785 \n", - "... ... ... ... ... \n", - "96_counts_clusters_c87db112 0.810325 0.677078 9.805510 3.943257 \n", - "97_counts_clusters_c87db112 1.187327 1.034916 13.934763 6.531429 \n", - "98_counts_clusters_c87db112 0.936380 0.965804 15.280870 6.356314 \n", - "99_counts_clusters_c87db112 1.510566 0.621739 9.873467 9.815158 \n", - "100_counts_clusters_c87db112 0.495795 0.495713 10.607854 5.464689 \n", + "channels CD20 CD31 CD45 CD68 \\\n", + "cells \n", + "1_counts_clusters_2d02715e 1.315880 0.589464 30.252512 1.639205 \n", + "2_counts_clusters_2d02715e 8.713191 1.219908 56.096997 2.077967 \n", + "3_counts_clusters_2d02715e 4.585831 1.025564 52.106125 2.153796 \n", + "4_counts_clusters_2d02715e 3.950231 0.583871 39.929262 1.899014 \n", + "5_counts_clusters_2d02715e 8.039006 0.985423 55.497515 2.064406 \n", + "... ... ... ... ... \n", + "96_counts_clusters_2d02715e 2.628480 1.435061 12.535290 6.423287 \n", + "97_counts_clusters_2d02715e 0.850247 0.568664 8.317586 3.651513 \n", + "98_counts_clusters_2d02715e 1.032256 0.860999 11.455320 4.825058 \n", + "99_counts_clusters_2d02715e 1.103696 0.984863 14.039679 5.912146 \n", + "100_counts_clusters_2d02715e 0.480134 0.498194 10.636129 5.904330 \n", "\n", "channels CD163 CK17 Collagen1 Fibronectin \\\n", "cells \n", - "1_counts_clusters_c87db112 2.595093 1.275055 7.540906 7.779709 \n", - "2_counts_clusters_c87db112 6.206642 2.654662 8.120834 9.743484 \n", - "3_counts_clusters_c87db112 9.301675 4.037615 22.116019 14.121541 \n", - "4_counts_clusters_c87db112 3.575007 2.577310 29.798437 17.675432 \n", - "5_counts_clusters_c87db112 2.841191 2.113751 9.091455 5.126966 \n", + "1_counts_clusters_2d02715e 2.432772 2.077082 7.781796 4.139287 \n", + "2_counts_clusters_2d02715e 4.129621 2.686037 5.455420 5.524063 \n", + "3_counts_clusters_2d02715e 4.097220 2.331725 7.267913 6.139904 \n", + "4_counts_clusters_2d02715e 2.709320 1.705489 7.024916 4.346849 \n", + "5_counts_clusters_2d02715e 4.395945 2.033076 4.772678 4.934692 \n", "... ... ... ... ... \n", - "96_counts_clusters_c87db112 9.179419 1.048139 40.200144 11.909424 \n", - "97_counts_clusters_c87db112 14.983489 1.084566 12.627397 9.501719 \n", - "98_counts_clusters_c87db112 12.865684 1.003338 11.538158 7.572785 \n", - "99_counts_clusters_c87db112 48.120955 1.054896 9.604530 7.028433 \n", - "100_counts_clusters_c87db112 14.148630 0.671717 10.156424 7.053110 \n", + "96_counts_clusters_2d02715e 7.808438 1.716372 37.751931 11.812116 \n", + "97_counts_clusters_2d02715e 7.229076 1.053102 55.057834 11.486410 \n", + "98_counts_clusters_2d02715e 9.948482 1.224571 33.234845 12.156787 \n", + "99_counts_clusters_2d02715e 12.283513 1.081740 13.259535 10.251130 \n", + "100_counts_clusters_2d02715e 14.462784 0.657815 9.449697 6.441781 \n", "\n", - "channels ECAD HLADR SMA Vim \\\n", - "cells \n", - "1_counts_clusters_c87db112 1.745743 1.576688 4.947849 89.713973 \n", - "2_counts_clusters_c87db112 4.143529 6.264831 3.418407 50.938679 \n", - "3_counts_clusters_c87db112 9.079312 5.893481 8.240330 34.542586 \n", - "4_counts_clusters_c87db112 2.835710 3.067414 6.869558 9.590902 \n", - "5_counts_clusters_c87db112 1.822619 3.226701 2.975826 8.591069 \n", - "... ... ... ... ... \n", - "96_counts_clusters_c87db112 1.028891 8.213371 3.419144 4.546988 \n", - "97_counts_clusters_c87db112 1.691567 14.328754 5.775819 8.412790 \n", - "98_counts_clusters_c87db112 1.616540 45.161700 4.578395 9.472542 \n", - "99_counts_clusters_c87db112 1.367574 9.942413 3.265405 11.612421 \n", - "100_counts_clusters_c87db112 0.598646 11.385688 3.044625 5.240363 \n", + "channels ECAD HLADR SMA Vim \\\n", + "cells \n", + "1_counts_clusters_2d02715e 1.638660 2.509107 2.552425 7.210590 \n", + "2_counts_clusters_2d02715e 2.271283 3.385231 0.894532 8.693713 \n", + "3_counts_clusters_2d02715e 2.960410 2.698596 1.826165 9.665717 \n", + "4_counts_clusters_2d02715e 2.103179 2.492270 1.044199 5.976883 \n", + "5_counts_clusters_2d02715e 2.381851 4.444559 0.383196 5.731354 \n", + "... ... ... ... ... \n", + "96_counts_clusters_2d02715e 2.634270 31.108982 6.185559 9.853439 \n", + "97_counts_clusters_2d02715e 1.136371 6.642796 3.817631 4.767680 \n", + "98_counts_clusters_2d02715e 1.475615 9.946127 4.933891 6.348947 \n", + "99_counts_clusters_2d02715e 1.735470 12.797073 6.092375 8.267192 \n", + "100_counts_clusters_2d02715e 0.566056 12.013471 2.820398 5.216806 \n", "\n", "channels pixel_meta_cluster pixel_som_cluster count \n", "cells \n", - "1_counts_clusters_c87db112 5 1 9050 \n", - "2_counts_clusters_c87db112 5 2 9495 \n", - "3_counts_clusters_c87db112 5 3 13887 \n", - "4_counts_clusters_c87db112 9 4 10893 \n", - "5_counts_clusters_c87db112 9 5 10411 \n", + "1_counts_clusters_2d02715e 2 1 9930 \n", + "2_counts_clusters_2d02715e 1 2 12134 \n", + "3_counts_clusters_2d02715e 1 3 5392 \n", + "4_counts_clusters_2d02715e 9 4 12617 \n", + "5_counts_clusters_2d02715e 9 5 16815 \n", "... ... ... ... \n", - "96_counts_clusters_c87db112 2 96 13135 \n", - "97_counts_clusters_c87db112 18 97 18881 \n", - "98_counts_clusters_c87db112 2 98 9606 \n", - "99_counts_clusters_c87db112 8 99 10220 \n", - "100_counts_clusters_c87db112 18 100 10450 \n", + "96_counts_clusters_2d02715e 5 96 11251 \n", + "97_counts_clusters_2d02715e 5 97 13194 \n", + "98_counts_clusters_2d02715e 5 98 15672 \n", + "99_counts_clusters_2d02715e 5 99 16393 \n", + "100_counts_clusters_2d02715e 18 100 10009 \n", "\n", "[100 rows x 19 columns]" ] }, - "execution_count": 12, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -874,6 +876,576 @@ ") = _export_to_ark_format_cells(sdata_ark_analysis, table_layer=\"table_cell_clustering_flowsom\", output=None)\n", "df" ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
channelscell_meta_clusterCD3CD4CD8CD14CD20CD31CD45CD68CD163CK17Collagen1FibronectinECADHLADRSMAVimcell_meta_cluster_rename
014.73297712.3349943.82658027.8072602.4614961.32918110.07625233.94405717.9683531.62993416.6186709.7233622.77062712.8757195.48196515.6193961
127.07574716.8512414.78248723.9333354.7683431.41909118.4241678.3910639.5335541.75629515.25607310.1501313.81761533.0355685.48996215.1353212
235.3108706.3266484.5520256.7826021.8897591.0577977.0216823.0857404.6366591.31156010.0391227.4251964.0318963.5932633.9358797.8293403
344.5881287.5046513.67025412.0558524.33834213.4431839.3970564.7277046.8568032.03714921.24071524.9632443.7882415.2085509.80144220.0212424
454.0785945.8587713.8884999.4723742.3720111.7031666.5180793.5631985.2308831.53007538.03022515.4346413.0980163.9489027.75970012.7903855
5618.03324520.7081148.37577710.89417922.9058142.07122636.0520114.2702518.4894502.85975611.2916149.7997474.53202910.4631473.16487812.2158096
6735.24613345.7553265.1436888.57520412.2453681.51720540.6911123.5523987.1673132.5196838.2625097.1138833.9896496.7961811.7066699.4814007
7822.0382326.72638448.54119912.7943022.1481811.41499122.1177694.8390546.9266172.43949517.79940911.2641552.9425485.3735075.77989113.5333108
8919.28792816.04428713.40028712.4061118.9261732.13510231.6265184.3614739.7135864.40711413.29799912.0338646.7299118.2530845.33690313.8988869
91010.38316315.0770014.6776689.39819039.1152241.86913437.1129923.7999537.8424502.65452212.0003788.9962423.81337611.4266392.55783611.44034810
10115.17781411.0393474.47730429.9584953.6753071.87249012.4297166.56310710.1149771.79055426.98842414.9543503.23978110.7332249.08885315.22043811
111222.37626813.12767430.34488312.2202538.0791261.49746931.4507174.1819879.0205242.92101113.82440911.1257253.8972397.4345584.23249312.20819712
121317.78174623.2595895.81740912.7437267.0031162.21412122.6213405.3962879.1708793.24215216.00820712.7432589.1962408.6094935.38562015.30165713
131429.75629917.79995822.6177338.8568199.5032871.86016747.4858673.3546307.4596243.2883769.2633668.7225124.2354076.8117992.42387111.26388114
141527.18599936.3291874.72158610.41264910.8280142.05083332.3717804.2736618.8718162.74522511.2045639.9045906.5026677.4057203.14529912.21304515
15167.0451437.4955636.1817226.4808602.1107531.6274329.4644812.5755025.87242048.4456617.1207636.28948332.7622084.10575432.1871677.51136016
161720.35497830.5201014.89232016.1739788.0759271.60313429.5833977.8280028.1016822.1346609.7811338.4949434.39656323.5514562.98812311.87451217
171810.49460717.1078815.34843617.78009421.2038111.46143827.2410456.12647518.5332192.45238212.95208410.3230794.16844311.1628883.74573313.40258618
18194.7224817.9387673.34224213.2843372.2355623.1048527.6243675.0105246.6270401.99983723.45261116.3326554.1696465.35052916.15260035.12702519
19208.96018218.1664244.33248226.9176215.3896721.52981516.7928068.85235729.4228262.79643215.95284610.7613414.1663569.9773595.01619014.36978520
\n", + "
" + ], + "text/plain": [ + "channels cell_meta_cluster CD3 CD4 CD8 CD14 \\\n", + "0 1 4.732977 12.334994 3.826580 27.807260 \n", + "1 2 7.075747 16.851241 4.782487 23.933335 \n", + "2 3 5.310870 6.326648 4.552025 6.782602 \n", + "3 4 4.588128 7.504651 3.670254 12.055852 \n", + "4 5 4.078594 5.858771 3.888499 9.472374 \n", + "5 6 18.033245 20.708114 8.375777 10.894179 \n", + "6 7 35.246133 45.755326 5.143688 8.575204 \n", + "7 8 22.038232 6.726384 48.541199 12.794302 \n", + "8 9 19.287928 16.044287 13.400287 12.406111 \n", + "9 10 10.383163 15.077001 4.677668 9.398190 \n", + "10 11 5.177814 11.039347 4.477304 29.958495 \n", + "11 12 22.376268 13.127674 30.344883 12.220253 \n", + "12 13 17.781746 23.259589 5.817409 12.743726 \n", + "13 14 29.756299 17.799958 22.617733 8.856819 \n", + "14 15 27.185999 36.329187 4.721586 10.412649 \n", + "15 16 7.045143 7.495563 6.181722 6.480860 \n", + "16 17 20.354978 30.520101 4.892320 16.173978 \n", + "17 18 10.494607 17.107881 5.348436 17.780094 \n", + "18 19 4.722481 7.938767 3.342242 13.284337 \n", + "19 20 8.960182 18.166424 4.332482 26.917621 \n", + "\n", + "channels CD20 CD31 CD45 CD68 CD163 CK17 \\\n", + "0 2.461496 1.329181 10.076252 33.944057 17.968353 1.629934 \n", + "1 4.768343 1.419091 18.424167 8.391063 9.533554 1.756295 \n", + "2 1.889759 1.057797 7.021682 3.085740 4.636659 1.311560 \n", + "3 4.338342 13.443183 9.397056 4.727704 6.856803 2.037149 \n", + "4 2.372011 1.703166 6.518079 3.563198 5.230883 1.530075 \n", + "5 22.905814 2.071226 36.052011 4.270251 8.489450 2.859756 \n", + "6 12.245368 1.517205 40.691112 3.552398 7.167313 2.519683 \n", + "7 2.148181 1.414991 22.117769 4.839054 6.926617 2.439495 \n", + "8 8.926173 2.135102 31.626518 4.361473 9.713586 4.407114 \n", + "9 39.115224 1.869134 37.112992 3.799953 7.842450 2.654522 \n", + "10 3.675307 1.872490 12.429716 6.563107 10.114977 1.790554 \n", + "11 8.079126 1.497469 31.450717 4.181987 9.020524 2.921011 \n", + "12 7.003116 2.214121 22.621340 5.396287 9.170879 3.242152 \n", + "13 9.503287 1.860167 47.485867 3.354630 7.459624 3.288376 \n", + "14 10.828014 2.050833 32.371780 4.273661 8.871816 2.745225 \n", + "15 2.110753 1.627432 9.464481 2.575502 5.872420 48.445661 \n", + "16 8.075927 1.603134 29.583397 7.828002 8.101682 2.134660 \n", + "17 21.203811 1.461438 27.241045 6.126475 18.533219 2.452382 \n", + "18 2.235562 3.104852 7.624367 5.010524 6.627040 1.999837 \n", + "19 5.389672 1.529815 16.792806 8.852357 29.422826 2.796432 \n", + "\n", + "channels Collagen1 Fibronectin ECAD HLADR SMA Vim \\\n", + "0 16.618670 9.723362 2.770627 12.875719 5.481965 15.619396 \n", + "1 15.256073 10.150131 3.817615 33.035568 5.489962 15.135321 \n", + "2 10.039122 7.425196 4.031896 3.593263 3.935879 7.829340 \n", + "3 21.240715 24.963244 3.788241 5.208550 9.801442 20.021242 \n", + "4 38.030225 15.434641 3.098016 3.948902 7.759700 12.790385 \n", + "5 11.291614 9.799747 4.532029 10.463147 3.164878 12.215809 \n", + "6 8.262509 7.113883 3.989649 6.796181 1.706669 9.481400 \n", + "7 17.799409 11.264155 2.942548 5.373507 5.779891 13.533310 \n", + "8 13.297999 12.033864 6.729911 8.253084 5.336903 13.898886 \n", + "9 12.000378 8.996242 3.813376 11.426639 2.557836 11.440348 \n", + "10 26.988424 14.954350 3.239781 10.733224 9.088853 15.220438 \n", + "11 13.824409 11.125725 3.897239 7.434558 4.232493 12.208197 \n", + "12 16.008207 12.743258 9.196240 8.609493 5.385620 15.301657 \n", + "13 9.263366 8.722512 4.235407 6.811799 2.423871 11.263881 \n", + "14 11.204563 9.904590 6.502667 7.405720 3.145299 12.213045 \n", + "15 7.120763 6.289483 32.762208 4.105754 32.187167 7.511360 \n", + "16 9.781133 8.494943 4.396563 23.551456 2.988123 11.874512 \n", + "17 12.952084 10.323079 4.168443 11.162888 3.745733 13.402586 \n", + "18 23.452611 16.332655 4.169646 5.350529 16.152600 35.127025 \n", + "19 15.952846 10.761341 4.166356 9.977359 5.016190 14.369785 \n", + "\n", + "channels cell_meta_cluster_rename \n", + "0 1 \n", + "1 2 \n", + "2 3 \n", + "3 4 \n", + "4 5 \n", + "5 6 \n", + "6 7 \n", + "7 8 \n", + "8 9 \n", + "9 10 \n", + "10 11 \n", + "11 12 \n", + "12 13 \n", + "13 14 \n", + "14 15 \n", + "15 16 \n", + "16 17 \n", + "17 18 \n", + "18 19 \n", + "19 20 " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_cell_meta_cluster_channel_avg" + ] } ], "metadata": { @@ -892,7 +1464,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.10.8" } }, "nbformat": 4, From 6d0dde84e2d9554d71b261a66b25f8a49482fd86 Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Tue, 10 Dec 2024 09:15:46 +0100 Subject: [PATCH 3/6] SC_40 update flowsom clustering notebook --- ...lowSOM_for_pixel_and_cell_clustering.ipynb | 224 +++++++++--------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb index d379539..3c1c1bd 100644 --- a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb +++ b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb @@ -50,13 +50,13 @@ "text": [ "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", - "2024-12-10 08:57:55,787 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:55,865 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", - "2024-12-10 08:57:55,867 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:55,871 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", - "2024-12-10 08:57:55,873 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:55,877 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", - "2024-12-10 08:57:55,895 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" + "2024-12-10 09:11:01,189 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:01,266 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", + "2024-12-10 09:11:01,268 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:01,273 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", + "2024-12-10 09:11:01,275 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:01,280 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", + "2024-12-10 09:11:01,300 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" ] }, { @@ -70,11 +70,11 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 08:57:55,994 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", - "2024-12-10 08:57:55,996 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:56,001 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", - "2024-12-10 08:57:56,003 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:56,008 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", + "2024-12-10 09:11:01,404 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", + "2024-12-10 09:11:01,406 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:01,412 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", + "2024-12-10 09:11:01,413 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:01,419 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning: Transforming to str index.\n", " warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1046: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.\n", @@ -145,10 +145,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 08:57:56,538 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:57,323 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", - "2024-12-10 08:57:57,325 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:57:58,103 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" + "2024-12-10 09:11:01,857 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:02,713 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", + "2024-12-10 09:11:02,715 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:03,545 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" ] }, { @@ -199,17 +199,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-12-10 08:57:58.266\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 08:57:58.267\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 08:58:00.099\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 08:58:00,448 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:58:00,946 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 08:58:00,947 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:58:01,236 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", - "2024-12-10 08:58:01,290 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:58:01,972 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", - "2024-12-10 08:58:01,972 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 08:58:02,604 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" + "\u001b[32m2024-12-10 09:11:03.706\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 09:11:03.707\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 09:11:05.745\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 09:11:06,083 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:06,582 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 09:11:06,583 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:06,880 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", + "2024-12-10 09:11:06,933 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:07,613 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-10 09:11:07,613 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:11:08,238 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" ] }, { @@ -261,7 +261,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -274,8 +274,8 @@ " adata.obsm[_SPATIAL] = coordinates\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "2024-12-10 09:04:14,876 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 09:04:14,893 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-10 09:11:10,356 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 09:11:10,372 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", @@ -310,7 +310,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -331,24 +331,24 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:04:24,536 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", - "2024-12-10 09:04:24,552 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", + "2024-12-10 09:11:10,618 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", + "2024-12-10 09:11:10,634 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "\u001b[32m2024-12-10 09:04:24.598\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 09:04:24.599\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 09:04:24.622\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 09:04:24,755 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", - "2024-12-10 09:04:24,770 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", + "\u001b[32m2024-12-10 09:11:10.681\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 09:11:10.682\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 09:11:10.705\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 09:11:10,839 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", + "2024-12-10 09:11:10,854 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -380,7 +380,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 8, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -403,16 +403,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:04:29,950 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:04:29,955 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:04:29,967 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:11:10,899 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:11:10,904 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:11:10,913 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -444,7 +444,7 @@ " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, - "execution_count": 9, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -464,16 +464,16 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:04:58,581 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:04:58,582 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:04:58,584 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" + "2024-12-10 09:11:10,968 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:11:10,978 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:11:10,981 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" ] }, { @@ -542,7 +542,7 @@ " \n", " \n", " \n", - " 1_counts_clusters_2d02715e\n", + " 1_counts_clusters_55e09093\n", " 37.843970\n", " 2.887842\n", " 97.043740\n", @@ -564,7 +564,7 @@ " 9930\n", " \n", " \n", - " 2_counts_clusters_2d02715e\n", + " 2_counts_clusters_55e09093\n", " 38.690112\n", " 9.945175\n", " 49.737972\n", @@ -586,7 +586,7 @@ " 12134\n", " \n", " \n", - " 3_counts_clusters_2d02715e\n", + " 3_counts_clusters_55e09093\n", " 73.091492\n", " 17.922896\n", " 18.220559\n", @@ -608,7 +608,7 @@ " 5392\n", " \n", " \n", - " 4_counts_clusters_2d02715e\n", + " 4_counts_clusters_55e09093\n", " 76.282287\n", " 61.344410\n", " 2.660174\n", @@ -630,7 +630,7 @@ " 12617\n", " \n", " \n", - " 5_counts_clusters_2d02715e\n", + " 5_counts_clusters_55e09093\n", " 47.305260\n", " 59.382376\n", " 3.534356\n", @@ -674,7 +674,7 @@ " ...\n", " \n", " \n", - " 96_counts_clusters_2d02715e\n", + " 96_counts_clusters_55e09093\n", " 3.381922\n", " 10.202954\n", " 2.722567\n", @@ -696,7 +696,7 @@ " 11251\n", " \n", " \n", - " 97_counts_clusters_2d02715e\n", + " 97_counts_clusters_55e09093\n", " 2.470278\n", " 8.337522\n", " 2.250204\n", @@ -718,7 +718,7 @@ " 13194\n", " \n", " \n", - " 98_counts_clusters_2d02715e\n", + " 98_counts_clusters_55e09093\n", " 3.030046\n", " 12.170709\n", " 2.506028\n", @@ -740,7 +740,7 @@ " 15672\n", " \n", " \n", - " 99_counts_clusters_2d02715e\n", + " 99_counts_clusters_55e09093\n", " 3.106052\n", " 14.744514\n", " 2.634652\n", @@ -762,7 +762,7 @@ " 16393\n", " \n", " \n", - " 100_counts_clusters_2d02715e\n", + " 100_counts_clusters_55e09093\n", " 1.480684\n", " 13.220733\n", " 1.721745\n", @@ -791,78 +791,78 @@ "text/plain": [ "channels CD3 CD4 CD8 CD14 \\\n", "cells \n", - "1_counts_clusters_2d02715e 37.843970 2.887842 97.043740 5.178658 \n", - "2_counts_clusters_2d02715e 38.690112 9.945175 49.737972 5.014744 \n", - "3_counts_clusters_2d02715e 73.091492 17.922896 18.220559 4.631251 \n", - "4_counts_clusters_2d02715e 76.282287 61.344410 2.660174 3.988683 \n", - "5_counts_clusters_2d02715e 47.305260 59.382376 3.534356 5.237534 \n", + "1_counts_clusters_55e09093 37.843970 2.887842 97.043740 5.178658 \n", + "2_counts_clusters_55e09093 38.690112 9.945175 49.737972 5.014744 \n", + "3_counts_clusters_55e09093 73.091492 17.922896 18.220559 4.631251 \n", + "4_counts_clusters_55e09093 76.282287 61.344410 2.660174 3.988683 \n", + "5_counts_clusters_55e09093 47.305260 59.382376 3.534356 5.237534 \n", "... ... ... ... ... \n", - "96_counts_clusters_2d02715e 3.381922 10.202954 2.722567 19.882297 \n", - "97_counts_clusters_2d02715e 2.470278 8.337522 2.250204 45.239891 \n", - "98_counts_clusters_2d02715e 3.030046 12.170709 2.506028 59.447868 \n", - "99_counts_clusters_2d02715e 3.106052 14.744514 2.634652 77.775664 \n", - "100_counts_clusters_2d02715e 1.480684 13.220733 1.721745 106.230223 \n", + "96_counts_clusters_55e09093 3.381922 10.202954 2.722567 19.882297 \n", + "97_counts_clusters_55e09093 2.470278 8.337522 2.250204 45.239891 \n", + "98_counts_clusters_55e09093 3.030046 12.170709 2.506028 59.447868 \n", + "99_counts_clusters_55e09093 3.106052 14.744514 2.634652 77.775664 \n", + "100_counts_clusters_55e09093 1.480684 13.220733 1.721745 106.230223 \n", "\n", "channels CD20 CD31 CD45 CD68 \\\n", "cells \n", - "1_counts_clusters_2d02715e 1.315880 0.589464 30.252512 1.639205 \n", - "2_counts_clusters_2d02715e 8.713191 1.219908 56.096997 2.077967 \n", - "3_counts_clusters_2d02715e 4.585831 1.025564 52.106125 2.153796 \n", - "4_counts_clusters_2d02715e 3.950231 0.583871 39.929262 1.899014 \n", - "5_counts_clusters_2d02715e 8.039006 0.985423 55.497515 2.064406 \n", + "1_counts_clusters_55e09093 1.315880 0.589464 30.252512 1.639205 \n", + "2_counts_clusters_55e09093 8.713191 1.219908 56.096997 2.077967 \n", + "3_counts_clusters_55e09093 4.585831 1.025564 52.106125 2.153796 \n", + "4_counts_clusters_55e09093 3.950231 0.583871 39.929262 1.899014 \n", + "5_counts_clusters_55e09093 8.039006 0.985423 55.497515 2.064406 \n", "... ... ... ... ... \n", - "96_counts_clusters_2d02715e 2.628480 1.435061 12.535290 6.423287 \n", - "97_counts_clusters_2d02715e 0.850247 0.568664 8.317586 3.651513 \n", - "98_counts_clusters_2d02715e 1.032256 0.860999 11.455320 4.825058 \n", - "99_counts_clusters_2d02715e 1.103696 0.984863 14.039679 5.912146 \n", - "100_counts_clusters_2d02715e 0.480134 0.498194 10.636129 5.904330 \n", + "96_counts_clusters_55e09093 2.628480 1.435061 12.535290 6.423287 \n", + "97_counts_clusters_55e09093 0.850247 0.568664 8.317586 3.651513 \n", + "98_counts_clusters_55e09093 1.032256 0.860999 11.455320 4.825058 \n", + "99_counts_clusters_55e09093 1.103696 0.984863 14.039679 5.912146 \n", + "100_counts_clusters_55e09093 0.480134 0.498194 10.636129 5.904330 \n", "\n", "channels CD163 CK17 Collagen1 Fibronectin \\\n", "cells \n", - "1_counts_clusters_2d02715e 2.432772 2.077082 7.781796 4.139287 \n", - "2_counts_clusters_2d02715e 4.129621 2.686037 5.455420 5.524063 \n", - "3_counts_clusters_2d02715e 4.097220 2.331725 7.267913 6.139904 \n", - "4_counts_clusters_2d02715e 2.709320 1.705489 7.024916 4.346849 \n", - "5_counts_clusters_2d02715e 4.395945 2.033076 4.772678 4.934692 \n", + "1_counts_clusters_55e09093 2.432772 2.077082 7.781796 4.139287 \n", + "2_counts_clusters_55e09093 4.129621 2.686037 5.455420 5.524063 \n", + "3_counts_clusters_55e09093 4.097220 2.331725 7.267913 6.139904 \n", + "4_counts_clusters_55e09093 2.709320 1.705489 7.024916 4.346849 \n", + "5_counts_clusters_55e09093 4.395945 2.033076 4.772678 4.934692 \n", "... ... ... ... ... \n", - "96_counts_clusters_2d02715e 7.808438 1.716372 37.751931 11.812116 \n", - "97_counts_clusters_2d02715e 7.229076 1.053102 55.057834 11.486410 \n", - "98_counts_clusters_2d02715e 9.948482 1.224571 33.234845 12.156787 \n", - "99_counts_clusters_2d02715e 12.283513 1.081740 13.259535 10.251130 \n", - "100_counts_clusters_2d02715e 14.462784 0.657815 9.449697 6.441781 \n", + "96_counts_clusters_55e09093 7.808438 1.716372 37.751931 11.812116 \n", + "97_counts_clusters_55e09093 7.229076 1.053102 55.057834 11.486410 \n", + "98_counts_clusters_55e09093 9.948482 1.224571 33.234845 12.156787 \n", + "99_counts_clusters_55e09093 12.283513 1.081740 13.259535 10.251130 \n", + "100_counts_clusters_55e09093 14.462784 0.657815 9.449697 6.441781 \n", "\n", "channels ECAD HLADR SMA Vim \\\n", "cells \n", - "1_counts_clusters_2d02715e 1.638660 2.509107 2.552425 7.210590 \n", - "2_counts_clusters_2d02715e 2.271283 3.385231 0.894532 8.693713 \n", - "3_counts_clusters_2d02715e 2.960410 2.698596 1.826165 9.665717 \n", - "4_counts_clusters_2d02715e 2.103179 2.492270 1.044199 5.976883 \n", - "5_counts_clusters_2d02715e 2.381851 4.444559 0.383196 5.731354 \n", + "1_counts_clusters_55e09093 1.638660 2.509107 2.552425 7.210590 \n", + "2_counts_clusters_55e09093 2.271283 3.385231 0.894532 8.693713 \n", + "3_counts_clusters_55e09093 2.960410 2.698596 1.826165 9.665717 \n", + "4_counts_clusters_55e09093 2.103179 2.492270 1.044199 5.976883 \n", + "5_counts_clusters_55e09093 2.381851 4.444559 0.383196 5.731354 \n", "... ... ... ... ... \n", - "96_counts_clusters_2d02715e 2.634270 31.108982 6.185559 9.853439 \n", - "97_counts_clusters_2d02715e 1.136371 6.642796 3.817631 4.767680 \n", - "98_counts_clusters_2d02715e 1.475615 9.946127 4.933891 6.348947 \n", - "99_counts_clusters_2d02715e 1.735470 12.797073 6.092375 8.267192 \n", - "100_counts_clusters_2d02715e 0.566056 12.013471 2.820398 5.216806 \n", + "96_counts_clusters_55e09093 2.634270 31.108982 6.185559 9.853439 \n", + "97_counts_clusters_55e09093 1.136371 6.642796 3.817631 4.767680 \n", + "98_counts_clusters_55e09093 1.475615 9.946127 4.933891 6.348947 \n", + "99_counts_clusters_55e09093 1.735470 12.797073 6.092375 8.267192 \n", + "100_counts_clusters_55e09093 0.566056 12.013471 2.820398 5.216806 \n", "\n", "channels pixel_meta_cluster pixel_som_cluster count \n", "cells \n", - "1_counts_clusters_2d02715e 2 1 9930 \n", - "2_counts_clusters_2d02715e 1 2 12134 \n", - "3_counts_clusters_2d02715e 1 3 5392 \n", - "4_counts_clusters_2d02715e 9 4 12617 \n", - "5_counts_clusters_2d02715e 9 5 16815 \n", + "1_counts_clusters_55e09093 2 1 9930 \n", + "2_counts_clusters_55e09093 1 2 12134 \n", + "3_counts_clusters_55e09093 1 3 5392 \n", + "4_counts_clusters_55e09093 9 4 12617 \n", + "5_counts_clusters_55e09093 9 5 16815 \n", "... ... ... ... \n", - "96_counts_clusters_2d02715e 5 96 11251 \n", - "97_counts_clusters_2d02715e 5 97 13194 \n", - "98_counts_clusters_2d02715e 5 98 15672 \n", - "99_counts_clusters_2d02715e 5 99 16393 \n", - "100_counts_clusters_2d02715e 18 100 10009 \n", + "96_counts_clusters_55e09093 5 96 11251 \n", + "97_counts_clusters_55e09093 5 97 13194 \n", + "98_counts_clusters_55e09093 5 98 15672 \n", + "99_counts_clusters_55e09093 5 99 16393 \n", + "100_counts_clusters_55e09093 18 100 10009 \n", "\n", "[100 rows x 19 columns]" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -879,7 +879,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -1438,7 +1438,7 @@ "19 20 " ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } From 8a6cba668498065fa8f214d4dc496fadcecd533c Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Tue, 10 Dec 2024 09:53:37 +0100 Subject: [PATCH 4/6] SC_40 example with multiple coordinate systems for flowsom clustering --- ...lowSOM_for_pixel_and_cell_clustering.ipynb | 270 ++++++++++-------- src/harpy/datasets/pixie_example.py | 12 +- .../table/cell_clustering/_preprocess.py | 2 +- 3 files changed, 158 insertions(+), 126 deletions(-) diff --git a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb index 3c1c1bd..1325a24 100644 --- a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb +++ b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb @@ -50,13 +50,13 @@ "text": [ "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", - "2024-12-10 09:11:01,189 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:01,266 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", - "2024-12-10 09:11:01,268 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:01,273 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", - "2024-12-10 09:11:01,275 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:01,280 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", - "2024-12-10 09:11:01,300 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" + "2024-12-10 09:46:33,318 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:33,401 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", + "2024-12-10 09:46:33,403 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:33,408 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", + "2024-12-10 09:46:33,410 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:33,414 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", + "2024-12-10 09:46:33,436 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" ] }, { @@ -70,11 +70,11 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:11:01,404 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", - "2024-12-10 09:11:01,406 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:01,412 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", - "2024-12-10 09:11:01,413 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:01,419 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", + "2024-12-10 09:46:33,539 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", + "2024-12-10 09:46:33,541 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:33,546 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", + "2024-12-10 09:46:33,548 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:33,553 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning: Transforming to str index.\n", " warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1046: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.\n", @@ -96,8 +96,10 @@ "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov1 (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels)" ] }, "execution_count": 2, @@ -145,10 +147,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:11:01,857 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:02,713 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", - "2024-12-10 09:11:02,715 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:03,545 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" + "2024-12-10 09:46:33,984 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:34,839 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", + "2024-12-10 09:46:34,841 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:35,665 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" ] }, { @@ -168,8 +170,10 @@ "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), raw_image_fov0_processed (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels)" ] }, "execution_count": 4, @@ -199,17 +203,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-12-10 09:11:03.706\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 09:11:03.707\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 09:11:05.745\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 09:11:06,083 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:06,582 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 09:11:06,583 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:06,880 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", - "2024-12-10 09:11:06,933 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:07,613 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", - "2024-12-10 09:11:07,613 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:11:08,238 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" + "\u001b[32m2024-12-10 09:46:35.835\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 09:46:35.836\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 09:46:37.821\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 09:46:38,138 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:38,618 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 09:46:38,618 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:38,904 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", + "2024-12-10 09:46:38,956 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:39,650 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-10 09:46:39,650 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-10 09:46:40,267 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" ] }, { @@ -233,8 +237,10 @@ "└── Tables\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), raw_image_fov0_processed (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, "execution_count": 5, @@ -274,8 +280,8 @@ " adata.obsm[_SPATIAL] = coordinates\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "2024-12-10 09:11:10,356 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 09:11:10,372 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-10 09:46:42,395 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-10 09:46:42,412 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", @@ -306,8 +312,10 @@ " ├── 'counts_clusters': AnnData (100, 16)\n", " └── 'table': AnnData (1414, 22)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), raw_image_fov0_processed (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, "execution_count": 6, @@ -321,11 +329,10 @@ " mapping=mapping,\n", " img_layer=[\"raw_image_fov0_processed\", \"raw_image_fov1_processed\"],\n", " labels_layer=[\"raw_image_fov0_flowsom_clusters\", \"raw_image_fov1_flowsom_clusters\"],\n", - " to_coordinate_system=[ \"global\", \"global\" ],\n", + " to_coordinate_system=[ \"fov0\", \"fov1\" ],\n", " output_layer=\"counts_clusters\",\n", " overwrite=True,\n", ")\n", - "# Note: to visualize in napari-spatialdata, this counts_clusters table layer needs to be removed for now. See https://github.com/scverse/napari-spatialdata/issues/244\n", "sdata_ark_analysis" ] }, @@ -338,17 +345,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:11:10,618 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", - "2024-12-10 09:11:10,634 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", + "2024-12-10 09:46:42,627 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", + "2024-12-10 09:46:42,643 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "\u001b[32m2024-12-10 09:11:10.681\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 09:11:10.682\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 09:11:10.705\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 09:11:10,839 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", - "2024-12-10 09:11:10,854 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", + "\u001b[32m2024-12-10 09:46:42.688\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-10 09:46:42.689\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-10 09:46:42.711\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-10 09:46:42,840 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", + "2024-12-10 09:46:42,853 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -376,8 +383,10 @@ " ├── 'table': AnnData (1414, 22)\n", " └── 'table_cell_clustering_flowsom': AnnData (1409, 20)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), raw_image_fov0_processed (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, "execution_count": 7, @@ -410,9 +419,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:11:10,899 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:11:10,904 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:11:10,913 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:46:42,910 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:46:42,931 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-10 09:46:42,933 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -440,8 +449,10 @@ " ├── 'table': AnnData (1414, 22)\n", " └── 'table_cell_clustering_flowsom': AnnData (1409, 20)\n", "with coordinate systems:\n", - " ▸ 'global', with elements:\n", - " raw_image_fov0 (Images), raw_image_fov0_processed (Images), raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov0 (Labels), label_nuclear_fov1 (Labels), label_whole_fov0 (Labels), label_whole_fov1 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" + " ▸ 'fov0', with elements:\n", + " raw_image_fov0 (Images), raw_image_fov0_processed (Images), label_nuclear_fov0 (Labels), label_whole_fov0 (Labels), raw_image_fov0_flowsom_clusters (Labels), raw_image_fov0_flowsom_metaclusters (Labels)\n", + " ▸ 'fov1', with elements:\n", + " raw_image_fov1 (Images), raw_image_fov1_processed (Images), label_nuclear_fov1 (Labels), label_whole_fov1 (Labels), raw_image_fov1_flowsom_clusters (Labels), raw_image_fov1_flowsom_metaclusters (Labels)" ] }, "execution_count": 8, @@ -471,9 +482,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:11:10,968 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:11:10,978 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:11:10,981 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" + "2024-12-10 09:46:42,978 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:46:42,981 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-10 09:46:42,986 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" ] }, { @@ -542,7 +553,7 @@ " \n", " \n", " \n", - " 1_counts_clusters_55e09093\n", + " 1_counts_clusters_fe90513d\n", " 37.843970\n", " 2.887842\n", " 97.043740\n", @@ -564,7 +575,7 @@ " 9930\n", " \n", " \n", - " 2_counts_clusters_55e09093\n", + " 2_counts_clusters_fe90513d\n", " 38.690112\n", " 9.945175\n", " 49.737972\n", @@ -586,7 +597,7 @@ " 12134\n", " \n", " \n", - " 3_counts_clusters_55e09093\n", + " 3_counts_clusters_fe90513d\n", " 73.091492\n", " 17.922896\n", " 18.220559\n", @@ -608,7 +619,7 @@ " 5392\n", " \n", " \n", - " 4_counts_clusters_55e09093\n", + " 4_counts_clusters_fe90513d\n", " 76.282287\n", " 61.344410\n", " 2.660174\n", @@ -630,7 +641,7 @@ " 12617\n", " \n", " \n", - " 5_counts_clusters_55e09093\n", + " 5_counts_clusters_fe90513d\n", " 47.305260\n", " 59.382376\n", " 3.534356\n", @@ -674,7 +685,7 @@ " ...\n", " \n", " \n", - " 96_counts_clusters_55e09093\n", + " 96_counts_clusters_fe90513d\n", " 3.381922\n", " 10.202954\n", " 2.722567\n", @@ -696,7 +707,7 @@ " 11251\n", " \n", " \n", - " 97_counts_clusters_55e09093\n", + " 97_counts_clusters_fe90513d\n", " 2.470278\n", " 8.337522\n", " 2.250204\n", @@ -718,7 +729,7 @@ " 13194\n", " \n", " \n", - " 98_counts_clusters_55e09093\n", + " 98_counts_clusters_fe90513d\n", " 3.030046\n", " 12.170709\n", " 2.506028\n", @@ -740,7 +751,7 @@ " 15672\n", " \n", " \n", - " 99_counts_clusters_55e09093\n", + " 99_counts_clusters_fe90513d\n", " 3.106052\n", " 14.744514\n", " 2.634652\n", @@ -762,7 +773,7 @@ " 16393\n", " \n", " \n", - " 100_counts_clusters_55e09093\n", + " 100_counts_clusters_fe90513d\n", " 1.480684\n", " 13.220733\n", " 1.721745\n", @@ -791,73 +802,73 @@ "text/plain": [ "channels CD3 CD4 CD8 CD14 \\\n", "cells \n", - "1_counts_clusters_55e09093 37.843970 2.887842 97.043740 5.178658 \n", - "2_counts_clusters_55e09093 38.690112 9.945175 49.737972 5.014744 \n", - "3_counts_clusters_55e09093 73.091492 17.922896 18.220559 4.631251 \n", - "4_counts_clusters_55e09093 76.282287 61.344410 2.660174 3.988683 \n", - "5_counts_clusters_55e09093 47.305260 59.382376 3.534356 5.237534 \n", + "1_counts_clusters_fe90513d 37.843970 2.887842 97.043740 5.178658 \n", + "2_counts_clusters_fe90513d 38.690112 9.945175 49.737972 5.014744 \n", + "3_counts_clusters_fe90513d 73.091492 17.922896 18.220559 4.631251 \n", + "4_counts_clusters_fe90513d 76.282287 61.344410 2.660174 3.988683 \n", + "5_counts_clusters_fe90513d 47.305260 59.382376 3.534356 5.237534 \n", "... ... ... ... ... \n", - "96_counts_clusters_55e09093 3.381922 10.202954 2.722567 19.882297 \n", - "97_counts_clusters_55e09093 2.470278 8.337522 2.250204 45.239891 \n", - "98_counts_clusters_55e09093 3.030046 12.170709 2.506028 59.447868 \n", - "99_counts_clusters_55e09093 3.106052 14.744514 2.634652 77.775664 \n", - "100_counts_clusters_55e09093 1.480684 13.220733 1.721745 106.230223 \n", + "96_counts_clusters_fe90513d 3.381922 10.202954 2.722567 19.882297 \n", + "97_counts_clusters_fe90513d 2.470278 8.337522 2.250204 45.239891 \n", + "98_counts_clusters_fe90513d 3.030046 12.170709 2.506028 59.447868 \n", + "99_counts_clusters_fe90513d 3.106052 14.744514 2.634652 77.775664 \n", + "100_counts_clusters_fe90513d 1.480684 13.220733 1.721745 106.230223 \n", "\n", "channels CD20 CD31 CD45 CD68 \\\n", "cells \n", - "1_counts_clusters_55e09093 1.315880 0.589464 30.252512 1.639205 \n", - "2_counts_clusters_55e09093 8.713191 1.219908 56.096997 2.077967 \n", - "3_counts_clusters_55e09093 4.585831 1.025564 52.106125 2.153796 \n", - "4_counts_clusters_55e09093 3.950231 0.583871 39.929262 1.899014 \n", - "5_counts_clusters_55e09093 8.039006 0.985423 55.497515 2.064406 \n", + "1_counts_clusters_fe90513d 1.315880 0.589464 30.252512 1.639205 \n", + "2_counts_clusters_fe90513d 8.713191 1.219908 56.096997 2.077967 \n", + "3_counts_clusters_fe90513d 4.585831 1.025564 52.106125 2.153796 \n", + "4_counts_clusters_fe90513d 3.950231 0.583871 39.929262 1.899014 \n", + "5_counts_clusters_fe90513d 8.039006 0.985423 55.497515 2.064406 \n", "... ... ... ... ... \n", - "96_counts_clusters_55e09093 2.628480 1.435061 12.535290 6.423287 \n", - "97_counts_clusters_55e09093 0.850247 0.568664 8.317586 3.651513 \n", - "98_counts_clusters_55e09093 1.032256 0.860999 11.455320 4.825058 \n", - "99_counts_clusters_55e09093 1.103696 0.984863 14.039679 5.912146 \n", - "100_counts_clusters_55e09093 0.480134 0.498194 10.636129 5.904330 \n", + "96_counts_clusters_fe90513d 2.628480 1.435061 12.535290 6.423287 \n", + "97_counts_clusters_fe90513d 0.850247 0.568664 8.317586 3.651513 \n", + "98_counts_clusters_fe90513d 1.032256 0.860999 11.455320 4.825058 \n", + "99_counts_clusters_fe90513d 1.103696 0.984863 14.039679 5.912146 \n", + "100_counts_clusters_fe90513d 0.480134 0.498194 10.636129 5.904330 \n", "\n", "channels CD163 CK17 Collagen1 Fibronectin \\\n", "cells \n", - "1_counts_clusters_55e09093 2.432772 2.077082 7.781796 4.139287 \n", - "2_counts_clusters_55e09093 4.129621 2.686037 5.455420 5.524063 \n", - "3_counts_clusters_55e09093 4.097220 2.331725 7.267913 6.139904 \n", - "4_counts_clusters_55e09093 2.709320 1.705489 7.024916 4.346849 \n", - "5_counts_clusters_55e09093 4.395945 2.033076 4.772678 4.934692 \n", + "1_counts_clusters_fe90513d 2.432772 2.077082 7.781796 4.139287 \n", + "2_counts_clusters_fe90513d 4.129621 2.686037 5.455420 5.524063 \n", + "3_counts_clusters_fe90513d 4.097220 2.331725 7.267913 6.139904 \n", + "4_counts_clusters_fe90513d 2.709320 1.705489 7.024916 4.346849 \n", + "5_counts_clusters_fe90513d 4.395945 2.033076 4.772678 4.934692 \n", "... ... ... ... ... \n", - "96_counts_clusters_55e09093 7.808438 1.716372 37.751931 11.812116 \n", - "97_counts_clusters_55e09093 7.229076 1.053102 55.057834 11.486410 \n", - "98_counts_clusters_55e09093 9.948482 1.224571 33.234845 12.156787 \n", - "99_counts_clusters_55e09093 12.283513 1.081740 13.259535 10.251130 \n", - "100_counts_clusters_55e09093 14.462784 0.657815 9.449697 6.441781 \n", + "96_counts_clusters_fe90513d 7.808438 1.716372 37.751931 11.812116 \n", + "97_counts_clusters_fe90513d 7.229076 1.053102 55.057834 11.486410 \n", + "98_counts_clusters_fe90513d 9.948482 1.224571 33.234845 12.156787 \n", + "99_counts_clusters_fe90513d 12.283513 1.081740 13.259535 10.251130 \n", + "100_counts_clusters_fe90513d 14.462784 0.657815 9.449697 6.441781 \n", "\n", "channels ECAD HLADR SMA Vim \\\n", "cells \n", - "1_counts_clusters_55e09093 1.638660 2.509107 2.552425 7.210590 \n", - "2_counts_clusters_55e09093 2.271283 3.385231 0.894532 8.693713 \n", - "3_counts_clusters_55e09093 2.960410 2.698596 1.826165 9.665717 \n", - "4_counts_clusters_55e09093 2.103179 2.492270 1.044199 5.976883 \n", - "5_counts_clusters_55e09093 2.381851 4.444559 0.383196 5.731354 \n", + "1_counts_clusters_fe90513d 1.638660 2.509107 2.552425 7.210590 \n", + "2_counts_clusters_fe90513d 2.271283 3.385231 0.894532 8.693713 \n", + "3_counts_clusters_fe90513d 2.960410 2.698596 1.826165 9.665717 \n", + "4_counts_clusters_fe90513d 2.103179 2.492270 1.044199 5.976883 \n", + "5_counts_clusters_fe90513d 2.381851 4.444559 0.383196 5.731354 \n", "... ... ... ... ... \n", - "96_counts_clusters_55e09093 2.634270 31.108982 6.185559 9.853439 \n", - "97_counts_clusters_55e09093 1.136371 6.642796 3.817631 4.767680 \n", - "98_counts_clusters_55e09093 1.475615 9.946127 4.933891 6.348947 \n", - "99_counts_clusters_55e09093 1.735470 12.797073 6.092375 8.267192 \n", - "100_counts_clusters_55e09093 0.566056 12.013471 2.820398 5.216806 \n", + "96_counts_clusters_fe90513d 2.634270 31.108982 6.185559 9.853439 \n", + "97_counts_clusters_fe90513d 1.136371 6.642796 3.817631 4.767680 \n", + "98_counts_clusters_fe90513d 1.475615 9.946127 4.933891 6.348947 \n", + "99_counts_clusters_fe90513d 1.735470 12.797073 6.092375 8.267192 \n", + "100_counts_clusters_fe90513d 0.566056 12.013471 2.820398 5.216806 \n", "\n", "channels pixel_meta_cluster pixel_som_cluster count \n", "cells \n", - "1_counts_clusters_55e09093 2 1 9930 \n", - "2_counts_clusters_55e09093 1 2 12134 \n", - "3_counts_clusters_55e09093 1 3 5392 \n", - "4_counts_clusters_55e09093 9 4 12617 \n", - "5_counts_clusters_55e09093 9 5 16815 \n", + "1_counts_clusters_fe90513d 2 1 9930 \n", + "2_counts_clusters_fe90513d 1 2 12134 \n", + "3_counts_clusters_fe90513d 1 3 5392 \n", + "4_counts_clusters_fe90513d 9 4 12617 \n", + "5_counts_clusters_fe90513d 9 5 16815 \n", "... ... ... ... \n", - "96_counts_clusters_55e09093 5 96 11251 \n", - "97_counts_clusters_55e09093 5 97 13194 \n", - "98_counts_clusters_55e09093 5 98 15672 \n", - "99_counts_clusters_55e09093 5 99 16393 \n", - "100_counts_clusters_55e09093 18 100 10009 \n", + "96_counts_clusters_fe90513d 5 96 11251 \n", + "97_counts_clusters_fe90513d 5 97 13194 \n", + "98_counts_clusters_fe90513d 5 98 15672 \n", + "99_counts_clusters_fe90513d 5 99 16393 \n", + "100_counts_clusters_fe90513d 18 100 10009 \n", "\n", "[100 rows x 19 columns]" ] @@ -1446,6 +1457,33 @@ "source": [ "df_cell_meta_cluster_channel_avg" ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'region': ['label_whole_fov0', 'label_whole_fov1'],\n", + " 'region_key': 'fov_labels',\n", + " 'instance_key': 'cell_ID'}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# \"table_cell_clustering_flowsom\" is annotated by segmentation masks, so they can be visualised using napari-spatialdata\n", + "sdata_ark_analysis[ \"table_cell_clustering_flowsom\" ].uns[ \"spatialdata_attrs\" ]\n", + "\n", + "#from napari_spatialdata import Interactive\n", + "\n", + "#Interactive(sdata_ark_analysis)" + ] } ], "metadata": { diff --git a/src/harpy/datasets/pixie_example.py b/src/harpy/datasets/pixie_example.py index 6e53a76..d90b3ae 100644 --- a/src/harpy/datasets/pixie_example.py +++ b/src/harpy/datasets/pixie_example.py @@ -96,9 +96,7 @@ def pixie_example(fovs: list | None = None, with_pixel_output=True, with_cells_o output_layer=f"raw_image_{fov}", c_coords=channels, overwrite=True, - # transformation={ - # fov: sd.transformations.Identity() - # } + transformations={fov: sd.transformations.Identity()}, ) sdata = harpy.im.add_labels_layer( @@ -106,9 +104,7 @@ def pixie_example(fovs: list | None = None, with_pixel_output=True, with_cells_o arr=imread.imread(os.path.join(path_segment_data, f"{fov}_nuclear.tiff")).squeeze(), output_layer=f"label_nuclear_{fov}", overwrite=True, - # transformation={ - # fov: sd.transformations.Identity() - # } + transformations={fov: sd.transformations.Identity()}, ) sdata = harpy.im.add_labels_layer( @@ -116,9 +112,7 @@ def pixie_example(fovs: list | None = None, with_pixel_output=True, with_cells_o arr=imread.imread(os.path.join(path_segment_data, f"{fov}_whole_cell.tiff")).squeeze(), output_layer=f"label_whole_{fov}", overwrite=True, - # transformation={ - # fov: sd.transformations.Identity() - # } + transformations={fov: sd.transformations.Identity()}, ) if with_cells_output: prefix = "label_whole_" diff --git a/src/harpy/table/cell_clustering/_preprocess.py b/src/harpy/table/cell_clustering/_preprocess.py index bcaeb35..c47880f 100644 --- a/src/harpy/table/cell_clustering/_preprocess.py +++ b/src/harpy/table/cell_clustering/_preprocess.py @@ -86,7 +86,7 @@ def cell_clustering_preprocess( ), f"Provided labels layers '{_labels_layer_cells}' and '{_labels_layer_clusters}' do not have the same shape." assert ( - get_transformation(se_labels) == get_transformation(se_clusters) + get_transformation(se_labels, get_all=True) == get_transformation(se_clusters, get_all=True) ), f"Transformation on provided labels layers '{_labels_layer_cells}' and '{_labels_layer_clusters}' are not equal. This is currently not supported." if i == 0: From e3aa50b0c4b1833474b64d1f0b0c21b956db9229 Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Wed, 11 Dec 2024 11:16:43 +0100 Subject: [PATCH 5/6] SC_40 optimizations in hp.im.flowsom --- src/harpy/image/_rasterize.py | 2 +- .../image/pixel_clustering/_clustering.py | 59 ++++++++++++++++--- src/harpy/image/segmentation/_grid.py | 2 +- src/harpy/utils/utils.py | 6 +- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/harpy/image/_rasterize.py b/src/harpy/image/_rasterize.py index 79b8a2e..d9ef0a8 100644 --- a/src/harpy/image/_rasterize.py +++ b/src/harpy/image/_rasterize.py @@ -28,7 +28,7 @@ def rasterize( output_layer: str, out_shape: tuple[int, int] | None = None, # output shape in y, x. chunks: int | None = None, - client: Client = None, + client: Client | None = None, scale_factors: ScaleFactors_t | None = None, overwrite: bool = False, ) -> SpatialData: diff --git a/src/harpy/image/pixel_clustering/_clustering.py b/src/harpy/image/pixel_clustering/_clustering.py index 3a36c84..f19889b 100644 --- a/src/harpy/image/pixel_clustering/_clustering.py +++ b/src/harpy/image/pixel_clustering/_clustering.py @@ -1,5 +1,6 @@ from __future__ import annotations +import uuid from collections.abc import Iterable import dask.array as da @@ -7,14 +8,17 @@ import pandas as pd from anndata import AnnData from dask.array import Array +from dask.distributed import Client from numpy.typing import NDArray -from spatialdata import SpatialData +from spatialdata import SpatialData, read_zarr +from spatialdata.models import Image3DModel from spatialdata.models.models import ScaleFactors_t from spatialdata.transformations import get_transformation from harpy.image._image import _get_spatial_element, add_labels_layer from harpy.utils._keys import _INSTANCE_KEY, _REGION_KEY, _SPATIAL, ClusteringKey from harpy.utils.pylogger import get_pylogger +from harpy.utils.utils import _get_uint_dtype log = get_pylogger(__name__) @@ -39,6 +43,8 @@ def flowsom( random_state: int = 100, chunks: str | int | tuple[int, ...] | None = None, scale_factors: ScaleFactors_t | None = None, + client: Client | None = None, + persist_intermediate: bool = True, overwrite: bool = False, **kwargs, # keyword arguments passed to _flowsom ) -> tuple[SpatialData, fs.FlowSOM, pd.Series]: @@ -67,9 +73,18 @@ def flowsom( random_state A random state for reproducibility of the clustering and sampling. chunks - Chunk sizes for processing. If provided as a tuple, it should contain chunk sizes for `c`, `(z)`, `y`, `x`. + Chunk sizes used for flowsom inference step on `img_layer`. If provided as a tuple, it should contain chunk sizes for `c`, `(z)`, `y`, `x`. scale_factors Scale factors to apply for multiscale + client + A Dask `Client` instance. If specified, during inference, the trained `fs.FlowSOM` model will be scattered (`client.scatter(...)`). + This reduces the size of the task graph and can improve performance by minimizing data transfer overhead during computation. + If not specified, Dask will use the default scheduler as configured on your system (e.g., single-threaded, multithreaded, or a global client if one is running). + persist_intermediate + If set to `True` will persit intermediate computation in memory. If `img_layer`, or one of the elements in `img_layer` is large, this could lead to increased ram usage. + Set to `False` to write to intermediate zarr store instead, which will reduce ram usage, but will increase computation time slightly. + We advice to set `persist_intermediate` to `True`, as it will only persist an array of dimension `(2,z,y,x)`, of dtype `numpy.uint8`. + Ignored if `sdata` is not backed by a zarr store. overwrite If True, overwrites the `output_layer_cluster` and/or `output_layer_metacluster` if it already exists in `sdata`. **kwargs @@ -132,9 +147,6 @@ def _fix_name(layer: str | Iterable[str]): _array_dim == arr.ndim ), "Image layers specified via parameter `img_layer` should all have same number of dimensions." - if chunks is not None: - arr = arr.rechunk(chunks) - to_squeeze = False if arr.ndim == 3: # add trivial z dimension for 2D case @@ -169,24 +181,50 @@ def _fix_name(layer: str | Iterable[str]): # 3D case, save z,y,x position adata.obsm[_SPATIAL] = arr_sampled[:, -3:] - _, fsom = _flowsom(adata, n_clusters=n_clusters, seed=random_state, **kwargs) + xdim = kwargs.pop("xdim", 10) + ydim = kwargs.pop("ydim", 10) + dtype = _get_uint_dtype(value=xdim * ydim) + _, fsom = _flowsom(adata, n_clusters=n_clusters, seed=random_state, xdim=xdim, ydim=ydim, **kwargs) + + if client is not None: + fsom_future = client.scatter(fsom) + else: + fsom_future = fsom assert len(img_layer) == len(_arr_list) # 2) apply fsom on all data for i, _array in enumerate(_arr_list): + if chunks is not None: + if to_squeeze: + # fix chunks to account for fact that we added trivial z-dimension + if isinstance(chunks, Iterable) and not isinstance(chunks, str): + chunks = (chunks[0], 1, chunks[1], chunks[2]) + _array = _array.rechunk(chunks) output_chunks = ((2,), _array.chunks[1], _array.chunks[2], _array.chunks[3]) # predict flowsom clusters _labels_flowsom = da.map_blocks( _predict_flowsom_clusters_chunk, _array, # can also be chunked in c dimension, drop_axis and new_axis take care of this - dtype=np.uint32, + dtype=dtype, chunks=output_chunks, drop_axis=0, new_axis=0, - fsom=fsom, + fsom=fsom_future, ) + # write to intermediate zarr slot or persist, otherwise dask will run the flowsom inference two times (once for clusters, once for metaclusters), + # once for each time we call add_labels_layer. + if sdata.is_backed() and not persist_intermediate: + se_intermediate = Image3DModel.parse(_labels_flowsom) + _labels_flowsom_name = f"labels_flowsom_{uuid.uuid4()}" + sdata.images[_labels_flowsom_name] = se_intermediate + sdata.write_element(_labels_flowsom_name) + sdata = read_zarr(sdata.path) + _labels_flowsom = _get_spatial_element(sdata, layer=_labels_flowsom_name).data + else: + _labels_flowsom = _labels_flowsom.persist() + _labels_flowsom_clusters, _labels_flowsom_metaclusters = _labels_flowsom # save the predicted clusters and metaclusters as a labels layer @@ -208,6 +246,10 @@ def _fix_name(layer: str | Iterable[str]): overwrite=overwrite, ) + if sdata.is_backed() and not persist_intermediate: + del sdata[_labels_flowsom_name] + sdata.delete_element_from_disk(element_name=_labels_flowsom_name) + # TODO decide on fix in flowsom to let clusters count from 1. # fsom cluster ID's count from 0, while labels layer cluster ID's count from 1. @@ -294,6 +336,7 @@ def _remove_nan_columns(array): final_array.shape[0], size=num_samples, replace=False, + chunks=num_samples, # indices can not be multi-chunk, see https://github.com/dask/dask/blob/a9396a913c33de1d5966df9cc1901fd70107c99b/dask/array/random.py#L896 ) if remove_nan_columns: diff --git a/src/harpy/image/segmentation/_grid.py b/src/harpy/image/segmentation/_grid.py index ff3a187..6ce4403 100644 --- a/src/harpy/image/segmentation/_grid.py +++ b/src/harpy/image/segmentation/_grid.py @@ -22,7 +22,7 @@ def add_grid_labels_layer( grid_type: str = "hexagon", # can be either "hexagon" or "square". offset: tuple[int, int] = (0, 0), # we recommend setting a non-zero offset via a translation. chunks: int | None = None, - client: Client = None, + client: Client | None = None, transformations: MappingToCoordinateSystem_t | None = None, scale_factors: ScaleFactors_t | None = None, overwrite: bool = False, diff --git a/src/harpy/utils/utils.py b/src/harpy/utils/utils.py index b537f6c..928bed1 100644 --- a/src/harpy/utils/utils.py +++ b/src/harpy/utils/utils.py @@ -134,8 +134,10 @@ def _get_uint_dtype(value: int) -> str: max_uint64 = np.iinfo(np.uint64).max max_uint32 = np.iinfo(np.uint32).max max_uint16 = np.iinfo(np.uint16).max - - if max_uint16 >= value: + max_uint8 = np.iinfo(np.uint8).max + if max_uint8 >= value: + dtype = "uint8" + elif max_uint16 >= value: dtype = "uint16" elif max_uint32 >= value: dtype = "uint32" From 1b11128ed1d22eab5e73d3ce256f069a3e8abc47 Mon Sep 17 00:00:00 2001 From: ArneDefauw Date: Wed, 11 Dec 2024 11:17:00 +0100 Subject: [PATCH 6/6] SC_40 update notebook --- ...lowSOM_for_pixel_and_cell_clustering.ipynb | 1391 +++++++++-------- 1 file changed, 711 insertions(+), 680 deletions(-) diff --git a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb index 1325a24..0b8a95a 100644 --- a/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb +++ b/docs/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.ipynb @@ -25,7 +25,7 @@ "%load_ext autoreload\n", "%autoreload 2\n", "\n", - "import harpy\n", + "import harpy as hp\n", "from harpy.datasets import pixie_example\n", "from harpy.table.cell_clustering._utils import _export_to_ark_format as _export_to_ark_format_cells\n", "from harpy.table.pixel_clustering._cluster_intensity import _export_to_ark_format as _export_to_ark_format_pixels\n", @@ -50,13 +50,12 @@ "text": [ "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n", - "2024-12-10 09:46:33,318 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:33,401 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", - "2024-12-10 09:46:33,403 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:33,408 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", - "2024-12-10 09:46:33,410 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:33,414 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n", - "2024-12-10 09:46:33,436 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n" + "2024-12-11 11:14:28,429 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,551 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0'\n", + "2024-12-11 11:14:28,555 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,560 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov0'\n", + "2024-12-11 11:14:28,563 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,567 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov0'\n" ] }, { @@ -70,11 +69,12 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:46:33,539 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", - "2024-12-10 09:46:33,541 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:33,546 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", - "2024-12-10 09:46:33,548 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:33,553 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", + "2024-12-11 11:14:28,623 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,717 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1'\n", + "2024-12-11 11:14:28,721 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,727 - harpy.image._manager - INFO - Writing results to layer 'label_nuclear_fov1'\n", + "2024-12-11 11:14:28,730 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:28,735 - harpy.image._manager - INFO - Writing results to layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning: Transforming to str index.\n", " warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1046: ImplicitModificationWarning: Trying to modify attribute `._uns` of view, initializing view as actual.\n", @@ -147,10 +147,10 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:46:33,984 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:34,839 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", - "2024-12-10 09:46:34,841 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:35,665 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" + "2024-12-11 11:14:29,159 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:29,929 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_processed'\n", + "2024-12-11 11:14:29,931 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:30,716 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_processed'\n" ] }, { @@ -182,7 +182,7 @@ } ], "source": [ - "sdata_ark_analysis = harpy.im.pixel_clustering_preprocess(\n", + "sdata_ark_analysis = hp.im.pixel_clustering_preprocess(\n", " sdata_ark_analysis,\n", " img_layer=[\"raw_image_fov0\", \"raw_image_fov1\"],\n", " output_layer=[\"raw_image_fov0_processed\", \"raw_image_fov1_processed\"],\n", @@ -203,17 +203,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-12-10 09:46:35.835\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 09:46:35.836\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 09:46:37.821\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 09:46:38,138 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:38,618 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 09:46:38,618 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:38,904 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", - "2024-12-10 09:46:38,956 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:39,650 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", - "2024-12-10 09:46:39,650 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", - "2024-12-10 09:46:40,267 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" + "\u001b[32m2024-12-11 11:14:30.894\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-11 11:14:30.895\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-11 11:14:32.906\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-11 11:14:33,626 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:33,629 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-11 11:14:33,630 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:33,633 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov0_flowsom_metaclusters'\n", + "2024-12-11 11:14:33,951 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:33,957 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-11 11:14:33,958 - harpy.image._manager - WARNING - No dims parameter specified. Assuming order of dimension of provided array is ((c), (z), y, x)\n", + "2024-12-11 11:14:33,961 - harpy.image._manager - INFO - Writing results to layer 'raw_image_fov1_flowsom_metaclusters'\n" ] }, { @@ -249,17 +249,44 @@ } ], "source": [ - "sdata_ark_analysis, fsom, mapping = harpy.im.flowsom(\n", + "import flowsom as fs\n", + "from dask.distributed import Client, LocalCluster\n", + "\n", + "work_with_client = False\n", + "\n", + "if work_with_client:\n", + " # client example\n", + " cluster = LocalCluster(\n", + " n_workers=1,\n", + " threads_per_worker=10,\n", + " )\n", + "\n", + " client = Client(cluster)\n", + "else:\n", + " client = None\n", + "\n", + "batch_model=fs.models.BatchFlowSOMEstimator\n", + "\n", + "sdata_ark_analysis, fsom, mapping = hp.im.flowsom(\n", " sdata_ark_analysis,\n", - " img_layer=[\"raw_image_fov0_processed\", \"raw_image_fov1_processed\"],\n", + " img_layer=[ \"raw_image_fov0_processed\", \"raw_image_fov1_processed\" ],\n", " output_layer_clusters=[\n", " \"raw_image_fov0_flowsom_clusters\",\n", " \"raw_image_fov1_flowsom_clusters\",\n", " ], # we need output_cluster_layer and output_meta_cluster_layer --> these will both be labels layers\n", - " output_layer_metaclusters=[\"raw_image_fov0_flowsom_metaclusters\", \"raw_image_fov1_flowsom_metaclusters\"],\n", + " output_layer_metaclusters=[\n", + " \"raw_image_fov0_flowsom_metaclusters\",\n", + " \"raw_image_fov1_flowsom_metaclusters\",\n", + " ],\n", " n_clusters=20,\n", " random_state=111,\n", " chunks=512,\n", + " client = client,\n", + " model = batch_model,\n", + " num_batches = 10,\n", + " xdim=10,\n", + " ydim=10,\n", + " persist_intermediate=True,\n", " overwrite=True,\n", ")\n", "sdata_ark_analysis" @@ -280,8 +307,8 @@ " adata.obsm[_SPATIAL] = coordinates\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "2024-12-10 09:46:42,395 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", - "2024-12-10 09:46:42,412 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", + "2024-12-11 11:14:35,924 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov0_flowsom_clusters'\n", + "2024-12-11 11:14:35,941 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'raw_image_fov1_flowsom_clusters'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `counts_clusters` already exists. Overwriting it in-memory.\n", @@ -324,7 +351,7 @@ } ], "source": [ - "sdata_ark_analysis = harpy.tb.cluster_intensity(\n", + "sdata_ark_analysis = hp.tb.cluster_intensity(\n", " sdata_ark_analysis,\n", " mapping=mapping,\n", " img_layer=[\"raw_image_fov0_processed\", \"raw_image_fov1_processed\"],\n", @@ -345,17 +372,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:46:42,627 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", - "2024-12-10 09:46:42,643 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", + "2024-12-11 11:14:36,153 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov0'\n", + "2024-12-11 11:14:36,170 - harpy.table._preprocess - INFO - Calculating cell size from provided labels_layer 'label_whole_fov1'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/models/models.py:1048: UserWarning: Converting `region_key: fov_labels` to categorical dtype.\n", " return convert_region_column_to_categorical(adata)\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n", - "\u001b[32m2024-12-10 09:46:42.688\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", - "\u001b[32m2024-12-10 09:46:42.689\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", - "\u001b[32m2024-12-10 09:46:42.711\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", - "2024-12-10 09:46:42,840 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", - "2024-12-10 09:46:42,853 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", + "\u001b[32m2024-12-11 11:14:36.219\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m84\u001b[0m - \u001b[34m\u001b[1mReading input.\u001b[0m\n", + "\u001b[32m2024-12-11 11:14:36.220\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m86\u001b[0m - \u001b[34m\u001b[1mFitting model: clustering and metaclustering.\u001b[0m\n", + "\u001b[32m2024-12-11 11:14:36.227\u001b[0m | \u001b[34m\u001b[1mDEBUG \u001b[0m | \u001b[36mflowsom.main\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m88\u001b[0m - \u001b[34m\u001b[1mUpdating derived values.\u001b[0m\n", + "2024-12-11 11:14:36,347 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['clustering']'\n", + "2024-12-11 11:14:36,362 - harpy.table.cell_clustering._clustering - INFO - Adding mean cluster intensity to '.uns['metaclustering']'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -395,7 +422,9 @@ } ], "source": [ - "sdata_ark_analysis, fsom = harpy.tb.flowsom(\n", + "batch_model=fs.models.BatchFlowSOMEstimator\n", + "\n", + "sdata_ark_analysis, fsom = hp.tb.flowsom(\n", " sdata_ark_analysis,\n", " labels_layer_cells=[\"label_whole_fov0\", \"label_whole_fov1\"],\n", " labels_layer_clusters=[\n", @@ -404,8 +433,10 @@ " ], # here you could also choose \"ark_pixel_som_cluster\"\n", " output_layer=\"table_cell_clustering_flowsom\",\n", " chunks=512,\n", - " overwrite=True,\n", + " model = batch_model,\n", + " num_batches = 10,\n", " random_state=100,\n", + " overwrite=True,\n", ")\n", "sdata_ark_analysis" ] @@ -419,9 +450,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:46:42,910 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:46:42,931 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", - "2024-12-10 09:46:42,933 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-11 11:14:36,436 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(clustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'clustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-11 11:14:36,437 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding mean over obtained cell clusters '(metaclustering)' of the average marker expression for each cell weighted by pixel cluster count to '.uns[ 'metaclustering_channels' ]' of table layer 'table_cell_clustering_flowsom'\n", + "2024-12-11 11:14:36,438 - harpy.table.cell_clustering._weighted_channel_expression - INFO - Adding average marker expression for each cell weighted by pixel cluster count to '.obs' of table layer 'table_cell_clustering_flowsom'\n", "/Users/arnedf/miniconda3/envs/harpy/lib/python3.10/site-packages/spatialdata/_core/_elements.py:116: UserWarning: Key `table_cell_clustering_flowsom` already exists. Overwriting it in-memory.\n", " self._check_key(key, self.keys(), self._shared_keys)\n" ] @@ -462,7 +493,7 @@ ], "source": [ "# weighted channel average for visualization -> calculate this on the flowsom clustered matrix\n", - "sdata_ark_analysis = harpy.tb.weighted_channel_expression(\n", + "sdata_ark_analysis = hp.tb.weighted_channel_expression(\n", " sdata_ark_analysis,\n", " table_layer_cell_clustering=\"table_cell_clustering_flowsom\",\n", " table_layer_pixel_cluster_intensity=\"counts_clusters\",\n", @@ -482,9 +513,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-12-10 09:46:42,978 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:46:42,981 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", - "2024-12-10 09:46:42,986 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" + "2024-12-11 11:14:36,543 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-11 11:14:36,547 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n", + "2024-12-11 11:14:36,550 - harpy.table.cell_clustering._utils - WARNING - Increasing cell cluster IDs (SOM cluster and meta cluster IDs) with +1 for visualization. The underlying dataframe in the SpatialData object remains unchanges.\n" ] }, { @@ -553,114 +584,114 @@ " \n", " \n", " \n", - " 1_counts_clusters_fe90513d\n", - " 37.843970\n", - " 2.887842\n", - " 97.043740\n", - " 5.178658\n", - " 1.315880\n", - " 0.589464\n", - " 30.252512\n", - " 1.639205\n", - " 2.432772\n", - " 2.077082\n", - " 7.781796\n", - " 4.139287\n", - " 1.638660\n", - " 2.509107\n", - " 2.552425\n", - " 7.210590\n", - " 2\n", + " 1_counts_clusters_a34405d3\n", + " 79.662205\n", + " 55.991234\n", + " 3.339938\n", + " 4.108338\n", + " 3.976343\n", + " 0.578644\n", + " 40.246395\n", + " 1.907112\n", + " 2.754490\n", + " 1.733413\n", + " 7.401993\n", + " 4.566187\n", + " 2.153363\n", + " 2.462132\n", + " 1.229484\n", + " 5.993419\n", + " 5\n", " 1\n", - " 9930\n", + " 11752\n", " \n", " \n", - " 2_counts_clusters_fe90513d\n", - " 38.690112\n", - " 9.945175\n", - " 49.737972\n", - " 5.014744\n", - " 8.713191\n", - " 1.219908\n", - " 56.096997\n", - " 2.077967\n", - " 4.129621\n", - " 2.686037\n", - " 5.455420\n", - " 5.524063\n", - " 2.271283\n", - " 3.385231\n", - " 0.894532\n", - " 8.693713\n", - " 1\n", + " 2_counts_clusters_a34405d3\n", + " 44.357776\n", + " 78.521997\n", + " 1.993199\n", + " 6.019438\n", + " 2.279956\n", + " 0.575271\n", + " 29.573188\n", + " 2.653170\n", + " 4.149742\n", + " 1.820865\n", + " 9.875389\n", + " 6.779230\n", + " 2.466204\n", + " 3.465180\n", + " 1.839119\n", + " 9.828461\n", + " 5\n", " 2\n", - " 12134\n", + " 9440\n", " \n", " \n", - " 3_counts_clusters_fe90513d\n", - " 73.091492\n", - " 17.922896\n", - " 18.220559\n", - " 4.631251\n", - " 4.585831\n", - " 1.025564\n", - " 52.106125\n", - " 2.153796\n", - " 4.097220\n", - " 2.331725\n", - " 7.267913\n", - " 6.139904\n", - " 2.960410\n", - " 2.698596\n", - " 1.826165\n", - " 9.665717\n", - " 1\n", + " 3_counts_clusters_a34405d3\n", + " 60.862157\n", + " 17.323038\n", + " 7.604455\n", + " 6.990412\n", + " 2.871016\n", + " 1.422096\n", + " 21.476851\n", + " 3.547263\n", + " 6.289704\n", + " 3.325128\n", + " 19.664543\n", + " 12.088449\n", + " 7.148716\n", + " 3.925060\n", + " 5.011668\n", + " 12.711450\n", + " 4\n", " 3\n", - " 5392\n", + " 7020\n", " \n", " \n", - " 4_counts_clusters_fe90513d\n", - " 76.282287\n", - " 61.344410\n", - " 2.660174\n", - " 3.988683\n", - " 3.950231\n", - " 0.583871\n", - " 39.929262\n", - " 1.899014\n", - " 2.709320\n", - " 1.705489\n", - " 7.024916\n", - " 4.346849\n", - " 2.103179\n", - " 2.492270\n", - " 1.044199\n", - " 5.976883\n", - " 9\n", + " 4_counts_clusters_a34405d3\n", + " 13.080275\n", + " 11.272689\n", + " 5.681579\n", + " 7.350961\n", + " 7.338359\n", + " 2.766095\n", + " 79.544518\n", + " 3.125768\n", + " 6.229959\n", + " 3.226597\n", + " 10.637938\n", + " 11.225132\n", + " 3.957128\n", + " 6.422467\n", + " 2.363766\n", + " 12.759784\n", + " 17\n", " 4\n", - " 12617\n", + " 7375\n", " \n", " \n", - " 5_counts_clusters_fe90513d\n", - " 47.305260\n", - " 59.382376\n", - " 3.534356\n", - " 5.237534\n", - " 8.039006\n", - " 0.985423\n", - " 55.497515\n", - " 2.064406\n", - " 4.395945\n", - " 2.033076\n", - " 4.772678\n", - " 4.934692\n", - " 2.381851\n", - " 4.444559\n", - " 0.383196\n", - " 5.731354\n", - " 9\n", + " 5_counts_clusters_a34405d3\n", + " 49.938381\n", + " 10.921948\n", + " 49.406746\n", + " 4.959634\n", + " 5.208744\n", + " 1.200178\n", + " 53.361240\n", + " 1.872839\n", + " 3.809860\n", + " 2.536913\n", + " 5.482853\n", + " 5.099018\n", + " 2.056258\n", + " 2.575106\n", + " 1.056300\n", + " 8.767088\n", + " 2\n", " 5\n", - " 16815\n", + " 11025\n", " \n", " \n", " ...\n", @@ -685,114 +716,114 @@ " ...\n", " \n", " \n", - " 96_counts_clusters_fe90513d\n", - " 3.381922\n", - " 10.202954\n", - " 2.722567\n", - " 19.882297\n", - " 2.628480\n", - " 1.435061\n", - " 12.535290\n", - " 6.423287\n", - " 7.808438\n", - " 1.716372\n", - " 37.751931\n", - " 11.812116\n", - " 2.634270\n", - " 31.108982\n", - " 6.185559\n", - " 9.853439\n", - " 5\n", + " 96_counts_clusters_a34405d3\n", + " 3.981039\n", + " 13.323010\n", + " 3.211220\n", + " 41.065997\n", + " 1.524707\n", + " 1.301879\n", + " 12.672745\n", + " 6.005695\n", + " 9.931868\n", + " 1.654690\n", + " 34.965053\n", + " 12.188016\n", + " 2.678179\n", + " 11.858054\n", + " 6.403222\n", + " 9.091599\n", + " 9\n", " 96\n", - " 11251\n", + " 15057\n", " \n", " \n", - " 97_counts_clusters_fe90513d\n", - " 2.470278\n", - " 8.337522\n", - " 2.250204\n", - " 45.239891\n", - " 0.850247\n", - " 0.568664\n", - " 8.317586\n", - " 3.651513\n", - " 7.229076\n", - " 1.053102\n", - " 55.057834\n", - " 11.486410\n", - " 1.136371\n", - " 6.642796\n", - " 3.817631\n", - " 4.767680\n", - " 5\n", + " 97_counts_clusters_a34405d3\n", + " 2.245529\n", + " 9.532662\n", + " 2.118796\n", + " 62.286725\n", + " 0.782066\n", + " 0.652548\n", + " 9.386354\n", + " 3.824479\n", + " 8.670170\n", + " 1.040886\n", + " 41.990669\n", + " 11.365051\n", + " 1.014963\n", + " 7.734525\n", + " 3.382813\n", + " 4.569495\n", + " 9\n", " 97\n", - " 13194\n", + " 11901\n", " \n", " \n", - " 98_counts_clusters_fe90513d\n", - " 3.030046\n", - " 12.170709\n", - " 2.506028\n", - " 59.447868\n", - " 1.032256\n", - " 0.860999\n", - " 11.455320\n", - " 4.825058\n", - " 9.948482\n", - " 1.224571\n", - " 33.234845\n", - " 12.156787\n", - " 1.475615\n", - " 9.946127\n", - " 4.933891\n", - " 6.348947\n", - " 5\n", + " 98_counts_clusters_a34405d3\n", + " 2.191547\n", + " 5.792474\n", + " 1.799250\n", + " 20.217224\n", + " 0.784272\n", + " 0.465956\n", + " 4.838669\n", + " 3.831804\n", + " 6.003469\n", + " 1.157570\n", + " 79.623646\n", + " 9.886305\n", + " 1.222871\n", + " 4.735837\n", + " 3.083184\n", + " 4.082930\n", + " 11\n", " 98\n", - " 15672\n", + " 15650\n", " \n", " \n", - " 99_counts_clusters_fe90513d\n", - " 3.106052\n", - " 14.744514\n", - " 2.634652\n", - " 77.775664\n", - " 1.103696\n", - " 0.984863\n", - " 14.039679\n", - " 5.912146\n", - " 12.283513\n", - " 1.081740\n", - " 13.259535\n", - " 10.251130\n", - " 1.735470\n", - " 12.797073\n", - " 6.092375\n", - " 8.267192\n", - " 5\n", + " 99_counts_clusters_a34405d3\n", + " 2.008014\n", + " 2.885256\n", + " 2.435322\n", + " 4.162790\n", + " 0.742080\n", + " 0.314810\n", + " 2.069228\n", + " 1.886825\n", + " 2.113793\n", + " 1.124537\n", + " 101.731324\n", + " 8.516621\n", + " 1.073964\n", + " 1.264790\n", + " 2.645304\n", + " 2.994190\n", + " 11\n", " 99\n", - " 16393\n", + " 25505\n", " \n", " \n", - " 100_counts_clusters_fe90513d\n", - " 1.480684\n", - " 13.220733\n", - " 1.721745\n", - " 106.230223\n", - " 0.480134\n", - " 0.498194\n", - " 10.636129\n", - " 5.904330\n", - " 14.462784\n", - " 0.657815\n", - " 9.449697\n", - " 6.441781\n", - " 0.566056\n", - " 12.013471\n", - " 2.820398\n", - " 5.216806\n", - " 18\n", + " 100_counts_clusters_a34405d3\n", + " 0.770209\n", + " 1.002478\n", + " 1.119347\n", + " 1.118850\n", + " 0.302310\n", + " 0.087209\n", + " 0.579103\n", + " 0.772100\n", + " 0.737610\n", + " 0.875762\n", + " 118.201814\n", + " 3.522398\n", + " 0.357518\n", + " 0.378539\n", + " 0.837177\n", + " 1.117873\n", + " 11\n", " 100\n", - " 10009\n", + " 21010\n", " \n", " \n", "\n", @@ -800,75 +831,75 @@ "" ], "text/plain": [ - "channels CD3 CD4 CD8 CD14 \\\n", - "cells \n", - "1_counts_clusters_fe90513d 37.843970 2.887842 97.043740 5.178658 \n", - "2_counts_clusters_fe90513d 38.690112 9.945175 49.737972 5.014744 \n", - "3_counts_clusters_fe90513d 73.091492 17.922896 18.220559 4.631251 \n", - "4_counts_clusters_fe90513d 76.282287 61.344410 2.660174 3.988683 \n", - "5_counts_clusters_fe90513d 47.305260 59.382376 3.534356 5.237534 \n", - "... ... ... ... ... \n", - "96_counts_clusters_fe90513d 3.381922 10.202954 2.722567 19.882297 \n", - "97_counts_clusters_fe90513d 2.470278 8.337522 2.250204 45.239891 \n", - "98_counts_clusters_fe90513d 3.030046 12.170709 2.506028 59.447868 \n", - "99_counts_clusters_fe90513d 3.106052 14.744514 2.634652 77.775664 \n", - "100_counts_clusters_fe90513d 1.480684 13.220733 1.721745 106.230223 \n", + "channels CD3 CD4 CD8 CD14 \\\n", + "cells \n", + "1_counts_clusters_a34405d3 79.662205 55.991234 3.339938 4.108338 \n", + "2_counts_clusters_a34405d3 44.357776 78.521997 1.993199 6.019438 \n", + "3_counts_clusters_a34405d3 60.862157 17.323038 7.604455 6.990412 \n", + "4_counts_clusters_a34405d3 13.080275 11.272689 5.681579 7.350961 \n", + "5_counts_clusters_a34405d3 49.938381 10.921948 49.406746 4.959634 \n", + "... ... ... ... ... \n", + "96_counts_clusters_a34405d3 3.981039 13.323010 3.211220 41.065997 \n", + "97_counts_clusters_a34405d3 2.245529 9.532662 2.118796 62.286725 \n", + "98_counts_clusters_a34405d3 2.191547 5.792474 1.799250 20.217224 \n", + "99_counts_clusters_a34405d3 2.008014 2.885256 2.435322 4.162790 \n", + "100_counts_clusters_a34405d3 0.770209 1.002478 1.119347 1.118850 \n", "\n", "channels CD20 CD31 CD45 CD68 \\\n", "cells \n", - "1_counts_clusters_fe90513d 1.315880 0.589464 30.252512 1.639205 \n", - "2_counts_clusters_fe90513d 8.713191 1.219908 56.096997 2.077967 \n", - "3_counts_clusters_fe90513d 4.585831 1.025564 52.106125 2.153796 \n", - "4_counts_clusters_fe90513d 3.950231 0.583871 39.929262 1.899014 \n", - "5_counts_clusters_fe90513d 8.039006 0.985423 55.497515 2.064406 \n", + "1_counts_clusters_a34405d3 3.976343 0.578644 40.246395 1.907112 \n", + "2_counts_clusters_a34405d3 2.279956 0.575271 29.573188 2.653170 \n", + "3_counts_clusters_a34405d3 2.871016 1.422096 21.476851 3.547263 \n", + "4_counts_clusters_a34405d3 7.338359 2.766095 79.544518 3.125768 \n", + "5_counts_clusters_a34405d3 5.208744 1.200178 53.361240 1.872839 \n", "... ... ... ... ... \n", - "96_counts_clusters_fe90513d 2.628480 1.435061 12.535290 6.423287 \n", - "97_counts_clusters_fe90513d 0.850247 0.568664 8.317586 3.651513 \n", - "98_counts_clusters_fe90513d 1.032256 0.860999 11.455320 4.825058 \n", - "99_counts_clusters_fe90513d 1.103696 0.984863 14.039679 5.912146 \n", - "100_counts_clusters_fe90513d 0.480134 0.498194 10.636129 5.904330 \n", + "96_counts_clusters_a34405d3 1.524707 1.301879 12.672745 6.005695 \n", + "97_counts_clusters_a34405d3 0.782066 0.652548 9.386354 3.824479 \n", + "98_counts_clusters_a34405d3 0.784272 0.465956 4.838669 3.831804 \n", + "99_counts_clusters_a34405d3 0.742080 0.314810 2.069228 1.886825 \n", + "100_counts_clusters_a34405d3 0.302310 0.087209 0.579103 0.772100 \n", "\n", - "channels CD163 CK17 Collagen1 Fibronectin \\\n", + "channels CD163 CK17 Collagen1 Fibronectin \\\n", "cells \n", - "1_counts_clusters_fe90513d 2.432772 2.077082 7.781796 4.139287 \n", - "2_counts_clusters_fe90513d 4.129621 2.686037 5.455420 5.524063 \n", - "3_counts_clusters_fe90513d 4.097220 2.331725 7.267913 6.139904 \n", - "4_counts_clusters_fe90513d 2.709320 1.705489 7.024916 4.346849 \n", - "5_counts_clusters_fe90513d 4.395945 2.033076 4.772678 4.934692 \n", - "... ... ... ... ... \n", - "96_counts_clusters_fe90513d 7.808438 1.716372 37.751931 11.812116 \n", - "97_counts_clusters_fe90513d 7.229076 1.053102 55.057834 11.486410 \n", - "98_counts_clusters_fe90513d 9.948482 1.224571 33.234845 12.156787 \n", - "99_counts_clusters_fe90513d 12.283513 1.081740 13.259535 10.251130 \n", - "100_counts_clusters_fe90513d 14.462784 0.657815 9.449697 6.441781 \n", + "1_counts_clusters_a34405d3 2.754490 1.733413 7.401993 4.566187 \n", + "2_counts_clusters_a34405d3 4.149742 1.820865 9.875389 6.779230 \n", + "3_counts_clusters_a34405d3 6.289704 3.325128 19.664543 12.088449 \n", + "4_counts_clusters_a34405d3 6.229959 3.226597 10.637938 11.225132 \n", + "5_counts_clusters_a34405d3 3.809860 2.536913 5.482853 5.099018 \n", + "... ... ... ... ... \n", + "96_counts_clusters_a34405d3 9.931868 1.654690 34.965053 12.188016 \n", + "97_counts_clusters_a34405d3 8.670170 1.040886 41.990669 11.365051 \n", + "98_counts_clusters_a34405d3 6.003469 1.157570 79.623646 9.886305 \n", + "99_counts_clusters_a34405d3 2.113793 1.124537 101.731324 8.516621 \n", + "100_counts_clusters_a34405d3 0.737610 0.875762 118.201814 3.522398 \n", "\n", - "channels ECAD HLADR SMA Vim \\\n", - "cells \n", - "1_counts_clusters_fe90513d 1.638660 2.509107 2.552425 7.210590 \n", - "2_counts_clusters_fe90513d 2.271283 3.385231 0.894532 8.693713 \n", - "3_counts_clusters_fe90513d 2.960410 2.698596 1.826165 9.665717 \n", - "4_counts_clusters_fe90513d 2.103179 2.492270 1.044199 5.976883 \n", - "5_counts_clusters_fe90513d 2.381851 4.444559 0.383196 5.731354 \n", - "... ... ... ... ... \n", - "96_counts_clusters_fe90513d 2.634270 31.108982 6.185559 9.853439 \n", - "97_counts_clusters_fe90513d 1.136371 6.642796 3.817631 4.767680 \n", - "98_counts_clusters_fe90513d 1.475615 9.946127 4.933891 6.348947 \n", - "99_counts_clusters_fe90513d 1.735470 12.797073 6.092375 8.267192 \n", - "100_counts_clusters_fe90513d 0.566056 12.013471 2.820398 5.216806 \n", + "channels ECAD HLADR SMA Vim \\\n", + "cells \n", + "1_counts_clusters_a34405d3 2.153363 2.462132 1.229484 5.993419 \n", + "2_counts_clusters_a34405d3 2.466204 3.465180 1.839119 9.828461 \n", + "3_counts_clusters_a34405d3 7.148716 3.925060 5.011668 12.711450 \n", + "4_counts_clusters_a34405d3 3.957128 6.422467 2.363766 12.759784 \n", + "5_counts_clusters_a34405d3 2.056258 2.575106 1.056300 8.767088 \n", + "... ... ... ... ... \n", + "96_counts_clusters_a34405d3 2.678179 11.858054 6.403222 9.091599 \n", + "97_counts_clusters_a34405d3 1.014963 7.734525 3.382813 4.569495 \n", + "98_counts_clusters_a34405d3 1.222871 4.735837 3.083184 4.082930 \n", + "99_counts_clusters_a34405d3 1.073964 1.264790 2.645304 2.994190 \n", + "100_counts_clusters_a34405d3 0.357518 0.378539 0.837177 1.117873 \n", "\n", "channels pixel_meta_cluster pixel_som_cluster count \n", "cells \n", - "1_counts_clusters_fe90513d 2 1 9930 \n", - "2_counts_clusters_fe90513d 1 2 12134 \n", - "3_counts_clusters_fe90513d 1 3 5392 \n", - "4_counts_clusters_fe90513d 9 4 12617 \n", - "5_counts_clusters_fe90513d 9 5 16815 \n", + "1_counts_clusters_a34405d3 5 1 11752 \n", + "2_counts_clusters_a34405d3 5 2 9440 \n", + "3_counts_clusters_a34405d3 4 3 7020 \n", + "4_counts_clusters_a34405d3 17 4 7375 \n", + "5_counts_clusters_a34405d3 2 5 11025 \n", "... ... ... ... \n", - "96_counts_clusters_fe90513d 5 96 11251 \n", - "97_counts_clusters_fe90513d 5 97 13194 \n", - "98_counts_clusters_fe90513d 5 98 15672 \n", - "99_counts_clusters_fe90513d 5 99 16393 \n", - "100_counts_clusters_fe90513d 18 100 10009 \n", + "96_counts_clusters_a34405d3 9 96 15057 \n", + "97_counts_clusters_a34405d3 9 97 11901 \n", + "98_counts_clusters_a34405d3 11 98 15650 \n", + "99_counts_clusters_a34405d3 11 99 25505 \n", + "100_counts_clusters_a34405d3 11 100 21010 \n", "\n", "[100 rows x 19 columns]" ] @@ -938,421 +969,421 @@ " \n", " 0\n", " 1\n", - " 4.732977\n", - " 12.334994\n", - " 3.826580\n", - " 27.807260\n", - " 2.461496\n", - " 1.329181\n", - " 10.076252\n", - " 33.944057\n", - " 17.968353\n", - " 1.629934\n", - " 16.618670\n", - " 9.723362\n", - " 2.770627\n", - " 12.875719\n", - " 5.481965\n", - " 15.619396\n", + " 9.920224\n", + " 10.636219\n", + " 9.059409\n", + " 11.995957\n", + " 6.404475\n", + " 7.600641\n", + " 19.981869\n", + " 5.353948\n", + " 7.567123\n", + " 5.640777\n", + " 17.392973\n", + " 13.367731\n", + " 5.794182\n", + " 6.907827\n", + " 9.516907\n", + " 19.260004\n", " 1\n", " \n", " \n", " 1\n", " 2\n", - " 7.075747\n", - " 16.851241\n", - " 4.782487\n", - " 23.933335\n", - " 4.768343\n", - " 1.419091\n", - " 18.424167\n", - " 8.391063\n", - " 9.533554\n", - " 1.756295\n", - " 15.256073\n", - " 10.150131\n", - " 3.817615\n", - " 33.035568\n", - " 5.489962\n", - " 15.135321\n", + " 9.960207\n", + " 15.345797\n", + " 6.050494\n", + " 21.287334\n", + " 5.233185\n", + " 2.117434\n", + " 17.084238\n", + " 6.750041\n", + " 13.714162\n", + " 2.039449\n", + " 20.468669\n", + " 16.143988\n", + " 4.065160\n", + " 9.322342\n", + " 6.876040\n", + " 14.503086\n", " 2\n", " \n", " \n", " 2\n", " 3\n", - " 5.310870\n", - " 6.326648\n", - " 4.552025\n", - " 6.782602\n", - " 1.889759\n", - " 1.057797\n", - " 7.021682\n", - " 3.085740\n", - " 4.636659\n", - " 1.311560\n", - " 10.039122\n", - " 7.425196\n", - " 4.031896\n", - " 3.593263\n", - " 3.935879\n", - " 7.829340\n", + " 20.953209\n", + " 26.071361\n", + " 8.986690\n", + " 11.771607\n", + " 8.442361\n", + " 1.953716\n", + " 27.605551\n", + " 7.085774\n", + " 8.561212\n", + " 3.263422\n", + " 14.460568\n", + " 10.752086\n", + " 4.982453\n", + " 8.778626\n", + " 5.584443\n", + " 14.549717\n", " 3\n", " \n", " \n", " 3\n", " 4\n", - " 4.588128\n", - " 7.504651\n", - " 3.670254\n", - " 12.055852\n", - " 4.338342\n", - " 13.443183\n", - " 9.397056\n", - " 4.727704\n", - " 6.856803\n", - " 2.037149\n", - " 21.240715\n", - " 24.963244\n", - " 3.788241\n", - " 5.208550\n", - " 9.801442\n", - " 20.021242\n", + " 14.599806\n", + " 19.162653\n", + " 6.738744\n", + " 10.326302\n", + " 31.657597\n", + " 2.134133\n", + " 36.219244\n", + " 4.099054\n", + " 9.283807\n", + " 2.693036\n", + " 10.250166\n", + " 8.842964\n", + " 4.352090\n", + " 11.591215\n", + " 2.726349\n", + " 11.210159\n", " 4\n", " \n", " \n", " 4\n", " 5\n", - " 4.078594\n", - " 5.858771\n", - " 3.888499\n", - " 9.472374\n", - " 2.372011\n", - " 1.703166\n", - " 6.518079\n", - " 3.563198\n", - " 5.230883\n", - " 1.530075\n", - " 38.030225\n", - " 15.434641\n", - " 3.098016\n", - " 3.948902\n", - " 7.759700\n", - " 12.790385\n", + " 2.607173\n", + " 3.224016\n", + " 1.587835\n", + " 4.004721\n", + " 1.092902\n", + " 0.628333\n", + " 3.484541\n", + " 2.121840\n", + " 2.685696\n", + " 0.959712\n", + " 8.164292\n", + " 5.457338\n", + " 3.288760\n", + " 2.259438\n", + " 3.133704\n", + " 3.889296\n", " 5\n", " \n", " \n", " 5\n", " 6\n", - " 18.033245\n", - " 20.708114\n", - " 8.375777\n", - " 10.894179\n", - " 22.905814\n", - " 2.071226\n", - " 36.052011\n", - " 4.270251\n", - " 8.489450\n", - " 2.859756\n", - " 11.291614\n", - " 9.799747\n", - " 4.532029\n", - " 10.463147\n", - " 3.164878\n", - " 12.215809\n", + " 3.951987\n", + " 13.003755\n", + " 3.170035\n", + " 43.084493\n", + " 1.789685\n", + " 1.112180\n", + " 10.437545\n", + " 24.989896\n", + " 19.458082\n", + " 1.397150\n", + " 15.664330\n", + " 9.878738\n", + " 2.170529\n", + " 11.558954\n", + " 5.503335\n", + " 12.998675\n", " 6\n", " \n", " \n", " 6\n", " 7\n", - " 35.246133\n", - " 45.755326\n", - " 5.143688\n", - " 8.575204\n", - " 12.245368\n", - " 1.517205\n", - " 40.691112\n", - " 3.552398\n", - " 7.167313\n", - " 2.519683\n", - " 8.262509\n", - " 7.113883\n", - " 3.989649\n", - " 6.796181\n", - " 1.706669\n", - " 9.481400\n", + " 5.573563\n", + " 10.668688\n", + " 3.377258\n", + " 18.102451\n", + " 2.561174\n", + " 4.944619\n", + " 9.995903\n", + " 5.517863\n", + " 9.383994\n", + " 1.853947\n", + " 18.188148\n", + " 14.227881\n", + " 3.399089\n", + " 7.011984\n", + " 9.899051\n", + " 38.214906\n", " 7\n", " \n", " \n", " 7\n", " 8\n", - " 22.038232\n", - " 6.726384\n", - " 48.541199\n", - " 12.794302\n", - " 2.148181\n", - " 1.414991\n", - " 22.117769\n", - " 4.839054\n", - " 6.926617\n", - " 2.439495\n", - " 17.799409\n", - " 11.264155\n", - " 2.942548\n", - " 5.373507\n", - " 5.779891\n", - " 13.533310\n", + " 27.069442\n", + " 35.805355\n", + " 5.529667\n", + " 9.248749\n", + " 16.994136\n", + " 1.639795\n", + " 36.993515\n", + " 3.775317\n", + " 7.440898\n", + " 2.550704\n", + " 10.308884\n", + " 8.615445\n", + " 4.747283\n", + " 8.732910\n", + " 2.593586\n", + " 10.743067\n", " 8\n", " \n", " \n", " 8\n", " 9\n", - " 19.287928\n", - " 16.044287\n", - " 13.400287\n", - " 12.406111\n", - " 8.926173\n", - " 2.135102\n", - " 31.626518\n", - " 4.361473\n", - " 9.713586\n", - " 4.407114\n", - " 13.297999\n", - " 12.033864\n", - " 6.729911\n", - " 8.253084\n", - " 5.336903\n", - " 13.898886\n", + " 15.020223\n", + " 19.070327\n", + " 6.534041\n", + " 10.172453\n", + " 22.049004\n", + " 2.585827\n", + " 30.746578\n", + " 4.145985\n", + " 8.132600\n", + " 2.868514\n", + " 13.845175\n", + " 11.285477\n", + " 6.531780\n", + " 11.375026\n", + " 3.932905\n", + " 12.996394\n", " 9\n", " \n", " \n", " 9\n", " 10\n", - " 10.383163\n", - " 15.077001\n", - " 4.677668\n", - " 9.398190\n", - " 39.115224\n", - " 1.869134\n", - " 37.112992\n", - " 3.799953\n", - " 7.842450\n", - " 2.654522\n", - " 12.000378\n", - " 8.996242\n", - " 3.813376\n", - " 11.426639\n", - " 2.557836\n", - " 11.440348\n", + " 6.325782\n", + " 10.142026\n", + " 4.140835\n", + " 12.977858\n", + " 2.843029\n", + " 3.477757\n", + " 10.121100\n", + " 5.695717\n", + " 7.105341\n", + " 2.085989\n", + " 21.844039\n", + " 16.293455\n", + " 4.120571\n", + " 6.143693\n", + " 13.951618\n", + " 33.232461\n", " 10\n", " \n", " \n", " 10\n", " 11\n", - " 5.177814\n", - " 11.039347\n", - " 4.477304\n", - " 29.958495\n", - " 3.675307\n", - " 1.872490\n", - " 12.429716\n", - " 6.563107\n", - " 10.114977\n", - " 1.790554\n", - " 26.988424\n", - " 14.954350\n", - " 3.239781\n", - " 10.733224\n", - " 9.088853\n", - " 15.220438\n", + " 13.092599\n", + " 17.965436\n", + " 4.825496\n", + " 8.515950\n", + " 42.571354\n", + " 1.532716\n", + " 40.957757\n", + " 3.471640\n", + " 8.142602\n", + " 2.668636\n", + " 8.247525\n", + " 7.364200\n", + " 3.827464\n", + " 11.626355\n", + " 1.792867\n", + " 9.971521\n", " 11\n", " \n", " \n", " 11\n", " 12\n", - " 22.376268\n", - " 13.127674\n", - " 30.344883\n", - " 12.220253\n", - " 8.079126\n", - " 1.497469\n", - " 31.450717\n", - " 4.181987\n", - " 9.020524\n", - " 2.921011\n", - " 13.824409\n", - " 11.125725\n", - " 3.897239\n", - " 7.434558\n", - " 4.232493\n", - " 12.208197\n", + " 35.788462\n", + " 47.732614\n", + " 5.096323\n", + " 9.389730\n", + " 6.580950\n", + " 1.574196\n", + " 37.113912\n", + " 3.773668\n", + " 6.861717\n", + " 2.523721\n", + " 9.791365\n", + " 8.184188\n", + " 4.291852\n", + " 6.876105\n", + " 2.593271\n", + " 10.422270\n", " 12\n", " \n", " \n", " 12\n", " 13\n", - " 17.781746\n", - " 23.259589\n", - " 5.817409\n", - " 12.743726\n", - " 7.003116\n", - " 2.214121\n", - " 22.621340\n", - " 5.396287\n", - " 9.170879\n", - " 3.242152\n", - " 16.008207\n", - " 12.743258\n", - " 9.196240\n", - " 8.609493\n", - " 5.385620\n", - " 15.301657\n", + " 11.267333\n", + " 22.112405\n", + " 4.436330\n", + " 11.221689\n", + " 8.517499\n", + " 1.823718\n", + " 26.488645\n", + " 5.377660\n", + " 7.821649\n", + " 2.314485\n", + " 11.743102\n", + " 10.017828\n", + " 5.973943\n", + " 32.964157\n", + " 4.123915\n", + " 15.393191\n", " 13\n", " \n", " \n", " 13\n", " 14\n", - " 29.756299\n", - " 17.799958\n", - " 22.617733\n", - " 8.856819\n", - " 9.503287\n", - " 1.860167\n", - " 47.485867\n", - " 3.354630\n", - " 7.459624\n", - " 3.288376\n", - " 9.263366\n", - " 8.722512\n", - " 4.235407\n", - " 6.811799\n", - " 2.423871\n", - " 11.263881\n", + " 5.599900\n", + " 8.217478\n", + " 4.093117\n", + " 11.615315\n", + " 2.393532\n", + " 2.072741\n", + " 8.319907\n", + " 4.740646\n", + " 5.862981\n", + " 1.771940\n", + " 45.296469\n", + " 17.510412\n", + " 3.273068\n", + " 4.844663\n", + " 9.434585\n", + " 14.237374\n", " 14\n", " \n", " \n", " 14\n", " 15\n", - " 27.185999\n", - " 36.329187\n", - " 4.721586\n", - " 10.412649\n", - " 10.828014\n", - " 2.050833\n", - " 32.371780\n", - " 4.273661\n", - " 8.871816\n", - " 2.745225\n", - " 11.204563\n", - " 9.904590\n", - " 6.502667\n", - " 7.405720\n", - " 3.145299\n", - " 12.213045\n", + " 4.070490\n", + " 10.468684\n", + " 2.958566\n", + " 20.728478\n", + " 3.051426\n", + " 1.548027\n", + " 8.166279\n", + " 65.663976\n", + " 15.892551\n", + " 1.361709\n", + " 12.513647\n", + " 7.178638\n", + " 2.129428\n", + " 10.472426\n", + " 4.074070\n", + " 14.436947\n", " 15\n", " \n", " \n", " 15\n", " 16\n", - " 7.045143\n", - " 7.495563\n", - " 6.181722\n", - " 6.480860\n", - " 2.110753\n", - " 1.627432\n", - " 9.464481\n", - " 2.575502\n", - " 5.872420\n", - " 48.445661\n", - " 7.120763\n", - " 6.289483\n", - " 32.762208\n", - " 4.105754\n", - " 32.187167\n", - " 7.511360\n", + " 25.989399\n", + " 10.389395\n", + " 43.361902\n", + " 11.320441\n", + " 5.502868\n", + " 1.596107\n", + " 31.901745\n", + " 4.047915\n", + " 6.649028\n", + " 2.593001\n", + " 12.630810\n", + " 9.429332\n", + " 3.332031\n", + " 5.850626\n", + " 4.441145\n", + " 12.780872\n", " 16\n", " \n", " \n", " 16\n", " 17\n", - " 20.354978\n", - " 30.520101\n", - " 4.892320\n", - " 16.173978\n", - " 8.075927\n", - " 1.603134\n", - " 29.583397\n", - " 7.828002\n", - " 8.101682\n", - " 2.134660\n", - " 9.781133\n", - " 8.494943\n", - " 4.396563\n", - " 23.551456\n", - " 2.988123\n", - " 11.874512\n", + " 6.171975\n", + " 14.129711\n", + " 4.450432\n", + " 32.999771\n", + " 2.991384\n", + " 1.449651\n", + " 14.678769\n", + " 10.301502\n", + " 16.227985\n", + " 1.979589\n", + " 19.928467\n", + " 13.745564\n", + " 3.307375\n", + " 13.041965\n", + " 7.408849\n", + " 14.392972\n", " 17\n", " \n", " \n", " 17\n", " 18\n", - " 10.494607\n", - " 17.107881\n", - " 5.348436\n", - " 17.780094\n", - " 21.203811\n", - " 1.461438\n", - " 27.241045\n", - " 6.126475\n", - " 18.533219\n", - " 2.452382\n", - " 12.952084\n", - " 10.323079\n", - " 4.168443\n", - " 11.162888\n", - " 3.745733\n", - " 13.402586\n", + " 4.160652\n", + " 5.233203\n", + " 3.001677\n", + " 3.694203\n", + " 1.580467\n", + " 0.939031\n", + " 6.375645\n", + " 1.274844\n", + " 2.753888\n", + " 96.253502\n", + " 3.903337\n", + " 3.271621\n", + " 16.286033\n", + " 3.430607\n", + " 59.106409\n", + " 5.572448\n", " 18\n", " \n", " \n", " 18\n", " 19\n", - " 4.722481\n", - " 7.938767\n", - " 3.342242\n", - " 13.284337\n", - " 2.235562\n", - " 3.104852\n", - " 7.624367\n", - " 5.010524\n", - " 6.627040\n", - " 1.999837\n", - " 23.452611\n", - " 16.332655\n", - " 4.169646\n", - " 5.350529\n", - " 16.152600\n", - " 35.127025\n", + " 5.443319\n", + " 5.737314\n", + " 4.578300\n", + " 6.719422\n", + " 1.976835\n", + " 2.241670\n", + " 6.249517\n", + " 2.944613\n", + " 6.888751\n", + " 17.290541\n", + " 7.797342\n", + " 5.843747\n", + " 63.039098\n", + " 4.542249\n", + " 11.757854\n", + " 4.433470\n", " 19\n", " \n", " \n", " 19\n", " 20\n", - " 8.960182\n", - " 18.166424\n", - " 4.332482\n", - " 26.917621\n", - " 5.389672\n", - " 1.529815\n", - " 16.792806\n", - " 8.852357\n", - " 29.422826\n", - " 2.796432\n", - " 15.952846\n", - " 10.761341\n", - " 4.166356\n", - " 9.977359\n", - " 5.016190\n", - " 14.369785\n", + " 12.661802\n", + " 14.215822\n", + " 6.632497\n", + " 10.445187\n", + " 5.404565\n", + " 2.035558\n", + " 17.039902\n", + " 4.757361\n", + " 7.733497\n", + " 3.587793\n", + " 18.233667\n", + " 12.162264\n", + " 9.456957\n", + " 7.759186\n", + " 5.301065\n", + " 10.924089\n", " 20\n", " \n", " \n", @@ -1361,70 +1392,70 @@ ], "text/plain": [ "channels cell_meta_cluster CD3 CD4 CD8 CD14 \\\n", - "0 1 4.732977 12.334994 3.826580 27.807260 \n", - "1 2 7.075747 16.851241 4.782487 23.933335 \n", - "2 3 5.310870 6.326648 4.552025 6.782602 \n", - "3 4 4.588128 7.504651 3.670254 12.055852 \n", - "4 5 4.078594 5.858771 3.888499 9.472374 \n", - "5 6 18.033245 20.708114 8.375777 10.894179 \n", - "6 7 35.246133 45.755326 5.143688 8.575204 \n", - "7 8 22.038232 6.726384 48.541199 12.794302 \n", - "8 9 19.287928 16.044287 13.400287 12.406111 \n", - "9 10 10.383163 15.077001 4.677668 9.398190 \n", - "10 11 5.177814 11.039347 4.477304 29.958495 \n", - "11 12 22.376268 13.127674 30.344883 12.220253 \n", - "12 13 17.781746 23.259589 5.817409 12.743726 \n", - "13 14 29.756299 17.799958 22.617733 8.856819 \n", - "14 15 27.185999 36.329187 4.721586 10.412649 \n", - "15 16 7.045143 7.495563 6.181722 6.480860 \n", - "16 17 20.354978 30.520101 4.892320 16.173978 \n", - "17 18 10.494607 17.107881 5.348436 17.780094 \n", - "18 19 4.722481 7.938767 3.342242 13.284337 \n", - "19 20 8.960182 18.166424 4.332482 26.917621 \n", + "0 1 9.920224 10.636219 9.059409 11.995957 \n", + "1 2 9.960207 15.345797 6.050494 21.287334 \n", + "2 3 20.953209 26.071361 8.986690 11.771607 \n", + "3 4 14.599806 19.162653 6.738744 10.326302 \n", + "4 5 2.607173 3.224016 1.587835 4.004721 \n", + "5 6 3.951987 13.003755 3.170035 43.084493 \n", + "6 7 5.573563 10.668688 3.377258 18.102451 \n", + "7 8 27.069442 35.805355 5.529667 9.248749 \n", + "8 9 15.020223 19.070327 6.534041 10.172453 \n", + "9 10 6.325782 10.142026 4.140835 12.977858 \n", + "10 11 13.092599 17.965436 4.825496 8.515950 \n", + "11 12 35.788462 47.732614 5.096323 9.389730 \n", + "12 13 11.267333 22.112405 4.436330 11.221689 \n", + "13 14 5.599900 8.217478 4.093117 11.615315 \n", + "14 15 4.070490 10.468684 2.958566 20.728478 \n", + "15 16 25.989399 10.389395 43.361902 11.320441 \n", + "16 17 6.171975 14.129711 4.450432 32.999771 \n", + "17 18 4.160652 5.233203 3.001677 3.694203 \n", + "18 19 5.443319 5.737314 4.578300 6.719422 \n", + "19 20 12.661802 14.215822 6.632497 10.445187 \n", "\n", - "channels CD20 CD31 CD45 CD68 CD163 CK17 \\\n", - "0 2.461496 1.329181 10.076252 33.944057 17.968353 1.629934 \n", - "1 4.768343 1.419091 18.424167 8.391063 9.533554 1.756295 \n", - "2 1.889759 1.057797 7.021682 3.085740 4.636659 1.311560 \n", - "3 4.338342 13.443183 9.397056 4.727704 6.856803 2.037149 \n", - "4 2.372011 1.703166 6.518079 3.563198 5.230883 1.530075 \n", - "5 22.905814 2.071226 36.052011 4.270251 8.489450 2.859756 \n", - "6 12.245368 1.517205 40.691112 3.552398 7.167313 2.519683 \n", - "7 2.148181 1.414991 22.117769 4.839054 6.926617 2.439495 \n", - "8 8.926173 2.135102 31.626518 4.361473 9.713586 4.407114 \n", - "9 39.115224 1.869134 37.112992 3.799953 7.842450 2.654522 \n", - "10 3.675307 1.872490 12.429716 6.563107 10.114977 1.790554 \n", - "11 8.079126 1.497469 31.450717 4.181987 9.020524 2.921011 \n", - "12 7.003116 2.214121 22.621340 5.396287 9.170879 3.242152 \n", - "13 9.503287 1.860167 47.485867 3.354630 7.459624 3.288376 \n", - "14 10.828014 2.050833 32.371780 4.273661 8.871816 2.745225 \n", - "15 2.110753 1.627432 9.464481 2.575502 5.872420 48.445661 \n", - "16 8.075927 1.603134 29.583397 7.828002 8.101682 2.134660 \n", - "17 21.203811 1.461438 27.241045 6.126475 18.533219 2.452382 \n", - "18 2.235562 3.104852 7.624367 5.010524 6.627040 1.999837 \n", - "19 5.389672 1.529815 16.792806 8.852357 29.422826 2.796432 \n", + "channels CD20 CD31 CD45 CD68 CD163 CK17 \\\n", + "0 6.404475 7.600641 19.981869 5.353948 7.567123 5.640777 \n", + "1 5.233185 2.117434 17.084238 6.750041 13.714162 2.039449 \n", + "2 8.442361 1.953716 27.605551 7.085774 8.561212 3.263422 \n", + "3 31.657597 2.134133 36.219244 4.099054 9.283807 2.693036 \n", + "4 1.092902 0.628333 3.484541 2.121840 2.685696 0.959712 \n", + "5 1.789685 1.112180 10.437545 24.989896 19.458082 1.397150 \n", + "6 2.561174 4.944619 9.995903 5.517863 9.383994 1.853947 \n", + "7 16.994136 1.639795 36.993515 3.775317 7.440898 2.550704 \n", + "8 22.049004 2.585827 30.746578 4.145985 8.132600 2.868514 \n", + "9 2.843029 3.477757 10.121100 5.695717 7.105341 2.085989 \n", + "10 42.571354 1.532716 40.957757 3.471640 8.142602 2.668636 \n", + "11 6.580950 1.574196 37.113912 3.773668 6.861717 2.523721 \n", + "12 8.517499 1.823718 26.488645 5.377660 7.821649 2.314485 \n", + "13 2.393532 2.072741 8.319907 4.740646 5.862981 1.771940 \n", + "14 3.051426 1.548027 8.166279 65.663976 15.892551 1.361709 \n", + "15 5.502868 1.596107 31.901745 4.047915 6.649028 2.593001 \n", + "16 2.991384 1.449651 14.678769 10.301502 16.227985 1.979589 \n", + "17 1.580467 0.939031 6.375645 1.274844 2.753888 96.253502 \n", + "18 1.976835 2.241670 6.249517 2.944613 6.888751 17.290541 \n", + "19 5.404565 2.035558 17.039902 4.757361 7.733497 3.587793 \n", "\n", "channels Collagen1 Fibronectin ECAD HLADR SMA Vim \\\n", - "0 16.618670 9.723362 2.770627 12.875719 5.481965 15.619396 \n", - "1 15.256073 10.150131 3.817615 33.035568 5.489962 15.135321 \n", - "2 10.039122 7.425196 4.031896 3.593263 3.935879 7.829340 \n", - "3 21.240715 24.963244 3.788241 5.208550 9.801442 20.021242 \n", - "4 38.030225 15.434641 3.098016 3.948902 7.759700 12.790385 \n", - "5 11.291614 9.799747 4.532029 10.463147 3.164878 12.215809 \n", - "6 8.262509 7.113883 3.989649 6.796181 1.706669 9.481400 \n", - "7 17.799409 11.264155 2.942548 5.373507 5.779891 13.533310 \n", - "8 13.297999 12.033864 6.729911 8.253084 5.336903 13.898886 \n", - "9 12.000378 8.996242 3.813376 11.426639 2.557836 11.440348 \n", - "10 26.988424 14.954350 3.239781 10.733224 9.088853 15.220438 \n", - "11 13.824409 11.125725 3.897239 7.434558 4.232493 12.208197 \n", - "12 16.008207 12.743258 9.196240 8.609493 5.385620 15.301657 \n", - "13 9.263366 8.722512 4.235407 6.811799 2.423871 11.263881 \n", - "14 11.204563 9.904590 6.502667 7.405720 3.145299 12.213045 \n", - "15 7.120763 6.289483 32.762208 4.105754 32.187167 7.511360 \n", - "16 9.781133 8.494943 4.396563 23.551456 2.988123 11.874512 \n", - "17 12.952084 10.323079 4.168443 11.162888 3.745733 13.402586 \n", - "18 23.452611 16.332655 4.169646 5.350529 16.152600 35.127025 \n", - "19 15.952846 10.761341 4.166356 9.977359 5.016190 14.369785 \n", + "0 17.392973 13.367731 5.794182 6.907827 9.516907 19.260004 \n", + "1 20.468669 16.143988 4.065160 9.322342 6.876040 14.503086 \n", + "2 14.460568 10.752086 4.982453 8.778626 5.584443 14.549717 \n", + "3 10.250166 8.842964 4.352090 11.591215 2.726349 11.210159 \n", + "4 8.164292 5.457338 3.288760 2.259438 3.133704 3.889296 \n", + "5 15.664330 9.878738 2.170529 11.558954 5.503335 12.998675 \n", + "6 18.188148 14.227881 3.399089 7.011984 9.899051 38.214906 \n", + "7 10.308884 8.615445 4.747283 8.732910 2.593586 10.743067 \n", + "8 13.845175 11.285477 6.531780 11.375026 3.932905 12.996394 \n", + "9 21.844039 16.293455 4.120571 6.143693 13.951618 33.232461 \n", + "10 8.247525 7.364200 3.827464 11.626355 1.792867 9.971521 \n", + "11 9.791365 8.184188 4.291852 6.876105 2.593271 10.422270 \n", + "12 11.743102 10.017828 5.973943 32.964157 4.123915 15.393191 \n", + "13 45.296469 17.510412 3.273068 4.844663 9.434585 14.237374 \n", + "14 12.513647 7.178638 2.129428 10.472426 4.074070 14.436947 \n", + "15 12.630810 9.429332 3.332031 5.850626 4.441145 12.780872 \n", + "16 19.928467 13.745564 3.307375 13.041965 7.408849 14.392972 \n", + "17 3.903337 3.271621 16.286033 3.430607 59.106409 5.572448 \n", + "18 7.797342 5.843747 63.039098 4.542249 11.757854 4.433470 \n", + "19 18.233667 12.162264 9.456957 7.759186 5.301065 10.924089 \n", "\n", "channels cell_meta_cluster_rename \n", "0 1 \n",