Plots all images registered the SPATA2 object.

plotImages(object, ...)

# S4 method for class 'SPATA2'
plotImages(
  object,
  img_names = getImageNames(object),
  by_section = TRUE,
  outline = FALSE,
  outline_ref = FALSE,
  fragments = TRUE,
  line_alpha = line_alpha_ref * 0.75,
  line_alpha_ref = 1,
  line_color = "black",
  line_color_ref = "red",
  line_size = 0.5,
  line_size_ref = line_size * 1.5,
  transform = TRUE,
  img_alpha = 1,
  against_ref = FALSE,
  alignment_eval = FALSE,
  ncol = NULL,
  nrow = NULL,
  verbose = TRUE
)

# S4 method for class 'SpatialData'
plotImages(
  object,
  img_names = NULL,
  ncol = NULL,
  nrow = NULL,
  image = TRUE,
  outline = FALSE,
  outline_ref = FALSE,
  by_section = TRUE,
  fragments = TRUE,
  line_alpha = line_alpha_ref * 0.75,
  line_alpha_ref = 1,
  line_color = "black",
  line_color_ref = "red",
  line_size = 0.5,
  line_size_ref = line_size * 1.5,
  transform = TRUE,
  img_alpha = 1,
  against_ref = FALSE,
  alignment_eval = FALSE,
  verbose = TRUE
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

...

Additional arguments given to plotImage().

img_names

Character vector or NULL. If character, specifies the images by name. If NULL, all images are plotted.

by_section

Logical value. If TRUE, the default, the outline for every tissue section identified is used.

outline

Logical value. If TRUE, all images are plotted with the outline identified by identifyTissueOutline(..., method = "image").

outline_ref

Logical value. If TRUE, all images plotted with the outline identified by identifyTissueOutline(..., method = "image") of the reference image.

line_alpha

Numeric. Affects alpha of main lines of the plot.

line_color, line_color_ref

Character value. The color for the outline if outline = TRUE and/or outline_ref = TRUE.

line_size, line_size_ref

Character value. The linewidth for the outline if outline = TRUE and/or outline_ref = TRUE.

transform

Logical value. Should the instructions for image transformation set with alignImage() be applied?

img_alpha

Numeric value. Sets the transparency for the image.

nrow, ncol

Numeric values or NULL. Used to arrange multiple plots.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Value

A ggplot assembled with via patchwork::wrap_plots().

Distance measures

The vignette on distance measures in SPATA2 has been replaced. Click here to read it.

Image visualization with ggplot2

When comparing the output of ggplot() + ggpLayerImage() with other image plotting functions, you may notice that the image appears horizontally flipped when plotted using ggpLayerImage(). This behavior is due to the use of a Cartesian coordinate system in SPATA2, where a pixel with coordinates c(width = 1, height = 1) is plotted on the left side at the bottom. In contrast, functions like EBImage::display() or graphics::plot() use an image space coordinate system, where pixel heights start from the top. Consequently, in image space, pixel c(width = 1, height = 1) is displayed on the top resulting in mirror inverted visualization of the image.

We chose to use a Cartesian coordinate system in SPATA2 because we believe it provides a more intuitive framework for the spatial alignment of tissue, spatial annotations, spatial trajectories, barcoded sots, single cells, etc. where coordinates in the corresponding data.frames are provided in form of x- and y-variables. See getCoordsDf(), getImgAnnOutlineDf(), getTissueOutlineDf() etc.

If you prefer to view your image in the regular orientation, you can use the flipAll() function on your object, specifying axis = "horizontal", to reverse this effect.

Examples

library(SPATA2)

data("example_data")

object <- example_data$object_UKF275T_diet

plotImages(object)