spatialCooccurrence
spatialCooccurrence ¶
spatialCooccurrence(
data,
spatialCooccurrence="spatialCooccurrence",
summarizePlot=True,
pVal=0.05,
rowCluster=False,
colCluster=False,
cmap="vlag",
nonsigColor="grey",
subsetPhenotype=None,
subsetNeighbourPhenotype=None,
binaryView=False,
fileName="spatial_cooccurrence.pdf",
outputDir=None,
saveDir=None,
show=True,
returnData=False,
returnFig=False,
dpi=300,
transparent=False,
sdataTable=None,
**kwargs
)
Co-occurrence heatmap: which cell types sit next to which, more than chance.
Reads the long-format table that
sp.tl.spatialCooccurrence writes to
uns[spatialCooccurrence] — phenotype, neighbour_phenotype, one score
column per image and one pvalue_<image> column per image — and pivots it into
a matrix. Pairs whose p-value is at or above pVal are drawn in nonsigColor
rather than on the colour scale, so only the significant structure carries
colour.
For backward compatibility, a uns value that is already a
phenotype x neighbour_phenotype matrix is plotted as-is, with no significance
masking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(AnnData | SpatialData | str, required)
|
The cell table. An |
required |
spatialCooccurrence
|
str
|
Key in |
'spatialCooccurrence'
|
summarizePlot
|
bool
|
|
True
|
pVal
|
float
|
Significance threshold for the greying-out. |
0.05
|
rowCluster
|
bool
|
Accepted for signature compatibility with scimap; rows are not
reordered. Use |
False
|
colCluster
|
bool
|
Accepted for signature compatibility with scimap; see |
False
|
cmap
|
str
|
Matplotlib colormap. |
'vlag'
|
nonsigColor
|
str
|
Colour for pairs that fail the |
'grey'
|
subsetPhenotype
|
str | list
|
Keep only these phenotypes as rows. |
None
|
subsetNeighbourPhenotype
|
str | list
|
Keep only these phenotypes as columns. |
None
|
binaryView
|
bool
|
Reduce the scores to their sign — attraction, avoidance — instead of their magnitude. |
False
|
**kwargs
|
dict
|
Extra options. |
{}
|
fileName
|
str
|
File name for the saved figure. The extension decides the format. |
'spatial_cooccurrence.pdf'
|
outputDir
|
str
|
Directory to save the figure in. When |
None
|
saveDir
|
str
|
Deprecated alias for |
None
|
show
|
bool
|
Call |
True
|
returnData
|
bool
|
Return the |
False
|
returnFig
|
bool
|
Return |
False
|
dpi
|
int
|
Resolution of the saved figure. |
300
|
transparent
|
bool
|
Save with a transparent background. |
False
|
sdataTable
|
str
|
Which |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
None | DataFrame | tuple
|
|