Skip to contents

The following is a full example of usage of the widget with a SpatialExperiment object.

First, install the R dependencies:

install.packages("BiocManager")
BiocManager::install("STexampleData")

Download the dataset, load and preprocess the SpatialExperiment object, and configure the Vitessce widget:

library(vitessceR)
library(STexampleData)

spe_visium <- STexampleData::Visium_mouseCoronal()

w <- SPEWrapper$new(
  spe_visium,
  sample_id = "sample01",
  image_id = "hires",
  out_dir = file.path("data", "spe")
)

# Create Vitessce view config
vc <- VitessceConfig$new("My config")
dataset <- vc$add_dataset("My dataset")$add_object(w)
spatial <- vc$add_view(dataset, Component$SPATIAL)
status <- vc$add_view(dataset, Component$STATUS)
desc <- vc$add_view(dataset, Component$DESCRIPTION)
desc <- desc$set_props(description = "Visualization of a SpatialExperiment object.")

vc$layout(
  hconcat(spatial, vconcat(desc, status))
)

# Render the Vitessce widget
vc$widget(theme = "light")