fishtank.seg.assign_spots

Contents

fishtank.seg.assign_spots#

fishtank.seg.assign_spots(spots, polygons, max_dist=5, cell='cell', x='global_x', y='global_y', z=None, polygons_z=None, fov=None)#

Assigns spots to the nearest polygon

Parameters:
  • spots (DataFrame) – a DataFrame of spot coordinates. Can be 2D or 3D.

  • polygons (GeoDataFrame) – a GeoDataFrame of cell outlines. Can be 2D or 3D.

  • max_dist (float | int (default: 5)) – the maximum distance to search for the nearest polygon.

  • cell (str (default: 'cell')) – the name of the cell column in the polygons.

  • x (str (default: 'global_x')) – the name of the x column in the spots.

  • y (str (default: 'global_y')) – the name of the y column in the spots.

  • z (Optional[str] (default: None)) – the name of the z column in the spots. If None, the polygons are assumed to be 2D.

  • polygons_z (Optional[str] (default: None)) – the name of the z column in the polygons. If None, the spots z values will be used.

  • fov (Optional[str] (default: None)) – the name of the fov column in the spots. If None, will do global alignment.

Return type:

DataFrame

Returns:

spots the spots DataFrame with {cell} and {cell}_dist columns added.