compute_gradient: compute_gradient

View source: R/compute_gradient.R

compute_gradientR Documentation

compute_gradient

Description

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()'.

Usage

compute_gradient(spe_object, radii, FUN, ...)

Arguments

spe_object

SpatialExperiment object in the form of the output of format_image_to_spe.

radii

Numeric Vector specifying the range of radii for the metrics to be calculated.

FUN

Variable name specifying the metric.

...

Arguments of FUN

Value

A list of the metrics under all radii

Examples

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")

TrigosTeam/SPIAT documentation built on Aug. 22, 2024, 7:50 p.m.