Skip to contents

Plot spot-by-cell-type proportions stored by RunRCTD(), RunCARD(), RunSPOTlight(), or RunSpatialDWLS(). The plot reads the stored result directly from srt@tools[[tool_name]] and never reruns a deconvolution backend. RunCSIDE() is intentionally excluded because its output represents differential or context effects rather than cell-type proportions.

Usage

SpatialDeconvolutionPlot(
  srt,
  tool_name = NULL,
  cell_types = NULL,
  plot_type = c("point", "dominant", "pie"),
  combine = TRUE,
  nrow = NULL,
  ncol = NULL,
  byrow = TRUE,
  ...,
  image.scale = c("lowres", "hires")
)

Arguments

srt

A spatial Seurat object containing a stored deconvolution result.

tool_name

Explicit non-empty key in srt@tools. Results are never discovered implicitly.

cell_types

Optional cell types to display. The default uses all stored cell types.

plot_type

Plot proportions as separate point maps, one dominant-type map derived from the stored proportions, or one spot-level pie map.

combine

Whether to combine point maps. If FALSE, return a named list.

nrow, ncol, byrow

Point-map layout controls. When both dimensions are NULL, a near-square layout with at most three columns is used.

image.scale

Image scale factor matching the selected raster.

...

Additional arguments passed to SpatialSpotPlot().

Value

A ggplot, patchwork, or named list of ggplot objects.

Examples

data(visium_human_pancreas_sub)
data(panc8_sub)
keep_spots <- unique(round(seq(1, ncol(visium_human_pancreas_sub), length.out = 200)))
spatial <- visium_human_pancreas_sub[, keep_spots]
#> Warning: Not validating Centroids objects
#> Warning: Not validating Centroids objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating Seurat objects
reference <- panc8_sub[, panc8_sub$celltype %in% c("ductal", "alpha", "beta")]
reference <- Seurat::FindVariableFeatures(reference, nfeatures = 300, verbose = FALSE)
shared <- intersect(
  SeuratObject::VariableFeatures(reference),
  rownames(spatial)
)
spatial <- RunSpatialDWLS(
  spatial[shared, ],
  reference = reference,
  reference_label = "celltype",
  features = shared,
  coord.cols = c("x", "y"),
  normalize = FALSE,
  verbose = FALSE
)
#> Warning: Not validating Centroids objects
#> Warning: Not validating Centroids objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating FOV objects
#> Warning: Not validating Seurat objects
SpatialDeconvolutionPlot(
  spatial,
  tool_name = "SpatialDWLS",
  cell_types = colnames(spatial@tools$SpatialDWLS$proportions)[1],
  overlay_image = FALSE,
  coord.cols = c("x", "y")
)