bento.io.prep

bento.io.prep(sdata, points_key='transcripts', feature_key='feature_name', instance_key='cell_boundaries', shape_keys=['cell_boundaries', 'nucleus_boundaries'], instance_map_type='1to1') SpatialData

Computes spatial indices for elements in SpatialData to enable usage of bento-tools.

This function indexes points to shapes, joins shapes to the instance shape, and computes a count table for the points.

Parameters:
  • sdata (SpatialData) – SpatialData object

  • points_key (str, default “transcripts”) – Key for points DataFrame in sdata.points

  • feature_key (str, default “feature_name”) – Key for the feature name in the points DataFrame

  • instance_key (str, default “cell_boundaries”) – Key for the shape that will be used as the instance for all indexing. Usually the cell shape.

  • shape_keys (List[str], default [“cell_boundaries”, “nucleus_boundaries”]) – List of shape names to index points to

  • instance_map_type (str, dict) – Type of mapping to use for the instance shape. If “1to1”, each instance shape will be mapped to a single shape at most. If “1tomany”, each instance shape will be mapped to one or more shapes; multiple shapes mapped to the same instance shape will be merged into a single MultiPolygon. Use a dict to specify different mapping types for each shape.

Returns:

Updated SpatialData object with: - Updated shapes in sdata.shapes[shape_key] with string index - Updated points in sdata.points[points_key] with string index for each shape - New count table in sdata.tables[“table”] - Updated attributes for instance_key and feature_key

Return type:

SpatialData