@@ -169,6 +169,7 @@ def render_shapes(
169169 scale : float | int = 1.0 ,
170170 method : str | None = None ,
171171 table_name : str | None = None ,
172+ table_layer : str | None = None ,
172173 ** kwargs : Any ,
173174 ) -> sd .SpatialData :
174175 """
@@ -228,6 +229,9 @@ def render_shapes(
228229 Name of the table containing the color(s) columns. If one name is given than the table is used for each
229230 spatial element to be plotted if the table annotates it. If you want to use different tables for particular
230231 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.
231235
232236 **kwargs : Any
233237 Additional arguments for customization. This can include:
@@ -271,6 +275,7 @@ def render_shapes(
271275 norm = norm ,
272276 scale = scale ,
273277 table_name = table_name ,
278+ table_layer = table_layer ,
274279 method = method ,
275280 ds_reduction = kwargs .get ("datashader_reduction" ),
276281 )
@@ -298,6 +303,7 @@ def render_shapes(
298303 fill_alpha = param_values ["fill_alpha" ],
299304 transfunc = kwargs .get ("transfunc" ),
300305 table_name = param_values ["table_name" ],
306+ table_layer = param_values ["table_layer" ],
301307 zorder = n_steps ,
302308 method = param_values ["method" ],
303309 ds_reduction = param_values ["ds_reduction" ],
@@ -320,6 +326,7 @@ def render_points(
320326 size : float | int = 1.0 ,
321327 method : str | None = None ,
322328 table_name : str | None = None ,
329+ table_layer : str | None = None ,
323330 ** kwargs : Any ,
324331 ) -> sd .SpatialData :
325332 """
@@ -370,6 +377,9 @@ def render_points(
370377 Name of the table containing the color(s) columns. If one name is given than the table is used for each
371378 spatial element to be plotted if the table annotates it. If you want to use different tables for particular
372379 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.
373383
374384 **kwargs : Any
375385 Additional arguments for customization. This can include:
@@ -403,6 +413,7 @@ def render_points(
403413 norm = norm ,
404414 size = size ,
405415 table_name = table_name ,
416+ table_layer = table_layer ,
406417 ds_reduction = kwargs .get ("datashader_reduction" ),
407418 )
408419
@@ -433,6 +444,7 @@ def render_points(
433444 transfunc = kwargs .get ("transfunc" ),
434445 size = param_values ["size" ],
435446 table_name = param_values ["table_name" ],
447+ table_layer = param_values ["table_layer" ],
436448 zorder = n_steps ,
437449 method = method ,
438450 ds_reduction = param_values ["ds_reduction" ],
@@ -573,6 +585,7 @@ def render_labels(
573585 fill_alpha : float | int = 0.4 ,
574586 scale : str | None = None ,
575587 table_name : str | None = None ,
588+ table_layer : str | None = None ,
576589 ** kwargs : Any ,
577590 ) -> sd .SpatialData :
578591 """
@@ -590,10 +603,10 @@ def render_labels(
590603 The name of the labels element to render. If `None`, all label
591604 elements in the `SpatialData` object will be used and all parameters will be broadcasted if possible.
592605 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.
597610 groups : list[str] | str | None
598611 When using `color` and the key represents discrete labels, `groups` can be used to show only a subset of
599612 them. Other values are set to NA. The list can contain multiple discrete labels to be visualized.
@@ -626,6 +639,9 @@ def render_labels(
626639 with the highest resolution is selected. This can lead to long computing times for large images!
627640 table_name: str | None
628641 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.
629645 kwargs
630646 Additional arguments to be passed to cmap and norm.
631647
@@ -654,6 +670,7 @@ def render_labels(
654670 palette = palette ,
655671 scale = scale ,
656672 table_name = table_name ,
673+ table_layer = table_layer ,
657674 )
658675
659676 sdata = self ._copy ()
@@ -678,6 +695,7 @@ def render_labels(
678695 transfunc = kwargs .get ("transfunc" ),
679696 scale = param_values ["scale" ],
680697 table_name = param_values ["table_name" ],
698+ table_layer = param_values ["table_layer" ],
681699 zorder = n_steps ,
682700 )
683701 n_steps += 1
@@ -811,7 +829,6 @@ def show(
811829 ax_x_min , ax_x_max = ax .get_xlim ()
812830 ax_y_max , ax_y_min = ax .get_ylim () # (0, 0) is top-left
813831
814- # handle coordinate system
815832 coordinate_systems = sdata .coordinate_systems if coordinate_systems is None else coordinate_systems
816833 if isinstance (coordinate_systems , str ):
817834 coordinate_systems = [coordinate_systems ]
0 commit comments