spatialProximityScore
spatialProximityScore ¶
spatialProximityScore(
data,
proximity,
scoreBy="imageid",
xCoordinate="X_centroid",
yCoordinate="Y_centroid",
zCoordinate=None,
phenotype="phenotype",
method="radius",
radius=20,
knn=3,
imageId="imageid",
subset=None,
verbose=True,
label="spatial_pscore",
maxWorkers=None,
outputDir=None,
streamData=False,
sdataTable=None,
)
Quantify how much of each image lies in the interaction zone between cell types.
A cell is in the interaction zone when its neighbourhood contains every
phenotype listed in proximity. Two scores summarise that per image:
- Proximity Volume — interaction-zone cells as a fraction of all cells. How much of the tissue is involved.
- Proximity Density — interaction-zone cells as a fraction of the cells of interest only. How much of the relevant population is involved.
The two answer different questions: a sample can have a tiny volume (few Tregs overall) but a high density (nearly every Treg is touching tumour).
Cells are labelled in obs[label] with the joined proximity names or 'other',
and the per-image summary goes to uns[label]. Plot it with
sp.pl.spatialProximityScore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(AnnData | SpatialData | str, required)
|
The cell table. An |
required |
proximity
|
(list, required)
|
The cell types whose interaction is being scored, e.g.
|
required |
scoreBy
|
str
|
Column in |
'imageid'
|
xCoordinate
|
str
|
Column in |
'X_centroid'
|
yCoordinate
|
str
|
Column in |
'Y_centroid'
|
zCoordinate
|
str
|
Column in |
None
|
phenotype
|
str
|
Column in |
'phenotype'
|
method
|
str
|
How neighbourhoods are defined. |
'radius'
|
radius
|
float
|
Neighbourhood radius in the units of the coordinate columns, normally
pixels. Used when |
20
|
knn
|
int
|
Number of nearest neighbours. Used when |
3
|
imageId
|
str
|
Column in |
'imageid'
|
subset
|
str
|
Process only this image. |
None
|
label
|
str
|
Key used for both |
'spatial_pscore'
|
maxWorkers
|
int
|
Cap on parallel workers. Defaults to |
None
|
verbose
|
bool
|
Print progress messages. |
True
|
outputDir
|
str
|
Directory to write the updated object to. With |
None
|
streamData
|
bool
|
Run out of core against an |
False
|
sdataTable
|
str
|
Which |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
adata |
AnnData | SpatialData | None
|
The updated object, with |