Skip to contents

Compute SE abundances within spatial neighborhoods (SNs)

Usage

ComputeSEAbundanceBySN(
  df,
  spot_coords = NULL,
  radius = 50,
  grid.size = 50,
  k = min(200, nrow(df)),
  X = "X",
  Y = "Y",
  SE = "SE",
  min.cells = 5
)

Arguments

df

data.frame, one row per single cell, with at least columns X, Y (spatial coordinates) and SE.

spot_coords

data.frame of SN centers with columns X, Y (rownames = SN IDs). If NULL, a regular grid of spatial neighborhoods is generated automatically, spaced `grid.size` apart.

radius

numeric, radius defining the SN (cells within this distance of a SN center are included).

grid.size

numeric, spacing between adjacent SN centers when `spot_coords` is auto-generated.

X, Y, SE

column names in `df` for x-coord, y-coord, and SE label.

min.cells

minimum number of cells required within a SN for it to be kept in the output.

Value

A data frame with the first two columns containing spatial coordinates of SNs, followed by columns containing SE abundances.