spatialproteomics 0.8.3__tar.gz → 0.8.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spatialproteomics-0.8.3/spatialproteomics.egg-info → spatialproteomics-0.8.4}/PKG-INFO +1 -1
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/pyproject.toml +1 -1
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/la/label.py +11 -2
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/la/utils.py +9 -1
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pp/utils.py +5 -3
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4/spatialproteomics.egg-info}/PKG-INFO +1 -1
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/tests/test_to_zarr.py +4 -4
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/LICENSE +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/README.md +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/setup.cfg +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/base_logger.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/constants.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/container.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/image_container/ImageContainer.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/image_container/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/la/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/nh/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/nh/neighborhood.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/nh/utils.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pl/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pl/plot.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pl/utils.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pp/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pp/intensity.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/pp/preprocessing.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/sd/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/sd/utils.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/tl/__init__.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/tl/tool.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/tl/utils.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/SOURCES.txt +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/dependency_links.txt +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/requires.txt +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/top_level.txt +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/tests/test_container.py +0 -0
- {spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/tests/test_integration.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spatialproteomics
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Spatialproteomics is an interoperable toolbox for analyzing highly multiplexed fluorescence image data
|
|
5
5
|
Author: Matthias Meyer-Bender, Harald Vohringer
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -76,6 +76,7 @@ def threshold_labels(
|
|
|
76
76
|
def predict_cell_types_argmax(
|
|
77
77
|
sdata,
|
|
78
78
|
marker_dict: dict,
|
|
79
|
+
min_intensity: float = 0.0,
|
|
79
80
|
table_key: str = SDLayers.TABLE,
|
|
80
81
|
label_key: str = SDFeatures.LABELS,
|
|
81
82
|
copy: bool = False,
|
|
@@ -90,6 +91,7 @@ def predict_cell_types_argmax(
|
|
|
90
91
|
Args:
|
|
91
92
|
sdata (spatialdata.SpatialData): The spatialdata object containing the expression matrix.
|
|
92
93
|
marker_dict (dict): A dictionary containing the marker genes for each cell type.
|
|
94
|
+
min_intensity (float, optional): The minimum intensity threshold for assigning cells to a type. Cells with all marker intensities below this threshold will be assigned to "Unlabeled". Defaults to 0.0.
|
|
93
95
|
table_key (str, optional): The key under which the expression matrix is stored in the tables attribute of the spatialdata object. Defaults to "table".
|
|
94
96
|
label_key (str, optional): The key under which the cell type labels are stored in the obs attribute of the spatialdata object. Defaults to "celltype".
|
|
95
97
|
copy (bool, optional): Whether to create a copy of the spatialdata object. Defaults to False.
|
|
@@ -102,7 +104,9 @@ def predict_cell_types_argmax(
|
|
|
102
104
|
assert (
|
|
103
105
|
len(set(marker_dict.keys()) - set(expression_df.columns)) == 0
|
|
104
106
|
), f"The following markers were not found in quantification layer: {set(marker_dict.keys()) - set(expression_df.columns)}."
|
|
105
|
-
celltypes = _predict_cell_types_argmax(
|
|
107
|
+
celltypes = _predict_cell_types_argmax(
|
|
108
|
+
expression_df, list(marker_dict.keys()), list(marker_dict.values()), min_intensity=min_intensity
|
|
109
|
+
)
|
|
106
110
|
adata.obs[label_key] = celltypes
|
|
107
111
|
adata.obs[label_key] = adata.obs[label_key].astype("category")
|
|
108
112
|
|
|
@@ -792,6 +796,7 @@ class LabelAccessor:
|
|
|
792
796
|
overwrite_existing_labels: bool = False,
|
|
793
797
|
cell_col: str = "cell",
|
|
794
798
|
label_col: str = "label",
|
|
799
|
+
min_intensity: float = 0.0,
|
|
795
800
|
):
|
|
796
801
|
"""
|
|
797
802
|
Predicts cell types based on the argmax classification of marker intensities.
|
|
@@ -802,6 +807,7 @@ class LabelAccessor:
|
|
|
802
807
|
overwrite_existing_labels (bool, optional): Whether to overwrite existing labels. Defaults to False.
|
|
803
808
|
cell_col (str, optional): The name of the column to store cell IDs in the output dataframe. Defaults to "cell".
|
|
804
809
|
label_col (str, optional): The name of the column to store predicted cell types in the output dataframe. Defaults to "label".
|
|
810
|
+
min_intensity (float, optional): The minimum intensity threshold for assigning cells to a type. Defaults to 0.0.
|
|
805
811
|
|
|
806
812
|
Returns:
|
|
807
813
|
xr.Dataset: A new spatialproteomics object with the predicted cell types added as labels.
|
|
@@ -825,7 +831,10 @@ class LabelAccessor:
|
|
|
825
831
|
obj = self._obj.copy()
|
|
826
832
|
|
|
827
833
|
celltypes_argmax = _predict_cell_types_argmax(
|
|
828
|
-
pd.DataFrame(obj.pp[markers][key].values, columns=markers),
|
|
834
|
+
pd.DataFrame(obj.pp[markers][key].values, columns=markers),
|
|
835
|
+
markers=markers,
|
|
836
|
+
celltypes=celltypes,
|
|
837
|
+
min_intensity=min_intensity,
|
|
829
838
|
)
|
|
830
839
|
|
|
831
840
|
# putting everything into a dataframe
|
|
@@ -4,6 +4,8 @@ import numpy as np
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
from skimage.segmentation import relabel_sequential
|
|
6
6
|
|
|
7
|
+
from spatialproteomics.constants import Labels
|
|
8
|
+
|
|
7
9
|
from ..base_logger import logger
|
|
8
10
|
|
|
9
11
|
|
|
@@ -160,11 +162,17 @@ def _predict_cell_types_argmax(
|
|
|
160
162
|
expression_df: pd.DataFrame,
|
|
161
163
|
markers: List,
|
|
162
164
|
celltypes: List,
|
|
165
|
+
min_intensity: float = 0.0,
|
|
163
166
|
):
|
|
164
167
|
# getting the argmax for each cell
|
|
165
168
|
argmax_classification = np.argmax(expression_df[markers], axis=1)
|
|
166
169
|
|
|
167
170
|
# translating the argmax classification into cell types
|
|
168
|
-
celltypes_argmax = np.array(celltypes)[argmax_classification]
|
|
171
|
+
celltypes_argmax = np.array(celltypes, dtype=object)[argmax_classification]
|
|
172
|
+
|
|
173
|
+
# if all markers are below the minimum intensity, assign UNASSIGNED
|
|
174
|
+
if min_intensity > 0.0:
|
|
175
|
+
below_threshold = (expression_df[markers].max(axis=1) < min_intensity).values
|
|
176
|
+
celltypes_argmax[below_threshold] = Labels.UNLABELED
|
|
169
177
|
|
|
170
178
|
return celltypes_argmax
|
|
@@ -659,11 +659,13 @@ def _threshold(
|
|
|
659
659
|
if intensity.size == 1:
|
|
660
660
|
intensity = np.full(len(all_channels), intensity.item(), dtype=img_dtype)
|
|
661
661
|
else:
|
|
662
|
-
#
|
|
663
|
-
intensity = np.asarray(intensity, dtype=
|
|
662
|
+
# casting to float here to allow for NAs (important when using the channels argument)
|
|
663
|
+
intensity = np.asarray(intensity, dtype=float)
|
|
664
664
|
|
|
665
665
|
max_val = np.max(img)
|
|
666
|
-
assert np.all(
|
|
666
|
+
assert np.all(
|
|
667
|
+
intensity[~np.isnan(intensity)] <= max_val
|
|
668
|
+
), "Intensity values must be smaller than the maximum intensity."
|
|
667
669
|
|
|
668
670
|
filtered = None
|
|
669
671
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spatialproteomics
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Spatialproteomics is an interoperable toolbox for analyzing highly multiplexed fluorescence image data
|
|
5
5
|
Author: Matthias Meyer-Bender, Harald Vohringer
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -7,7 +7,7 @@ def test_to_zarr_image(ds_image):
|
|
|
7
7
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
8
8
|
output_path = os.path.join(temp_dir, "zarr_writing_test.zarr")
|
|
9
9
|
try:
|
|
10
|
-
ds_image.drop_encoding().to_zarr(output_path)
|
|
10
|
+
ds_image.drop_encoding().to_zarr(output_path, consolidated=False)
|
|
11
11
|
assert os.path.exists(output_path) and os.path.isdir(
|
|
12
12
|
output_path
|
|
13
13
|
), f"Directory {output_path} was not created."
|
|
@@ -21,7 +21,7 @@ def test_to_zarr_segmentation(ds_segmentation):
|
|
|
21
21
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
22
22
|
output_path = os.path.join(temp_dir, "zarr_writing_test.zarr")
|
|
23
23
|
try:
|
|
24
|
-
ds_segmentation.drop_encoding().to_zarr(output_path)
|
|
24
|
+
ds_segmentation.drop_encoding().to_zarr(output_path, consolidated=False)
|
|
25
25
|
assert os.path.exists(output_path) and os.path.isdir(
|
|
26
26
|
output_path
|
|
27
27
|
), f"Directory {output_path} was not created."
|
|
@@ -35,7 +35,7 @@ def test_to_zarr_labels(ds_labels):
|
|
|
35
35
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
36
36
|
output_path = os.path.join(temp_dir, "zarr_writing_test.zarr")
|
|
37
37
|
try:
|
|
38
|
-
ds_labels.drop_encoding().to_zarr(output_path)
|
|
38
|
+
ds_labels.drop_encoding().to_zarr(output_path, consolidated=False)
|
|
39
39
|
assert os.path.exists(output_path) and os.path.isdir(
|
|
40
40
|
output_path
|
|
41
41
|
), f"Directory {output_path} was not created."
|
|
@@ -49,7 +49,7 @@ def test_to_zarr_neighborhoods(ds_neighborhoods):
|
|
|
49
49
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
50
50
|
output_path = os.path.join(temp_dir, "zarr_writing_test.zarr")
|
|
51
51
|
try:
|
|
52
|
-
ds_neighborhoods.drop_encoding().to_zarr(output_path)
|
|
52
|
+
ds_neighborhoods.drop_encoding().to_zarr(output_path, consolidated=False)
|
|
53
53
|
assert os.path.exists(output_path) and os.path.isdir(
|
|
54
54
|
output_path
|
|
55
55
|
), f"Directory {output_path} was not created."
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics/image_container/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{spatialproteomics-0.8.3 → spatialproteomics-0.8.4}/spatialproteomics.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|