Adds a hull that outlines the tissue.

ggpLayerTissueOutline(object, ...)

# S4 method for class 'SPATA2'
ggpLayerTissueOutline(
  object,
  method = "obs",
  img_name = activeImage(object),
  by_section = TRUE,
  fragments = FALSE,
  line_alpha = 0.9,
  line_color = "black",
  line_size = 1,
  line_type = "solid",
  transform = TRUE,
  smooth_with = "none",
  scale_fct = 1,
  outline_fct = c(1.75, 2.75),
  expand_outline = 0,
  ...
)

# S4 method for class 'SpatialData'
ggpLayerTissueOutline(
  object,
  method = NULL,
  img_name = activeImage(object),
  by_section = TRUE,
  fragments = FALSE,
  line_alpha = 0.9,
  line_color = "black",
  line_size = 1,
  line_type = "solid",
  transform = TRUE,
  smooth_with = "none",
  scale_fct = 1,
  outline_fct = c(1.75, 2.75),
  expand_outline = 0,
  ...
)

# S4 method for class 'HistoImage'
ggpLayerTissueOutline(
  object,
  by_section = TRUE,
  fragments = FALSE,
  line_alpha = 0.9,
  line_color = "black",
  line_size = 1,
  line_type = "solid",
  transform = TRUE,
  smooth_with = "none",
  scale_fct = 1,
  expand_outline = 0,
  ...
)

# S4 method for class 'data.frame'
ggpLayerTissueOutline(
  object,
  method = "coords",
  by_section = TRUE,
  line_alpha = 0.9,
  line_color = "black",
  line_size = 1,
  line_type = "solid",
  outline_fct = c(1.75, 2.75),
  use_scattermore = FALSE,
  expand_outline = 0,
  ...
)

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 smoothr::smooth() depending on the input for smooth_with.

method

Character value. Either 'obs' or 'image'. Decides whether the tissue outline used based on the observations or the image is used. If method = NULL, the function checks first if any HistoImage is registered. If so, the outline from the image specified with img_name is returned. If there are no images, the outline computed with identifyTissueOutline(..., method = 'obs') is used.

img_name

Character value. The name of the image of interest. If NULL, the active image is chosen by default. Either way, must be one of getImageNames().

by_section

Logical value. If TRUE, the outline is used which acknowledges the potential for multiple tissue sections. If FALSE, the outline is used which simply outlines everything with one single polygon.

line_alpha

Numeric. Affects alpha of main lines of the plot.

line_color

Character. Affects color of the main lines of the plot.

line_size

Numeric. Affects size of the main lines of the plot.

line_type

Character. The line type. One of 'blank', 'solid', 'dashed', 'dotted', 'dotdash', 'longdash' and 'twodash'.

transform

Logical value. Ignored if no images exist in the object. If TRUE, spatial transformation instructions saved during image alignment of the image img_name are applied. Only relevant if there are any images registered in the SPATA2 object.

smooth_with

Character vaule. Sets the method with which to smooth the tissue outline polygon. One of c("chaikin", "densify", "ksmooth", "spline", "none"). If 'none', no smoothing is conducted.

expand_outline

Distance measure with which to expand the outline. Must be provided in pixel units!

use_scattermore

Logical value. If TRUE, data points are plotted with scattermore::geom_scattermore() which allows quick plotting of several thousand data points. If the number of data points plotted is bigger than 10.000 it is used anyway.

incl_edge

Logical. If TRUE, include tissue section outline. See examples of getTissueOutlineDf().

Value

ggpLayer*()-functions return lists of ggproto objects that can be added to ggplots via the + operator. In most of the cases they are supposed to be added to plots created with the plotSurface*() family.

Examples


library(SPATA2)
library(tidyverse)

data("example_data")

object <- loadExampleObject("UKF275T")

plotSurface(object, color_by = "HM_HYPOXIA", pt_clrsp = "Reds 3") +
 ggpLayerTissueOutline(object)

# alternative
plotSurface(object, color_by = "HM_HYPOXIA", pt_clrsp = "Reds 3", outline = TRUE)