Adds the data points (beads, cells, spots, etc.) of the object to the plot. This function is actually the working horse of plotSurface().

ggpLayerPoints(object, ...)

# S4 method for class 'SPATA2'
ggpLayerPoints(
  object,
  alpha_by = NULL,
  color_by = NULL,
  pt_alpha = 0.9,
  pt_clr = "lightgrey",
  pt_size = NULL,
  scale_pt_size = TRUE,
  clrp = NULL,
  clrp_adjust = NULL,
  clrsp = NULL,
  smooth = FALSE,
  smooth_span = 0.2,
  normalize = NULL,
  transform_with = NULL,
  xrange = NULL,
  yrange = NULL,
  outline = FALSE,
  outline_fct = c(1.75, 2.75),
  unit = NULL,
  breaks = NULL,
  expand = TRUE,
  scale_fct = 1,
  use_scattermore = FALSE,
  sctm_pixels = c(1024, 1024),
  add_labs = FALSE,
  bcs_rm = NULL,
  na_rm = FALSE,
  geom = "point",
  verbose = NULL,
  ...
)

# S4 method for class 'SpatialData'
ggpLayerPoints(
  object,
  img_name = activeImage(object),
  alpha_by = NULL,
  color_by = NULL,
  pt_alpha = 0.9,
  pt_clr = "lightgrey",
  pt_size = 1,
  clrp = "sifre",
  clrp_adjust = NULL,
  clrsp = "inferno",
  scale_pt_size = TRUE,
  xrange = NULL,
  yrange = NULL,
  unit = NULL,
  breaks = NULL,
  expand = TRUE,
  bcs_rm = NULL,
  outline = FALSE,
  outline_fct = c(1.75, 2.75),
  na_rm = FALSE,
  scale_fct = 1,
  use_scattermore = FALSE,
  sctm_pixels = c(1024, 1024),
  add_labs = FALSE,
  geom = "point",
  ...
)

# S4 method for class 'data.frame'
ggpLayerPoints(
  object,
  alpha_by = NULL,
  color_by = NULL,
  pt_alpha = 0.9,
  pt_clr = "lightgrey",
  pt_size = 1,
  scale_fct = 1,
  use_scattermore = FALSE,
  sctm_pixels = c(1024, 1024),
  bcs_rm = NULL,
  geom = "point",
  na_rm = FALSE
)

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 scale_color_add_on().

color_by

Character value. The variables by which to color the data points.

pt_alpha

Numeric value. Specifies the degree of transparency of all points.

pt_clr

Character value. Specifies the color of all points.

pt_size

Numeric value. Specifies the size of all points.

clrp

Character value. Specifies the color palette to be used to represent groups of discrete variables. Run validColorPalettes() to obtain valid input options.

clrp_adjust

Named character vector or NULL. If character, it adjusts the color palette that is used to represent the groups. Names of the input vector must refer to the group and the respective named element denotes the color with which to represent the group.

clrsp

Character value. Specifies the color spectrum to be used to represent continuous values of numeric variables. Run validColorSpectra() to obtain valid input options.

smooth

Logical. If TRUE, a loess fit is used to smooth the values.

smooth_span

Numeric value. Controls the degree of smoothing. Given to argument span of stats::loess().

normalize

Logical. If set to TRUE values will be scaled to 0-1.

Hint: Variables that are uniformly expressed can not be scaled and are discarded.

transform_with

List or NULL. If list, can be used to transform continuous variables before usage. Names of the list slots refer to the variable. The content of the slot refers to the transforming functions. E.g if the variable of interest is GFAP gene expression, the following would work:

  • Single function: transform_with = log10,

  • Multiple functions: transform_with = list(GFAP = list(log10, log2)

In case of plotting: Useful if you want to apply more than one transformation on variables mapped to plotting aesthetics. Input for transform_with is applied before the respective <aes>_trans argument.

xrange, yrange

Distance vector of length two or NULL. If not NULL, specifies the x- and y-range to which the spatial output is cropped. E.g. xrange = c(200, 500) results in the two dimensional space being cropped from x-coordinate 200px up to x-coordinate 500px. If NULL, the original range is used.

unit

The desired unit. Defaults to the unit in which the original size of the image of the spatial method is provided. Obtain valid input options with validUnitsOfLengthSI().

breaks

Specifies where the breaks are set. Labels are plotted in the unit specified in unit. Valid input:

  • NULL: No specification. Five breaks are set equally distributed. Does not work with STS/IAS related plots as the range is taken from the whole image.

  • vector: Vector of distance measures. Breaks are set for axes denoted in which. (Defaults to both, x and y.)

  • list: List with slots x and y. Vector of distance measures to set each axis specifically.

expand

Specifies how the axis are expanded. Using expand of ggplot2::scale_x/y_continuous(). Valid input:

  • NULL or TRUE: No specification. Default is used.

  • FALSE: No expansion.

  • vector: Numeric vector of length two. Input is set for axes denoted in which. (Defaults to both, x and y.)

  • list: List with slots x and y. Numeric vector of length two, used for each axis specifically.

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.

add_labs

Logical. If TRUE, adds x- and y-labs to the plot.

bcs_rm

Character vector or NULL. If character, specifies the observations to be removed prior to analysis or visualization by their barcode.

verbose

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

(Warning messages will always be printed.)

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().

spot_alpha, spot_size, spot_clr

Parameters to set the aesthetics alpha, size, and color of the spots. Arguments alpha_by and color_by are prioritized.

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")

ggplot() +
 ggpLayerPoints(object, color_by = "HM_HYPOXIA")