@@ -169,6 +169,7 @@ def render_shapes(
169
169
scale : float | int = 1.0 ,
170
170
method : str | None = None ,
171
171
table_name : str | None = None ,
172
+ table_layer : str | None = None ,
172
173
** kwargs : Any ,
173
174
) -> sd .SpatialData :
174
175
"""
@@ -228,6 +229,9 @@ def render_shapes(
228
229
Name of the table containing the color(s) columns. If one name is given than the table is used for each
229
230
spatial element to be plotted if the table annotates it. If you want to use different tables for particular
230
231
elements, as specified under element.
232
+ table_layer: str | None
233
+ Layer of the table to use for coloring if `color` is in :attr:`sdata.table.var_names`. If None, the data in
234
+ :attr:`sdata.table.X` is used for coloring.
231
235
232
236
**kwargs : Any
233
237
Additional arguments for customization. This can include:
@@ -271,6 +275,7 @@ def render_shapes(
271
275
norm = norm ,
272
276
scale = scale ,
273
277
table_name = table_name ,
278
+ table_layer = table_layer ,
274
279
method = method ,
275
280
ds_reduction = kwargs .get ("datashader_reduction" ),
276
281
)
@@ -298,6 +303,7 @@ def render_shapes(
298
303
fill_alpha = param_values ["fill_alpha" ],
299
304
transfunc = kwargs .get ("transfunc" ),
300
305
table_name = param_values ["table_name" ],
306
+ table_layer = param_values ["table_layer" ],
301
307
zorder = n_steps ,
302
308
method = param_values ["method" ],
303
309
ds_reduction = param_values ["ds_reduction" ],
@@ -320,6 +326,7 @@ def render_points(
320
326
size : float | int = 1.0 ,
321
327
method : str | None = None ,
322
328
table_name : str | None = None ,
329
+ table_layer : str | None = None ,
323
330
** kwargs : Any ,
324
331
) -> sd .SpatialData :
325
332
"""
@@ -370,6 +377,9 @@ def render_points(
370
377
Name of the table containing the color(s) columns. If one name is given than the table is used for each
371
378
spatial element to be plotted if the table annotates it. If you want to use different tables for particular
372
379
elements, as specified under element.
380
+ table_layer: str | None
381
+ Layer of the table to use for coloring if `color` is in :attr:`sdata.table.var_names`. If None, the data in
382
+ :attr:`sdata.table.X` is used for coloring.
373
383
374
384
**kwargs : Any
375
385
Additional arguments for customization. This can include:
@@ -403,6 +413,7 @@ def render_points(
403
413
norm = norm ,
404
414
size = size ,
405
415
table_name = table_name ,
416
+ table_layer = table_layer ,
406
417
ds_reduction = kwargs .get ("datashader_reduction" ),
407
418
)
408
419
@@ -433,6 +444,7 @@ def render_points(
433
444
transfunc = kwargs .get ("transfunc" ),
434
445
size = param_values ["size" ],
435
446
table_name = param_values ["table_name" ],
447
+ table_layer = param_values ["table_layer" ],
436
448
zorder = n_steps ,
437
449
method = method ,
438
450
ds_reduction = param_values ["ds_reduction" ],
@@ -573,6 +585,7 @@ def render_labels(
573
585
fill_alpha : float | int = 0.4 ,
574
586
scale : str | None = None ,
575
587
table_name : str | None = None ,
588
+ table_layer : str | None = None ,
576
589
** kwargs : Any ,
577
590
) -> sd .SpatialData :
578
591
"""
@@ -590,10 +603,10 @@ def render_labels(
590
603
The name of the labels element to render. If `None`, all label
591
604
elements in the `SpatialData` object will be used and all parameters will be broadcasted if possible.
592
605
color : list[str] | str | None
593
- Can either be string representing a color-like or key in :attr:`sdata.table.obs`. The latter can be used to
594
- color by categorical or continuous variables. If the color column is found in multiple locations, please
595
- provide the table_name to be used for the element if you would like a specific table to be used. By default
596
- one table will automatically be choosen.
606
+ Can either be string representing a color-like or key in :attr:`sdata.table.obs` or in the index of
607
+ :attr:`sdata.table.var`. The latter can be used to color by categorical or continuous variables. If the
608
+ color column is found in multiple locations, please provide the table_name to be used for the element if you
609
+ would like a specific table to be used. By default one table will automatically be choosen.
597
610
groups : list[str] | str | None
598
611
When using `color` and the key represents discrete labels, `groups` can be used to show only a subset of
599
612
them. Other values are set to NA. The list can contain multiple discrete labels to be visualized.
@@ -626,6 +639,9 @@ def render_labels(
626
639
with the highest resolution is selected. This can lead to long computing times for large images!
627
640
table_name: str | None
628
641
Name of the table containing the color columns.
642
+ table_layer: str | None
643
+ Layer of the AnnData table to use for coloring if `color` is in :attr:`sdata.table.var_names`. If None,
644
+ :attr:`sdata.table.X` of the default table is used for coloring.
629
645
kwargs
630
646
Additional arguments to be passed to cmap and norm.
631
647
@@ -654,6 +670,7 @@ def render_labels(
654
670
palette = palette ,
655
671
scale = scale ,
656
672
table_name = table_name ,
673
+ table_layer = table_layer ,
657
674
)
658
675
659
676
sdata = self ._copy ()
@@ -678,6 +695,7 @@ def render_labels(
678
695
transfunc = kwargs .get ("transfunc" ),
679
696
scale = param_values ["scale" ],
680
697
table_name = param_values ["table_name" ],
698
+ table_layer = param_values ["table_layer" ],
681
699
zorder = n_steps ,
682
700
)
683
701
n_steps += 1
@@ -811,7 +829,6 @@ def show(
811
829
ax_x_min , ax_x_max = ax .get_xlim ()
812
830
ax_y_max , ax_y_min = ax .get_ylim () # (0, 0) is top-left
813
831
814
- # handle coordinate system
815
832
coordinate_systems = sdata .coordinate_systems if coordinate_systems is None else coordinate_systems
816
833
if isinstance (coordinate_systems , str ):
817
834
coordinate_systems = [coordinate_systems ]
0 commit comments