troutpy.tl.factors_to_cells#
- troutpy.tl.factors_to_cells(sdata, extracellular_layer='segmentation_free_table', cellular_layer='table', copy=None)#
Extracts extracellular RNA data and associated NMF factor loadings, intersects the gene annotations between the extracellular data and the cellular data, and applies the NMF factors to annotate the cellular data with exRNA-related factors.
- Parameters:
sdata (spatialdata.SpatialData) – The AnnData object containing both extracellular and cellular data.
layer_factors (str) – The key in
sdatathat contains the extracellular RNA data with NMF factors. Default is ‘nmf_data’.copy (bool) – Wether to save the
sdataobject in a separate object
- Return type:
- Returns:
sdata The updated
sdataobject with annotated cellular data that includes the applied exRNA factors as new columns.
Notes
The function assumes that the extracellular RNA data is stored in
sdata[layer_factors]and that the NMF factor loadings are stored in theunsattribute of the extracellular dataset as ‘H_nmf’. The factor scores are added to theobsattribute of the cellular data.