@@ -56,7 +56,7 @@ def xenium(
56
56
* ,
57
57
cells_boundaries : bool = True ,
58
58
nucleus_boundaries : bool = True ,
59
- cells_as_circles : bool = True ,
59
+ cells_as_circles : bool = False ,
60
60
cells_labels : bool = True ,
61
61
nucleus_labels : bool = True ,
62
62
transcripts : bool = True ,
@@ -96,10 +96,8 @@ def xenium(
96
96
nucleus_boundaries
97
97
Whether to read nucleus boundaries (polygons).
98
98
cells_as_circles
99
- Whether to read cells also as circles. Useful for performant visualization. The radii of the nuclei,
100
- not the ones of cells, will be used; using the radii of cells would make the visualization too cluttered
101
- (the cell boundaries are computed as a maximum expansion of the nuclei location and therefore the
102
- corresponding circles would show considerable overlap).
99
+ Whether to read cells also as circles (the center and the radius of each circle is computed from the
100
+ corresponding labels cell).
103
101
cells_labels
104
102
Whether to read cell labels (raster). The polygonal version of the cell labels are simplified
105
103
for visualization purposes, and using the raster version is recommended for analysis.
@@ -128,6 +126,25 @@ def xenium(
128
126
Returns
129
127
-------
130
128
:class:`spatialdata.SpatialData`
129
+
130
+ Notes
131
+ -----
132
+ Old versions. Until spatialdata-io v0.1.3post0: previously, `cells_as_circles` was `True` by default; the table was associated to the
133
+ circles when `cells_as_circles` was `True`, and the table was associated to the polygons when `cells_as_circles`
134
+ was `False`; the radii of the circles were computed form the nuclei instead of the cells.
135
+
136
+ Performance. You can improve visualization performance (at the cost of accuracy) by setting `cells_as_circles` to `True`.
137
+
138
+ Examples
139
+ --------
140
+ This code shows how to change the annotation target of the table from the cell circles to the cell labels.
141
+ >>> from spatialdata_io import xenium
142
+ >>> sdata = xenium("path/to/raw/data", cells_as_circles=True)
143
+ >>> sdata["table"].obs["region"] = "cell_labels"
144
+ >>> sdata.set_table_annotates_spatialelement(
145
+ ... table_name="table", region="cell_labels", region_key="region", instance_key="cell_labels"
146
+ ... )
147
+ >>> sdata.write("path/to/data.zarr")
131
148
"""
132
149
image_models_kwargs , labels_models_kwargs = _initialize_raster_models_kwargs (
133
150
image_models_kwargs , labels_models_kwargs
@@ -138,7 +155,7 @@ def xenium(
138
155
# to trigger the warning if the version cannot be parsed
139
156
version = _parse_version_of_xenium_analyzer (specs , hide_warning = False )
140
157
141
- specs ["region" ] = "cell_circles" if cells_as_circles else "cell_boundaries "
158
+ specs ["region" ] = "cell_circles" if cells_as_circles else "cell_labels "
142
159
143
160
# the table is required in some cases
144
161
if not cells_table :
@@ -210,14 +227,16 @@ def xenium(
210
227
if cell_labels_indices_mapping is not None and table is not None :
211
228
if not pd .DataFrame .equals (cell_labels_indices_mapping ["cell_id" ], table .obs [str (XeniumKeys .CELL_ID )]):
212
229
warnings .warn (
213
- "The cell_id column in the cell_labels_table does not match the cell_id column derived from the cell "
214
- "labels data. This could be due to trying to read a new version that is not supported yet. Please "
215
- "report this issue." ,
230
+ "The cell_id column in the cell_labels_table does not match the cell_id column derived from the "
231
+ "cell labels data. This could be due to trying to read a new version that is not supported yet. "
232
+ "Please report this issue." ,
216
233
UserWarning ,
217
234
stacklevel = 2 ,
218
235
)
219
236
else :
220
237
table .obs ["cell_labels" ] = cell_labels_indices_mapping ["label_index" ]
238
+ if not cells_as_circles :
239
+ table .uns [TableModel .ATTRS_KEY ][TableModel .INSTANCE_KEY ] = "cell_labels"
221
240
222
241
if nucleus_boundaries :
223
242
polygons ["nucleus_boundaries" ] = _get_polygons (
0 commit comments