R/spatialSmoother.R
spatialSmoother.RdSpatial smoother wrapper for SpatialExperiment and SingleCellExperiment objects
spatialSmoother(
object,
reducedDim2smooth = "PhiSpace",
smoothReducedDim = TRUE,
assay2smooth = "logcounts",
smoothedReducedDim = NULL,
smoothedAssay = NULL,
x_coord = NULL,
y_coord = NULL,
k = 10,
kernel = "linear",
sigma = NULL,
include_self = TRUE,
verbose = TRUE
)SpatialExperiment or SingleCellExperiment object
Name of reduced dimension to smooth (default: "PhiSpace")
Logical, whether to smooth reduced dimensions instead of gene expression
Name of assay to smooth (for gene expression smoothing)
Name for the new smoothed reduced dimension (default: paste0(reducedDim2smooth, "_smoothed"))
Name for the new smoothed assay (default: paste0(assay2smooth, "_smoothed"))
Column name in colData for x coordinates (required for SCE objects)
Column name in colData for y coordinates (required for SCE objects)
Number of nearest neighbors (default: 10)
Kernel function: "gaussian", "uniform", or "linear" (default: "gaussian")
Bandwidth parameter for Gaussian kernel (default: auto-computed)
Whether to include the cell itself in smoothing (default: TRUE)
Whether to report progress with message() and show a
progress bar (default: TRUE).
Modified object with new smoothed assay or reduced dimension
set.seed(1)
ref <- logNormTransf(scuttle::mockSCE(ncells = 200, ngenes = 300))
query <- logNormTransf(scuttle::mockSCE(ncells = 100, ngenes = 300))
spe <- SpatialExperiment::SpatialExperiment(
assays = list(logcounts = logcounts(query)),
spatialCoords = cbind(x = runif(100), y = runif(100))
)
spe <- PhiSpace(ref, spe, phenotypes = "Cell_Cycle", refAssay = "logcounts",
ncomp = 3)
spe <- spatialSmoother(spe, k = 5, verbose = FALSE)
reducedDimNames(spe)