The function sweeps over circles of a range of radii surrounding reference cells and calculates the metrics at the radii. Metrics used with function need two conditions: 1) have a `radius` parameter. 2) return a single number. For metrics that do not return a single number, users can wrap them in a new function that returns a number and then pass the new function to `compute_gradient()`.
compute_gradient(spe_object, radii, FUN, ...)
SpatialExperiment object in the form of the output of
format_image_to_spe
.
Numeric Vector specifying the range of radii for the metrics to be calculated.
Variable name specifying the metric.
Arguments of FUN
A list of the metrics under all radii
gradient_positions <- c(30, 50, 100)
gradient_entropy <- compute_gradient(SPIAT::defined_image,
radii = gradient_positions, FUN = calculate_entropy,
cell_types_of_interest = c("Immune1","Immune2"),
feature_colname = "Cell.Type")