Spatially-aware subsampling of SpatialExperiment objects

spatialSampler(
  spe,
  prop = 0.1,
  method = "grid",
  grid_size = NULL,
  seed = 123,
  min_cells_per_region = 1,
  balance_regions = FALSE
)

Arguments

spe

SpatialExperiment object

prop

Proportion of cells to sample (between 0 and 1)

method

Sampling method: "grid", "kmeans", or "random" (default: "grid")

grid_size

Number of grid cells per dimension for grid method (default: auto-calculated)

seed

Random seed for reproducibility (default: 123)

min_cells_per_region

Minimum cells required per spatial region (default: 1)

balance_regions

Whether to balance sampling across spatial regions (default: FALSE; if true, might create duplicated spatial units)

Value

Subsampled SpatialExperiment object