Skip to contents

Use the optional semla package as a backend to prepare a Staffli-enabled Seurat object and compute spot-level spatial networks. The network is stored in srt@tools[[tool_name]] when store_results = TRUE. SCOP provides no dedicated plot for this result; retrieve it with GetSpatialResult() and use an existing generic spatial plot when needed.

Usage

RunSemlaSpatialNetwork(
  srt,
  image_type = "tissue_lowres",
  nNeighbors = 6,
  maxDist = NULL,
  minK = 0,
  coords = "pixels",
  tool_name = "SemlaSpatialNetwork",
  store_results = TRUE,
  verbose = TRUE,
  ...
)

Arguments

srt

A Seurat object with spatial image data.

image_type

Image scale used by semla::UpdateSeuratForSemla() when the object does not already contain a Staffli object.

nNeighbors

Number of nearest spatial neighbors.

maxDist

Optional maximum neighbor distance.

minK

Minimum number of retained neighbors per spot.

coords

Coordinate system passed to semla::GetSpatialNetwork().

tool_name

Name used to store results in srt@tools.

store_results

Whether to store the semla spatial network in srt@tools.

verbose

Whether to print the message. Default is TRUE.

...

Additional arguments passed to semla.

Value

A Seurat object.

Examples

data(visium_human_pancreas_sub)
spatial <- visium_human_pancreas_sub
spatial@tools$SemlaSpatialNetwork <- list(
  network = data.frame(
    from = colnames(spatial)[1:6],
    to = colnames(spatial)[2:7],
    distance = sqrt(diff(spatial$x[1:7])^2 + diff(spatial$y[1:7])^2)
  )
)

head(spatial@tools$SemlaSpatialNetwork$network)
#>                                  from                 to distance
#> ATTATCTCGACAGATC-1 TGGTATCGGTCTGTAT-1 ATTATCTCGACAGATC-1       55
#> TGAGATCAAATACTCA-1 ATTATCTCGACAGATC-1 TGAGATCAAATACTCA-1       55
#> CTGGTCCTAACTTGGC-1 TGAGATCAAATACTCA-1 CTGGTCCTAACTTGGC-1       55
#> ATAGTCTTTGACGTGC-1 CTGGTCCTAACTTGGC-1 ATAGTCTTTGACGTGC-1       55
#> GGGTGGTCCAGCCTGT-1 ATAGTCTTTGACGTGC-1 GGGTGGTCCAGCCTGT-1       55
#> ACACGGCACTATGCAT-1 GGGTGGTCCAGCCTGT-1 ACACGGCACTATGCAT-1       55
SpatialSpotPlot(
  spatial,
  group.by = "coda_label",
  overlay_image = FALSE,
  coord.cols = c("x", "y")
)


spatial <- RunSemlaSpatialNetwork(
  spatial,
  nNeighbors = 6,
  coords = "pixels",
  verbose = FALSE
)
#>  Found VisiumV2 object(s).
#> 
#> ── Collecting data from @images slot 
#> ! Array coordinates are not available for non-VisiumHD datasets. Please consider using semla's own functions to load the data. See '?ReadVisiumData()'