troutpy.tl.cell_contacts_with_urna_sources#
- troutpy.tl.cell_contacts_with_urna_sources(sdata, spatial_key='spatial', cell_type_key='cell type', distance=50, copy=False, uns_prefix='cell_contact')#
Compute cell-type x cell-type contact-count matrices based on spatial and uRNA-mediated neighborhoods.
Three matrices are computed:
"cell_body"(cells withindistanceof each other),"combined"(cell-body neighbors plus cells connected via an extracellular transcript whose source cell is not already a spatial neighbor of its target cell), and"urna_specific"(combinedminuscell_body). They are stored insdata["table"].unsunderf"{uns_prefix}_cell_body",f"{uns_prefix}_combined", andf"{uns_prefix}_urna_specific".- Parameters:
sdata (spatialdata.SpatialData) – SpatialData object containing
sdata["table"](AnnData with cell type annotations and spatial coordinates),sdata["target_score"](AnnData withclosest_cellanddistancein.obs), andsdata["source_score"](AnnData withclosest_cellin.obs).spatial_key (str, optional) – Key in
sdata["table"].obsmcontaining spatial coordinates. Defaults to"spatial".cell_type_key (str, optional) – Column in
sdata["table"].obswith cell type labels. Defaults to"cell type".distance (float, optional) – Radius used to define spatial neighborhoods. Defaults to
50.copy (bool, optional) – If
True, return the matrices. Otherwise modifysdatain place and returnNone. Defaults toFalse.uns_prefix (str, optional) – Prefix for the keys under which matrices are saved in
sdata["table"].uns. Defaults to"cell_contact".
- Returns:
dict of pandas.DataFrame or None Dictionary with
"cell_body","combined", and"urna_specific"contact-count DataFrames (cell types x cell types) ifcopy=True; otherwiseNone.