troutpy.tl.segmentation_free_clustering

troutpy.tl.segmentation_free_clustering#

troutpy.tl.segmentation_free_clustering(sdata, params=None, layer='transcripts', coord_keys=None, gene_key='feature_name', method='points2regions', transcript_id_key='transcript_id_key', copy=False)#

Cluster transcripts without relying on pre-defined cell or tissue segmentations.

Supports multiple segmentation-free clustering methods, with Points2Regions being the default.

Parameters:
  • sdata (spatialdata.SpatialData) – A spatial data object containing transcriptomic information.

  • params (dict, optional) – Parameters for the selected clustering method. For method="points2regions" this must contain "num_clusters", "pixel_width", and "pixel_smoothing".

  • layer (str, optional) – Key of the points layer in sdata containing the transcripts to cluster. Defaults to "transcripts".

  • coord_keys (list of str, optional) – Names of the x- and y-coordinate columns in sdata.points[layer]. Defaults to ["x", "y"].

  • gene_key (str, optional) – Column name holding the gene/feature assigned to each transcript.

  • method (str, optional) –

    Clustering method to use. Options:

    • "points2regions": cluster using the Points2Regions algorithm (default).

    • "sainsc": not yet implemented.

  • transcript_id_key (str, optional) – Column name holding the transcript IDs.

  • copy (bool, optional) – If True, return the resulting AnnData object. Otherwise update sdata in place and return None.

Returns:

anndata.AnnData or None Clustering-result AnnData (also stored as sdata["segmentation_free_table"]) if copy=True; otherwise None.