R/computation.R
computeBanksy.Rd
Compute the component neighborhood matrices for the BANKSY matrix.
computeBanksy(
se,
assay_name,
coord_names = NULL,
compute_agf = FALSE,
k_geom = 15,
spatial_mode = c("kNN_median", "kNN_r", "kNN_rn", "kNN_rank", "kNN_unif", "rNN_gauss"),
n = 2,
sigma = 1.5,
alpha = 0.05,
k_spatial = 100L,
M = NULL,
sample_size = NULL,
sample_renorm = TRUE,
seed = NULL,
dimensions = "all",
center = TRUE,
verbose = TRUE
)
A SpatialExperiment
,
SingleCellExperiment
or SummarizedExperiment
object. If not a SpatialExperiment object, argument coord_names
must be provided.
A string scalar specifying the name of the assay to use.
A string vector specifying the names in colData
corresponding to spatial coordinates.
A logical scalar specifying whether to compute the AGF.
An integer scalar specifying the number of neighbors to use. Values \(\in [15,30]\) work well.
A string scalar specifying the kernel for neighborhood computation (default: kNN_median).
kNN_median: k-nearest neighbors with median-scaled Gaussian kernel
kNN_r: k-nearest neighbors with $1/r$ kernel
kNN_rn: k-nearest neighbors with $1/r^n$ kernel
kNN_rank: k-nearest neighbors with rank Gaussian kernel
kNN_unif: k-nearest neighbors wth uniform kernel
rNN_gauss: radial nearest neighbors with Gaussian kernel
A numeric scalar specifying the exponent of radius (for kNN_rn).
A numeric scalar specifying the std. dev. of Gaussian kernel (for rNN_gauss).
A numeric scalar specifying the radius used: larger alphas give smaller radii (for rNN_gauss).
An integer scalar specifying the initial number of neighbors to use (for rNN_gauss)
Advanced usage. A integer scalar specifying the highest azimuthal
Fourier harmonic to compute. If specified, overwrites the use_agf
argument.
An integer scalar number of neighbors to sample from the neighborhood.
A logical scalar specifying whether to renormalize the neighbor weights to 1.
An integer scalar specifying seed for sampling the neighborhood.
A character vector specifying the dimensions to use when computing neighborhood.
subset of colnames of cell.locs
allUses all colnames of spatialCoords to compute (default)
A logical scalar specifying whether to center higher order harmonics in local neighborhoods.
A logical scalar specifying verbosity.
A SpatialExperiment / SingleCellExperiment / SummarizedExperiment object with neighborhood matrices added.
Given an expression matrix (as specified by assay_name
), this function
computes the mean neighborhood matrix (H0
) and optionally, the
azimuthal Gabor filter (AGF) matrix (H1
). The number of neighbors
used to define the spatial neighborhood is given by k_geom
.
Different kernels may be used to compute the neighborhood features,
specified by spatial_mode
.
data(rings)
spe <- computeBanksy(rings, assay_name = "counts", M = 1, k_geom = c(15, 30))
#> Computing neighbors...
#> Spatial mode is kNN_median
#> Parameters: k_geom=15
#> Done
#> Computing neighbors...
#> Spatial mode is kNN_median
#> Parameters: k_geom=30
#> Done
#> Computing harmonic m = 0
#> Using 15 neighbors
#> Done
#> Computing harmonic m = 1
#> Using 30 neighbors
#> Centering
#> Done