troutpy.pp.aggregate_urna

Contents

troutpy.pp.aggregate_urna#

troutpy.pp.aggregate_urna(sdata, layer='transcripts', gene_key='gene', method='bin', square_size=50, radius=50, knn_k=5, extracellular_only=True, copy=False, key_added=None, cell_type_key='leiden', embedding_enabled=True, fragment_k=5, fragment_dist_thresh=7.0, fragment_sim_thresh=0.5)#

Aggregate urna transcript counts into a grid of squares.

Parameters:
  • sdata (SpatialData) – The spatial data object.

  • layer (str (default: 'transcripts')) – The key to access transcript coordinates in sdata.

  • gene_key (str (default: 'gene')) – Column name where the gene assigned to each transcript is stored.

  • method (str (default: 'bin')) – Aggregation strategy. Options: “bin”, “radius”, “knn”, “local_maxima”

  • square_size (float (default: 50)) – Size of each square grid bin (used for “bin” and “local_maxima” methods).

  • radius (float (default: 50)) – Radius for aggregating neighboring transcripts (used for “radius” and “local_maxima”).

  • knn_k (int (default: 5)) – Number of nearest neighbors (used for the “knn” method).

  • overlap_bin – (Not used in the “bin” method, but available for future updates.)

  • local_maxima_threshold – Minimum count threshold for a grid cell to be accepted as a local maximum.

  • extracellular_only (bool (default: True)) – If True (default), only uses extracellular transcripts.

  • copy (bool (default: False)) – If True, returns a new SpatialData object; otherwise, sdata is modified in place.

  • key_added (Optional[str] (default: None)) – Key under which aggregated results are stored. Defaults to ‘segmentation_free_table’ if not provided.

  • cell_type_key (str) – Cell type key in sdata[‘table’] to use for fragment embedding, if semected

  • embedding_enabled (bool) – Wether to compute gene embeddings for the fragments method

  • fragment_k (int) – Number of neighbors for spatial knn to be used in fragments method

  • fragment_dist_thresh (int) – Maximum distance to be used to connect RNA fragments in the space

  • fragment_sim_thresh (float) – Fragment similarity threshold used to connect fragments by gene expression similarity.

Returns:

sdata or None If copy is True, returns a new SpatialData object; otherwise, returns None.