rapids_singlecell.gr.ripley#
- rapids_singlecell.gr.ripley(adata, cluster_key, *, mode='F', spatial_key='spatial', metric='euclidean', n_neigh=2, n_simulations=100, n_observations=1000, max_dist=None, n_steps=50, rng=None, copy=False, table_key=None)[source]#
Calculate Ripley’s statistics for point processes.
GPU port of
squidpy.gr.ripley(). Depending onmode, it computes Ripley’s'F','G'or'L'statistic per cluster and compares it to simulated Spatial Poisson Point Processes on the convex hull of all observations.'F'and'G'are defined aswhere are the distances from random points of a Spatial Poisson Point Process (
'F') or from points of other clusters ('G') to theirn_neighnearest points of the cluster.'L'stabilizes the variance ofas .
- Parameters:
- adata
AnnData|SpatialData Annotated data matrix or a SpatialData object containing the selected table.
- cluster_key
str Key in
anndata.AnnData.obswith the cluster labels.- mode
Literal['F','G','L'] (default:'F') Which Ripley’s statistic to compute.
- spatial_key
str(default:'spatial') Key in
anndata.AnnData.obsmwith the 2D spatial coordinates.- metric
str(default:'euclidean') Distance metric. Only
'euclidean'is supported.- n_neigh
int(default:2) Number of nearest neighbors whose distances enter
'F'and'G'.- n_simulations
int(default:100) How many simulations to run for computing p-values.
- n_observations
int(default:1000) How many observations to generate for each Spatial Poisson Point Process.
- max_dist
float|None(default:None) Maximum distance of the support. If
None,max_distis of the convex hull.- n_steps
int(default:50) Number of steps of the support.
- rng
int|Generator|None(default:None) Seed or
numpy.random.Generatorthat seeds the GPU random number generator for the simulated point processes.- copy
bool(default:False) If
True, return the result, otherwise save it toadata.- table_key
str|None(default:None) Key in
SpatialData.tables; required for SpatialData input. All reads and writes use this table; ignored for AnnData input.
- adata
- Return type:
- Returns:
If
copy = True, returns adictwith the following keys:'{mode}_stat'-pandas.DataFramewith the statistic per cluster and bin.'sims_stat'-pandas.DataFramewith the statistic per simulation and bin.'bins'- the support of the statistic.'pvalues'- p-values of shape(n_clusters, n_steps).
Otherwise, modifies the
adatawith the following key:anndata.AnnData.uns['{cluster_key}_ripley_{mode}']- the above mentioneddict.
Notes
Distances for
'F'and'G'are exact in double precision.'L'counts pairs in single precision around the centroid of the coordinates, so pairs within rounding error of a support value may land in the neighboring bin. Random points are drawn on the GPU, so simulations do not reproducesquidpy.gr.ripley()for the samerng.