ripley_test
Run a Ripley alphabet test on a GeoDataFrame.
Simulates a random poisson point process and computes the Ripley alphabet function values for both the observed pattern and the simulated patterns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame containing the segmented objects. |
required |
distances
|
ndarray
|
An array of distances at which to compute the Ripley alphabet function. |
required |
ripley_alphabet
|
str
|
The Ripley alphabet statistic to compute. Must be one of "k", "g", or "l". |
'g'
|
n_sim
|
int
|
The number of simulations to perform for the random point process. |
100
|
hull_type
|
str
|
The type of hull to use for the Ripley test. Options are "convex_hull", "alpha_shape", "ellipse", or "bbox". |
'bbox'
|
Returns:
Type | Description |
---|---|
tuple[ndarray, ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing: - ripley_stat: The observed Ripley alphabet function values. - sims: An array of simulated Ripley alphabet function values. - pvalues: An array of p-values for the observed Ripley alphabet function values. |
Examples:
>>> from histolytics.data import hgsc_cancer_nuclei
>>> from histolytics.spatial_clust.ripley import ripley_test
>>> import numpy as np
>>>
>>> # Load the HGSC cancer nuclei dataset
>>> nuc = hgsc_cancer_nuclei()
>>> neo = nuc[nuc["class_name"] == "neoplastic"]
>>>
>>> distances = np.linspace(0, 100, 10)
>>>
>>> # Run the Ripley G test for the neoplastic nuclei
>>> ripley_stat, sims, pvalues = ripley_test(
... neo,
... distances=distances,
... ripley_alphabet="g",
... n_sim=100,
... hull_type="bbox",
... )
>>>
>>> print(pvalues)
[0. 0. 0. 0.00990099 0.00990099 0.01980198
0.04950495 0.0990099 0.17821782 0. ]
Source code in src/histolytics/spatial_clust/ripley.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|