Here are tutorials covering a few key elements of my work studying spatial relationships between cell types! These workflows are intended for usage with data that A) has spatial X/Y coordinates, and B) has a discrete notion of cell type.
This code was used for my analyses for papers in The Journal for ImmunoTherapy in Cancer, Translational Research and Biomarkers, and Frontiers in Immunology.
Data is the CODEX data used in this paper, split by patient.
We use spatstat to calculate the density of a cell type within a sample, using a fixed grid width so that samples can be compared. Densities can be useful for a lot of downstream analysis; I've used this output to find diagnostically relevant regions using image-based machine learning methods.
In this workflow, we convert our data to a point pattern process (using spatstat), run Gcross, analyze the AUC, and compare the Gcross curve to theoretical.
Using Giotto, an R package intended for spatial -omics data, we identify pairs of cells that tend to cluster together ("enriched" cell pairs) and pairs of cells that tend to be distant from one another ("depleted" cell pairs).