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”, “fragments”.square_size (
float(default:50)) – Size of each square grid bin (used for the “bin” method).radius (
float(default:50)) – Radius for aggregating neighboring transcripts (used for the “radius” method).knn_k (
int(default:5)) – Number of nearest neighbors (used for the “knn” method).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(default:'leiden')) – Cell type key in sdata[‘table’] to use for gene embeddings (used for the “fragments” method).embedding_enabled (
bool(default:True)) – Whether to compute gene embeddings for the “fragments” method.fragment_k (
int(default:5)) – Number of spatial nearest neighbors considered when linking transcripts into fragments (used for the “fragments” method).fragment_dist_thresh (
float(default:7.0)) – Maximum distance between transcripts to be connected into the same fragment (used for the “fragments” method).fragment_sim_thresh (
float(default:0.5)) – Minimum gene-embedding cosine similarity for two transcripts to be connected into the same fragment (used for the “fragments” method).
- Returns:
sdata or None If copy is True, returns a new SpatialData object; otherwise, returns None.