spatialAggregate
spatialAggregate ¶
spatialAggregate(
data,
xCoordinate="X_centroid",
yCoordinate="Y_centroid",
zCoordinate=None,
purity=60,
phenotype="phenotype",
method="radius",
radius=30,
knn=10,
imageId="imageid",
subset=None,
verbose=True,
label="spatialAggregate",
outputDir=None,
maxWorkers=None,
streamData=False,
sdataTable=None,
)
Find local aggregates of a single cell type.
For every cell, look at its neighbourhood and take the most common phenotype
there. When that phenotype accounts for at least purity percent of the
neighbourhood, the cell is labelled with it; otherwise it is labelled
'non-significant'. The result is a map of where each cell type forms
coherent patches rather than scattered individuals.
purity is the knob that matters: at 60 you get generous, contiguous regions;
at 90 only dense cores survive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(AnnData | SpatialData | str, required)
|
The cell table. An |
required |
xCoordinate
|
str
|
Column in |
'X_centroid'
|
yCoordinate
|
str
|
Column in |
'Y_centroid'
|
zCoordinate
|
str
|
Column in |
None
|
purity
|
int
|
Minimum percentage of the neighbourhood that the dominant phenotype must occupy for a cell to be labelled. Between 1 and 100. |
60
|
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 |
30
|
knn
|
int
|
Number of nearest neighbours. Used when |
10
|
imageId
|
str
|
Column in |
'imageid'
|
subset
|
str
|
Process only this image. |
None
|
label
|
str
|
Column in |
'spatialAggregate'
|
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 |