Skip to content

Commit 13fa5ef

Browse files
Added deprecation warnings for DeepProfiler_processing.py and cell_locations.py (cytomining#695)
* added deprecation warning for DeepProfiler_processing.py * added deprecation warning in cell_locations.py module * [pre-commit.ci lite] apply automatic fixes * moved deprecation warnings to classes * updated cell_locations warning * added SingleCells deprecation warning * added cmap deprecation warnings * fixed CellLocation name and pycytominer name * Updated deprecation warnings to point to CytoTable --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 341cbe6 commit 13fa5ef

5 files changed

Lines changed: 66 additions & 1 deletion

File tree

pycytominer/annotate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Annotates profiles with metadata information
33
"""
44

5+
import warnings
56
from typing import Literal, Optional, Union
67

78
import pandas as pd
@@ -116,6 +117,14 @@ def annotate(
116117

117118
# Add specific Connectivity Map (CMAP) formatting
118119
if format_broad_cmap:
120+
# raise deprecation warning when format_broad_cmap is set to True
121+
warnings.warn(
122+
"The `format_broad_cmap` parameter in annotate() is deprecated and will be "
123+
"removed in a future release.",
124+
category=DeprecationWarning,
125+
stacklevel=2,
126+
)
127+
119128
annotated = annotate_cmap(
120129
annotated,
121130
annotate_join_on=join_on[1],

pycytominer/cyto_utils/DeepProfiler_processing.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ def __init__(
6161
See above for all other parameters.
6262
"""
6363

64+
# setting DeepProfilerData deprecation warning
65+
warnings.warn(
66+
"The DeepProfilerData class is deprecated and will be removed in a future "
67+
"Pycytominer release. Please use CytoTable instead: "
68+
"https://github.com/cytomining/CytoTable",
69+
category=DeprecationWarning,
70+
stacklevel=2,
71+
)
72+
6473
self.index_df = pd.read_csv(index_file, dtype=str)
6574
self.profile_dir = profile_dir
6675
self.filename_delimiter = filename_delimiter
@@ -175,6 +184,16 @@ def __init__(
175184
---------
176185
See above for all parameters.
177186
"""
187+
188+
# setting AggregateDeepProfiler deprecation warning
189+
warnings.warn(
190+
"The AggregateDeepProfiler class is deprecated and will be removed in a future "
191+
"Pycytominer release. Please use CytoTable instead: "
192+
"https://github.com/cytomining/CytoTable",
193+
category=DeprecationWarning,
194+
stacklevel=2,
195+
)
196+
178197
if aggregate_operation not in [
179198
"median",
180199
"mean",
@@ -369,7 +388,14 @@ def __init__(
369388
---------
370389
See above for all parameters.
371390
"""
372-
391+
# setting SingleCellDeepProfiler deprecation warning
392+
warnings.warn(
393+
"The SingleCellDeepProfiler class is deprecated and will be removed in a future "
394+
"Pycytominer release. Please use CytoTable instead: "
395+
"https://github.com/cytomining/CytoTable",
396+
category=DeprecationWarning,
397+
stacklevel=2,
398+
)
373399
self.deep_data = deep_data
374400

375401
def get_single_cells(

pycytominer/cyto_utils/annotate_custom.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import contextlib
6+
import warnings
67

78
import numpy as np
89
import pandas as pd
@@ -29,6 +30,7 @@ def prepare_external_metadata_for_annotate(
2930
external_metadata : pd.DataFrame
3031
External metadata with columns renamed to be compatible with annotate() conventions.
3132
"""
33+
# Setting deprecation warning
3234
# Protect certain columns with specific prefixes ("Metadata_", "Image_Metadata", and "Image_").
3335
# The function will protect only non-numeric columns with "Image_" prefix.
3436
# This prevents adding a "Metadata_" prefix, which will occur during `cp_clean`, later
@@ -92,6 +94,14 @@ def annotate_cmap(
9294
annotated: pd.DataFrame
9395
CMAP annotated data
9496
"""
97+
98+
# setting deprecation warning
99+
warnings.warn(
100+
"annotate_cmap is deprecated and will be removed in a future release.",
101+
category=DeprecationWarning,
102+
stacklevel=2,
103+
)
104+
95105
pert_opts = ["none", "chemical", "genetic"]
96106

97107
if perturbation_mode not in pert_opts:

pycytominer/cyto_utils/cell_locations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import pathlib
88
import tempfile
9+
import warnings
910
from typing import Optional, Union
1011

1112
import boto3
@@ -91,6 +92,15 @@ def __init__(
9192
cell_x_loc: str = "Nuclei_Location_Center_X",
9293
cell_y_loc: str = "Nuclei_Location_Center_Y",
9394
):
95+
96+
# setting deprecation warning for the cell_locations module
97+
warnings.warn(
98+
"The CellLocation class is deprecated and will be removed in a "
99+
"future Pycytominer release.",
100+
category=DeprecationWarning,
101+
stacklevel=2,
102+
)
103+
94104
self.metadata_input = self._expanduser(metadata_input)
95105
self.augmented_metadata_output = self._expanduser(augmented_metadata_output)
96106
self.single_cell_input = self._expanduser(single_cell_input)

pycytominer/cyto_utils/cells.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Class to interact with single cell morphological profiles.
33
"""
44

5+
import warnings
56
from typing import Optional, Union, cast
67

78
import numpy as np
@@ -136,6 +137,15 @@ def __init__(
136137
if not subsample_frac > 0 and subsample_frac <= 1:
137138
raise ValueError("subsample_frac must be between 0 and 1")
138139

140+
# set SingleCells deprecation warning and recommend CytoTable
141+
warnings.warn(
142+
"The SingleCells class is deprecated and will be removed in a future "
143+
"Pycytominer release. Please use CytoTable instead: "
144+
"https://github.com/cytomining/CytoTable",
145+
category=DeprecationWarning,
146+
stacklevel=2,
147+
)
148+
139149
self.sql_file = sql_file
140150
self.strata = strata
141151
self.load_image_data = load_image_data

0 commit comments

Comments
 (0)