scimap.tl.spatial_interaction
Function Call
scimap.tl.spatial_interaction
(
adata,
x_coordinate='X_centroid',
y_coordinate='Y_centroid',
phenotype='phenotype',
method='radius', radius=30, knn=10,
permutation=1000,
imageid='imageid',subset=None,
pval_method='histocat',
label='spatial_interaction')
Short description
The spatial_interaction
function enables the unbiased and systematic study of all
cell–cell interactions present in a tissue or all tissues of a sample cohort by using a
permutation test to compare the number of interactions between all cell types in a given image
to that of a matched control containing randomized cell phenotypes. This approach determines
the significance of cell–cell interactions and reveals enrichments or depletions
in cell–cell interactions that are indicative of cellular organization.
The function supports two methods to define a local neighbourhood
Radius method: Can be used to identifies the neighbours within a user defined radius for every cell.
KNN method: Can be used to identifies the neighbours based on K nearest neigbours for every cell
The resultant proportion matrix is saved with adata.uns
.
Parameters
adata
: AnnData Object
x_coordinate
: float, required (The default is 'X_centroid')
Column name containing the x-coordinates values.
y_coordinate
: float, required (The default is 'Y_centroid')
Column name containing the y-coordinates values.
phenotype
: string, required (The default is 'phenotype')
Column name of the column containing the phenotype information. It could also be any categorical assignment given to single cells.
method
: string, optional (The default is 'radius')
Two options are available: a) 'radius', b) 'knn'.
a) radius - Identifies the neighbours within a given radius for every cell.
b) knn - Identifies the K nearest neigbours for every cell.
radius
: int, optional (The default is 30)
The radius used to define a local neighbhourhood.
knn
: int, optional (The default is 10)
Number of cells considered for defining the local neighbhourhood.
permutation
: int, optional (The default is 1000)
The number of permutations to be performed for calculating the P-Value.
pval_method
: string, optional (The default is 'histocat')
Two options are available: a) 'histocat', b) 'zscore'.
a) P-values are calculated by subtracting the permuted mean from the observed mean
divided by the number of permutations as described in the histoCAT manuscript (Denis et.al, Nature Methods 2017)
b) zscores are calculated from the mean and standard deviation and further p-values
are derived by fitting the observed values to a normal distribution.
imageid
: string, optional (The default is 'imageid')
Column name of the column containing the image id.
subset
: string, optional (The default is None)
imageid of the image to be subsetted for analyis.
label
: string, optional (The default is 'spatial_interaction')
Key for the returned data, stored in adata.uns
.
Returns
AnnData
object with the results stored in adata.uns['spatial_interaction']
.
Example
# Using the radius method to identify local neighbours and histocat to compute P-values
adata = sm.tl.spatial_interaction(adata, method='radius', radius=30,pval_method='histocat',
imageid='ImageId',x_coordinate='X_position',y_coordinate='Y_position')
# Using the KNN method to identify local neighbours and zscore to compute P-values
adata = sm.tl.spatial_interaction(adata, method='knn', radius=30,pval_method='zscore',
imageid='ImageId',x_coordinate='X_position',y_coordinate='Y_position')