This method calculates Ripley's reduced second moment function, K(r), for each feature in a spatial grid.

compute_k_ripley(
  object,
  rmax = 80,
  nlarge = 2e+06,
  var.approx = FALSE,
  ratio = FALSE,
  sampling_rate = 0.25,
  seed = 123,
  verbose = TRUE
)

Arguments

object

An object of class "STGrid".

rmax

Maximum desired value of the argument r.

nlarge

Efficiency threshold. If the number of points exceeds nlarge, then only the border correction will be computed (by default), using a fast algorithm.

var.approx

Logical. If TRUE, the approximate variance of K(r) under CSR will also be computed.

ratio

Logical. If TRUE, the numerator and denominator of each edge-corrected estimate will also be saved, for use in analyzing replicated point patterns.

sampling_rate

By default a subset of molecules is sampled. Set sampling_rate to 1 to keep all molecules.

seed

The seed for sampling_rate.

verbose

Whether to print porgress bar.

Value

An updated object of class "STGrid" with the Ripley's K function estimates stored in the slot 'ripley_k_function'.

Examples

example_dataset()
#> |-- INFO :  Dataset 11284233/files/Xenium_Mouse_Brain_Coronal_7g was already loaded. 
Xenium_Mouse_Brain_Coronal_7g <- compute_k_ripley(Xenium_Mouse_Brain_Coronal_7g, verbose=FALSE)
#> |-- INFO :  >>> Estimating Ripley's reduced second moment function for all features.