troutpy.tl.factors_to_cells#
- troutpy.tl.factors_to_cells(sdata, extracellular_layer='segmentation_free_table', cellular_layer='table', copy=None)#
Project extracellular-RNA factor loadings onto the cellular table for shared genes.
Intersects the gene annotations between the extracellular and cellular tables, and multiplies the cellular expression matrix by the (gene-subset) factor loadings to obtain per-cell factor scores.
- Parameters:
sdata (spatialdata.SpatialData) – SpatialData object containing both the extracellular and cellular tables.
extracellular_layer (str, optional) – Key in
sdatafor the extracellular table with NMF/LDA/DRVI gene loadings in.varm["gene_loadings"]. Defaults to"segmentation_free_table".cellular_layer (str, optional) – Key in
sdatafor the cellular table to annotate. Defaults to"table".copy (bool, optional) – If truthy, return the modified SpatialData object; otherwise modify
sdatain place and returnNone.
- Return type:
- Returns:
spatialdata.SpatialData or None
sdatawithsdata[cellular_layer].obsm["factors_cell_loadings"]set to the per-cell factor scores (restricted to genes shared withextracellular_layer) ifcopyis truthy; otherwiseNone.