troutpy.pp.cosmx_converter

troutpy.pp.cosmx_converter#

troutpy.pp.cosmx_converter(sdata, copy_data=False)#

Convert a CosMx multi-FOV SpatialData object into a unified single-coordinate-system object.

Stitches image and label tiles, concatenates transcript tiles, remaps all per-FOV cell IDs to globally unique integers, and repacks the result into a standard SpatialData structure with a single image, label, points, shapes, and table layer.

Parameters:
  • sdata (spatialdata.SpatialData) – Raw CosMx SpatialData object with per-FOV images, labels, points, and a "table" AnnData. The table’s obs must contain "fov" and "cell_ID" columns for cell ID remapping.

  • copy_data (bool, optional) – If True, operate on a deep copy of sdata and return it. Otherwise modify in place and return None. Defaults to False.

Return type:

SpatialData

Returns:

spatialdata.SpatialData or None Converted SpatialData object if copy_data=True; otherwise None.

Raises:

ValueError – If sdata.table.obs does not contain a "fov" column required for cell ID remapping.