Skip to content

Commit 689ff4c

Browse files
committed
Expose SpatialData table name as parameter
1 parent 7b2a121 commit 689ff4c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

metaspace_converter/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class COL:
2020
MICROMETER: Final = "micrometer"
2121
OPTICAL_IMAGE_KEY: Final = "optical_image"
2222
POINTS_KEY: Final = "maldi_points"
23+
TABLE_KEY: Final = "table"
2324
REGION_KEY: Final = "region"
2425
INSTANCE_KEY: Final = "instance_id"
2526
X: Final = "x"

metaspace_converter/to_spatialdata.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
OPTICAL_IMAGE_KEY,
2020
POINTS_KEY,
2121
REGION_KEY,
22+
TABLE_KEY,
2223
XY,
2324
YX,
2425
YXC,
@@ -40,6 +41,7 @@ def metaspace_to_spatialdata(
4041
optical_name_added: str = OPTICAL_IMAGE_KEY,
4142
add_points: bool = True,
4243
points_name_added: str = POINTS_KEY,
44+
table_name: str = TABLE_KEY,
4345
sm: Optional[SMInstance] = None,
4446
**annotation_filter,
4547
) -> SpatialData:
@@ -67,7 +69,8 @@ def metaspace_to_spatialdata(
6769
add_points: Whether to also add ion image pixel coordinates as SpatialData points. This
6870
allows to spatially visualize the ion image values. If False, only ion intensities are
6971
added to the table and coordinates are added to ``obs``.
70-
points_name_added: Name of the element where to store the points in the SpatialData object
72+
points_name: Name of the element where to store the points in the SpatialData object
73+
table_name_added: The name for the SpatialData table to which annotations will be saved.
7174
sm: Optionally a cached SMInstance
7275
annotation_filter: Additional keyword arguments passed to the METASPACE API.
7376
@@ -101,7 +104,7 @@ def metaspace_to_spatialdata(
101104
**annotation_filter,
102105
)
103106
table = _create_spatialdata_table(adata)
104-
sdata = SpatialData(tables={"table": table})
107+
sdata = SpatialData(tables={table_name: table})
105108

106109
# Create image
107110
if has_optical_image(dataset) and add_optical_image:

0 commit comments

Comments
 (0)