Skip to contents

This function will open a react application that can be used to interactively visualize categorical or numeric features as spatial maps. For the application to run properly, relevant data needs to be available via a file server. This function is intended to be used within a shiny app

Usage

ftrviewer(
  host = "127.0.0.1",
  port = "8080",
  sampleID = 1,
  values,
  opacities,
  opacity = 1,
  range,
  scaleByOpacity = FALSE,
  isNumeric = TRUE,
  useLasso = FALSE,
  levels = character(),
  categories = character(),
  colors = rev(RColorBrewer::brewer.pal(n = 9, name = "Spectral")),
  container_width = 800,
  container_height = 800,
  spot_size = 0.003,
  elementId = NULL
)

Arguments

host

The host address. Defaults to localhost "127.0.0.1"

port

A number for a valid port

sampleID

A section number

values

A vector of numeric or categorical values

opacities

A numeric vector of opacity values

opacity

An integer of length 1 specifying a fixed opacity value

range

A numeric vector of length 2 specifying a range of values (color domain)

scaleByOpacity

A logical specifying if the opacity should be set by opacities or opacity

isNumeric

A logical specifying if the input is numeric or not

useLasso

A logical specifying if the lasso selection tool should be activated

levels

Category levels for coloring of values

categories

A character vector with the categories available

colors

A character vector of colors

container_width, container_height

Container width/height in pixels

spot_size

A numeric value specifying the spot radius

elementId

The id of the viewer element

Value

A htmlwidget to be used in a shiny application

Examples


library(semla)
se_mbrain <- readRDS(system.file("extdata/mousebrain", "se_mbrain", package = "semla"))
se_mbrain <- LoadImages(se_mbrain)
#> 
#> ── Loading H&E images ──
#> 
#>  Loading image from /private/var/folders/8r/bfm2m_q17znfk0m_8dt330tm0000gp/T/RtmpLHpYU7/temp_libpath305b1609463d/semla/extdata/mousebrain/spatial/tissue_lowres_image.jpg
#>  Scaled image from 600x565 to 400x377 pixels
#>  Saving loaded H&E images as 'rasters' in Seurat object

if (FALSE) { # \dontrun{
# Export data for viewer
datapath <- ExportDataForViewer(se_mbrain, outdir = tempdir())

if (interactive()) {
# Start file server
file_server(datapath)

# Run feature viewer widget
ftrviewer(values = as.numeric(se_mbrain$nFeature_Spatial),
          opacities = rep(1, ncol(se_mbrain)), isNumeric = TRUE,
          range = range(se_mbrain$nFeature_Spatial))

# Stop file server
beakr::stopAllServers()
}
} # }