troutpy.tl.compute_contribution_score

troutpy.tl.compute_contribution_score#

troutpy.tl.compute_contribution_score(sdata)#

Compute a normalised extracellular RNA (uRNA) contribution score for each cell.

For each gene, a cell’s contribution is weighted by the total extracellular count of that gene divided by the number of cells expressing it. Scores are summed across genes and also normalised by each cell’s total raw expression. Results are written to sdata["table"].obs.

Parameters:

sdata (spatialdata.SpatialData) – SpatialData object containing a "table" AnnData (with a "raw" layer) and an "xrna_metadata" table whose var DataFrame includes a "count" column with per-gene extracellular transcript counts.

Returns:

None Scores are added in place to sdata["table"].obs as "urna_contribution_score" and "normalized_urna_contribution_score".

Raises:

ValueError – If no common genes are found between the cell table and the gene metadata.