computeBanksy: Compute the component neighborhood matrices for the BANKSY...

View source: R/computation.R

computeBanksyR Documentation

Compute the component neighborhood matrices for the BANKSY matrix.

Description

Compute the component neighborhood matrices for the BANKSY matrix.

Usage

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
)

Arguments

se

A SpatialExperiment, SingleCellExperiment or SummarizedExperiment object. If not a SpatialExperiment object, argument coord_names must be provided.

assay_name

A string scalar specifying the name of the assay to use.

coord_names

A string vector specifying the names in colData corresponding to spatial coordinates.

compute_agf

A logical scalar specifying whether to compute the AGF.

k_geom

An integer scalar specifying the number of neighbors to use. Values \in [15,30] work well.

spatial_mode

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

n

A numeric scalar specifying the exponent of radius (for kNN_rn).

sigma

A numeric scalar specifying the std. dev. of Gaussian kernel (for rNN_gauss).

alpha

A numeric scalar specifying the radius used: larger alphas give smaller radii (for rNN_gauss).

k_spatial

An integer scalar specifying the initial number of neighbors to use (for rNN_gauss)

M

Advanced usage. A integer scalar specifying the highest azimuthal Fourier harmonic to compute. If specified, overwrites the use_agf argument.

sample_size

An integer scalar number of neighbors to sample from the neighborhood.

sample_renorm

A logical scalar specifying whether to renormalize the neighbor weights to 1.

seed

An integer scalar specifying seed for sampling the neighborhood.

dimensions

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)

center

A logical scalar specifying whether to center higher order harmonics in local neighborhoods.

verbose

A logical scalar specifying verbosity.

Details

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.

Value

A SpatialExperiment / SingleCellExperiment / SummarizedExperiment object with neighborhood matrices added.

Examples

data(rings)
spe <- computeBanksy(rings, assay_name = "counts", M = 1, k_geom = c(15, 30))


prabhakarlab/Banksy documentation built on April 11, 2024, 2:45 p.m.