troutpy.tl.in_out_correlation#
- troutpy.tl.in_out_correlation(sdata, extracellular_layer='segmentation_free_table', cellular_layer='table', n_neighbors=5, copy=None)#
Compute the correlation between intracellular and extracellular gene expression.
For each cell, extracellular expression is aggregated as the mean over its
n_neighborsnearest extracellular bins, then correlated (Spearman) against the cell’s intracellular expression for each shared gene. Results are stored insdata["xrna_metadata"].var["in_out_spearmanR"]andsdata["xrna_metadata"].var["in_out_pvalue"].- Parameters:
sdata (
SpatialData) – SpatialData object containing both the extracellular and cellular AnnData tables.extracellular_layer (
str(default:'segmentation_free_table')) – Key of the extracellular AnnData table insdata.cellular_layer (
str(default:'table')) – Key of the cellular AnnData table insdata.n_neighbors (
int(default:5)) – Number of nearest extracellular bins to aggregate per cell.copy (
Optional[bool] (default:None)) – IfTrue, return a modified copy ofsdata. Otherwise modify in place.
- Return type:
- Returns:
If
copy=True, a modified copy ofsdata. OtherwiseNone, modifyingsdatain place.