SpatialDE.spatial_patterns
- SpatialDE.spatial_patterns(adata, genes=None, normalized=False, spatial_key='spatial', layer=None, params=SpatialPatternParameters(), rng=np.random.default_rng(), copy=False)
Detect spatial patterns of gene expression and assign genes to patterns.
Uses a Gaussian process mixture. A Dirichlet process prior allows to automatically determine the number of distinct regions in the dataset.
- Parameters:
adata (
AnnData) – The annotated data matrix.genes (
Optional[List[str]]) – List of genes to base the analysis on. Defaults to all genes.normalized – Whether the data are already normalized to an approximately Gaussian likelihood. If
False, they will be normalized using the workflow from Svensson et al, 2018.spatial_key – Key in
adata.obsmwhere the spatial coordinates are stored.layer (
Optional[str]) – Name of the AnnData object layer to use. By defaultadata.Xis used.params (
SpatialPatternParameters) – Parameters for the algorithm, e.g. prior distributions, spatial smoothness, etc.rng (
Generator) – Random number generator.copy (
bool) – Whether to return a copy ofadatawith results or write the results intoadatain-place.
- Return type:
Tuple[SpatialPatterns,Optional[AnnData]]- Returns:
A tuple. The first element is a
SpatialPatterns, the second isNoneifcopy == Falseor anAnnDataobject. Patterns will be inadata.obs["spatial_pattern_0"], …,adata.obs["spatial_pattern_n"].