neighNMF
neighNMF ¶
neighNMF(
data,
xCoordinate="X_centroid",
yCoordinate="Y_centroid",
zCoordinate=None,
phenotype="phenotype",
method="radius",
radius=30,
knn=10,
imageId="imageid",
subset=None,
verbose=True,
label="neighNMF",
maxWorkers=None,
outputDir=None,
streamData=False,
inferenceMode="phenotype_driven",
layer=None,
subsetMarker=None,
nmfComponents=5,
nmfRandomState=0,
sdataTable=None,
)
Non-negative matrix factorisation of neighbourhood composition.
Builds the same cell x category neighbourhood matrix as
sp.tl.neighCount, then factorises it into
nmfComponents parts. Each cell gets a weight per component, and each component
is a recognisable mixture of cell types — so a cell can sit partly in two
neighbourhoods, which k-means cannot express.
Only the factorisation is kept: uns[label] holds the cell factors and
uns[label + "_nmf_components"] the component definitions. The full
neighbourhood matrix is discarded, which keeps the object small on big slides —
run sp.tl.neighCount as well if you want it.
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
|
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
|
Key in |
'neighNMF'
|
maxWorkers
|
int
|
Cap on parallel workers. Defaults to |
None
|
inferenceMode
|
str
|
|
'phenotype_driven'
|
layer
|
str
|
Which matrix to read for |
None
|
subsetMarker
|
list
|
Restrict |
None
|
nmfComponents
|
int
|
Number of components to factor into. The main thing to tune. |
5
|
nmfRandomState
|
int
|
Seed for the NMF initialisation. |
0
|
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 |