Analysis of cell proximity using random walk expected hitting time.
This is not yet a registered package, so for now, clone this repo somewhere then, run in the julia repl
]dev /path/to/Stepwell
using Muon, Stepwell
# Read dataset on AnnData format
adata = readh5ad("spatial-data.h5ad")
# Build a neighborhood graph
G = CellularNeighborhoodGraph(adata)
# Define some subset of cells that we wish to measure proximity to
absorbing_cells = adata.obs.celltype .== "Tumor"
# Measure expected random walk lengths from each cell
eat = expected_absorption_time(G, absorbing_cells)
# Measure expected absorption time normalized for local cell type composition.
# `k` here determines the spatial scale at which we are normalizing for local
# cell type composition. If `k` is small we are measuring highly specific co-location,
# if `k` is large we are measuring broader co-location.
normalized_eat = normalized_expected_absorption_time(G, absorbing_cells, k=100)Consider the graph
We only consider (in the local_shuffled_expected_absorption_time function)
proximity normalized for local cell type composition to measure true
co-location, independent of incidental co-location that occurs purely to due
abundance of particular cell types. This works by first sending the cell