InteractiveSpatialPlot: Interactive Spatial Cell Selection Tool

View source: R/visualization.R

InteractiveSpatialPlotR Documentation

Interactive Spatial Cell Selection Tool

Description

Launch an interactive gadget for lasso-based cell selection from a spatial Seurat object. Supports Visium, SlideSeq, and Vizgen data. Returns the cell names of the selected subset, suitable for downstream subsetting or analysis.

Usage

InteractiveSpatialPlot(
  object,
  image = NULL,
  image.scale = "lowres",
  group.by = NULL,
  alpha = 1,
  pt.size.factor = 1,
  overlay_image = TRUE
)

Arguments

object

A Seurat object with spatial data.

image

Name of the spatial image stored in the object. If NULL, uses the default image for the object.

image.scale

Character. Which image scaling factor to use for spatial coordinate transformation ("lowres" by default).

group.by

Metadata variable (column name) to use for coloring cell points (e.g., cluster assignment). If NULL, uses "seurat_clusters" if available, otherwise all cells are grouped together.

alpha

Numeric transparency value for cell points (default 1.0).

pt.size.factor

Numeric scaling factor for point size (default 1.0).

overlay_image

Logical; if TRUE, overlays the tissue image in the background of the plot (default TRUE).

Value

A character vector of cell names selected via lasso, which can be used to subset the object.

Note

This function requires the plotly, magrittr, and base64enc packages to be installed. It also requires shiny and miniUI for the interactive UI.

Examples

## Not run: 
selected_cells <- InteractiveSpatialPlot(object = brain)
selected_cells <- InteractiveSpatialPlot(object = brain, overlay_image = FALSE)

## End(Not run)

Seurat documentation built on Dec. 14, 2025, 9:07 a.m.