Skip to contents

This function takes in an image-related object - path to JP(E)G/PNG file, raster object, RGBarray. It returns a ggplot object with the selected image.

Usage

# S4 method for character
plotImage(x)

# S4 method for Seurat
plotImage(x, slice = Images(x)[1])

# S4 method for SpatialExperiment
plotImage(x, slice = imgData(x)[1, "sample_id"])

# S4 method for array
plotImage(x, alpha = NULL)

# S4 method for ANY
plotImage(x)

Arguments

x

A variety of objects can be passed: character string corresponding to an image file path, valid file types are JPG, JPEG and PNG. It can also take as input objects of class raster and RGB arrays. It can also take a SpatialExperiment or Seurat object from which the image will be extracted.

slice

Character string indicating which image slice to use when SpatialExperiment or Seurat objects are passed. By default uses the first slice available.

alpha

NOT IMPLEMENTED - single numeric between 0 and 1 determining the image opacity. Lower values correspond to more transparency.

Value

ggplot object

Author

Marc Elosua Bayes & Helena L Crowell

Examples

# Filename
path <- file.path(
  system.file(package = "SPOTlight"), 
  "extdata/SPOTlight.png")
plotImage(x = path)

# array
png_img <- png::readPNG(path)
plotImage(png_img)

# Seurat Object
# library(SeuratData)
# so <- LoadData("stxBrain", type = "anterior1")
# plotImage(so)
# SpatialExperiment
library(TENxVisiumData)
spe <- MouseKidneyCoronal()
#> see ?TENxVisiumData and browseVignettes('TENxVisiumData') for documentation
#> loading from cache
plotImage(spe)