Preprocessing (.pp)#

class spatialdata_plot.pp.basic.PreprocessingAccessor(sdata)#

Preprocessing functions for SpatialData objects.

Parameters:

sdata (SpatialData) – A spatial data object.

get_bb(x=(0, 0), y=(0, 0))#

Get bounding box around a point.

Parameters:
  • x (Union[slice, list[int], tuple[int, int]] (default: (0, 0))) – x range of the bounding box. Stepsize will be ignored if slice

  • y (Union[slice, list[int], tuple[int, int]] (default: (0, 0))) – y range of the bounding box. Stepsize will be ignored if slice

Return type:

SpatialData

Returns:

sd.SpatialData subsetted SpatialData object

get_elements(elements)#

Get a subset of the spatial data object by specifying elements to keep.

Parameters:

elements (Union[str, list[str]]) –

A string or a list of strings specifying the elements to keep. Valid element types are:

  • ’coordinate_systems’

  • ’images’

  • ’labels’

  • ’shapes’

Return type:

SpatialData

Returns:

sd.SpatialData A new spatial data object containing only the specified elements.

Raises:
  • TypeError – If elements is not a string or a list of strings. If elements is a list of strings but one or more of the strings are not valid element types.

  • ValueError – If any of the specified elements is not present in the original spatialdata object.

  • AssertionError – If label_keys is not an empty list but the spatial data object does not have a table or the table does not have ‘uns’ or ‘obs’ attributes.

Notes

If the original spatialdata object has a table, and elements includes label keys, the returned spatialdata object will have a subset of the original table with only the rows corresponding to the specified label keys. The region attribute of the returned spatial data object’s table will be set to the list of specified label keys.

If the original spatial data object has no table, or if elements does not include label keys, the returned spatialdata object will have no table.

property sdata: SpatialData#

The SpatialData object to provide preprocessing functions for.