@@ -97,7 +97,7 @@ def _make_multi():
97
97
98
98
def test_plot_can_color_from_geodataframe (self , sdata_blobs : SpatialData ):
99
99
blob = deepcopy (sdata_blobs )
100
- blob ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
100
+ blob ["table" ].obs ["region" ] = "blobs_polygons"
101
101
blob ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
102
102
blob .shapes ["blobs_polygons" ]["value" ] = [1 , 10 , 1 , 20 , 1 ]
103
103
blob .pl .render_shapes (
@@ -111,7 +111,7 @@ def test_plot_can_scale_shapes(self, sdata_blobs: SpatialData):
111
111
def test_plot_can_filter_with_groups (self , sdata_blobs : SpatialData ):
112
112
_ , axs = plt .subplots (nrows = 1 , ncols = 2 , layout = "tight" )
113
113
114
- sdata_blobs ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
114
+ sdata_blobs ["table" ].obs ["region" ] = "blobs_polygons"
115
115
sdata_blobs ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
116
116
sdata_blobs .shapes ["blobs_polygons" ]["cluster" ] = "c1"
117
117
sdata_blobs .shapes ["blobs_polygons" ].iloc [3 :5 , 1 ] = "c2"
@@ -125,7 +125,7 @@ def test_plot_can_filter_with_groups(self, sdata_blobs: SpatialData):
125
125
)
126
126
127
127
def test_plot_coloring_with_palette (self , sdata_blobs : SpatialData ):
128
- sdata_blobs ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
128
+ sdata_blobs ["table" ].obs ["region" ] = "blobs_polygons"
129
129
sdata_blobs ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
130
130
sdata_blobs .shapes ["blobs_polygons" ]["cluster" ] = "c1"
131
131
sdata_blobs .shapes ["blobs_polygons" ].iloc [3 :5 , 1 ] = "c2"
@@ -138,13 +138,13 @@ def test_plot_coloring_with_palette(self, sdata_blobs: SpatialData):
138
138
).pl .show ()
139
139
140
140
def test_plot_colorbar_respects_input_limits (self , sdata_blobs : SpatialData ):
141
- sdata_blobs ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
141
+ sdata_blobs ["table" ].obs ["region" ] = "blobs_polygons"
142
142
sdata_blobs ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
143
143
sdata_blobs .shapes ["blobs_polygons" ]["cluster" ] = [1 , 2 , 3 , 5 , 20 ]
144
- sdata_blobs .pl .render_shapes ("blobs_polygons" , color = "cluster" , groups = [ "c1" ] ).pl .show ()
144
+ sdata_blobs .pl .render_shapes ("blobs_polygons" , color = "cluster" ).pl .show ()
145
145
146
146
def test_plot_colorbar_can_be_normalised (self , sdata_blobs : SpatialData ):
147
- sdata_blobs ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
147
+ sdata_blobs ["table" ].obs ["region" ] = "blobs_polygons"
148
148
sdata_blobs ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
149
149
sdata_blobs .shapes ["blobs_polygons" ]["cluster" ] = [1 , 2 , 3 , 5 , 20 ]
150
150
norm = Normalize (vmin = 0 , vmax = 5 , clip = True )
@@ -186,7 +186,7 @@ def test_plot_can_plot_with_annotation_despite_random_shuffling(self, sdata_blob
186
186
187
187
def test_plot_can_plot_queried_with_annotation_despite_random_shuffling (self , sdata_blobs : SpatialData ):
188
188
sdata_blobs ["table" ].obs ["region" ] = "blobs_circles"
189
- new_table = sdata_blobs ["table" ][:5 ]
189
+ new_table = sdata_blobs ["table" ][:5 ]. copy ()
190
190
new_table .uns ["spatialdata_attrs" ]["region" ] = "blobs_circles"
191
191
new_table .obs ["instance_id" ] = np .array (range (5 ))
192
192
@@ -214,7 +214,7 @@ def test_plot_can_plot_queried_with_annotation_despite_random_shuffling(self, sd
214
214
215
215
def test_plot_can_color_two_shapes_elements_by_annotation (self , sdata_blobs : SpatialData ):
216
216
sdata_blobs ["table" ].obs ["region" ] = "blobs_circles"
217
- new_table = sdata_blobs ["table" ][:10 ]
217
+ new_table = sdata_blobs ["table" ][:10 ]. copy ()
218
218
new_table .uns ["spatialdata_attrs" ]["region" ] = ["blobs_circles" , "blobs_polygons" ]
219
219
new_table .obs ["instance_id" ] = np .concatenate ((np .array (range (5 )), np .array (range (5 ))))
220
220
@@ -230,7 +230,7 @@ def test_plot_can_color_two_shapes_elements_by_annotation(self, sdata_blobs: Spa
230
230
231
231
def test_plot_can_color_two_queried_shapes_elements_by_annotation (self , sdata_blobs : SpatialData ):
232
232
sdata_blobs ["table" ].obs ["region" ] = "blobs_circles"
233
- new_table = sdata_blobs ["table" ][:10 ]
233
+ new_table = sdata_blobs ["table" ][:10 ]. copy ()
234
234
new_table .uns ["spatialdata_attrs" ]["region" ] = ["blobs_circles" , "blobs_polygons" ]
235
235
new_table .obs ["instance_id" ] = np .concatenate ((np .array (range (5 )), np .array (range (5 ))))
236
236
@@ -312,7 +312,20 @@ def test_plot_datashader_can_color_by_category(self, sdata_blobs: SpatialData):
312
312
sdata_blobs .pl .render_shapes (element = "blobs_polygons" , color = "category" , method = "datashader" ).pl .show ()
313
313
314
314
def test_plot_datashader_can_color_by_value (self , sdata_blobs : SpatialData ):
315
- sdata_blobs ["table" ].obs ["region" ] = [ "blobs_polygons" ] * sdata_blobs [ "table" ]. n_obs
315
+ sdata_blobs ["table" ].obs ["region" ] = "blobs_polygons"
316
316
sdata_blobs ["table" ].uns ["spatialdata_attrs" ]["region" ] = "blobs_polygons"
317
317
sdata_blobs .shapes ["blobs_polygons" ]["value" ] = [1 , 10 , 1 , 20 , 1 ]
318
318
sdata_blobs .pl .render_shapes (element = "blobs_polygons" , color = "value" , method = "datashader" ).pl .show ()
319
+
320
+ def test_plot_can_set_clims_clip (self , sdata_blobs : SpatialData ):
321
+ table_shapes = sdata_blobs ["table" ][:5 ].copy ()
322
+ table_shapes .obs .instance_id = list (range (5 ))
323
+ table_shapes .obs ["region" ] = "blobs_circles"
324
+ table_shapes .obs ["dummy_gene_expression" ] = [i * 10 for i in range (5 )]
325
+ table_shapes .uns ["spatialdata_attrs" ]["region" ] = "blobs_circles"
326
+ sdata_blobs ["new_table" ] = table_shapes
327
+
328
+ norm = Normalize (vmin = 20 , vmax = 40 , clip = True )
329
+ sdata_blobs .pl .render_shapes (
330
+ "blobs_circles" , color = "dummy_gene_expression" , norm = norm , table_name = "new_table"
331
+ ).pl .show ()
0 commit comments