Displays the spatial dimension of the sample and colors the surface according to the expression of genes, gene sets or features. There are methods for multiple classes:

plotSurface(object, ...)

# S4 method for class 'SPATA2'
plotSurface(
  object,
  color_by = NULL,
  alpha_by = NULL,
  smooth = FALSE,
  smooth_span = 0.2,
  pt_alpha = NULL,
  pt_clr = NULL,
  pt_clrp = NULL,
  pt_clrsp = NULL,
  pt_size = NULL,
  outline = FALSE,
  outline_fct = c(2.125, 2.75),
  clrp_adjust = NULL,
  transform_with = NULL,
  use_scattermore = NULL,
  sctm_pixels = c(1024, 1024),
  bcs_rm = base::character(0),
  na_rm = FALSE,
  xrange = getCoordsRange(object)$x,
  yrange = getCoordsRange(object)$y,
  display_image = NULL,
  img_alpha = 1,
  img_name = NULL,
  geom = "point",
  verbose = NULL,
  ...
)

# S4 method for class 'data.frame'
plotSurface(
  object,
  color_by = NULL,
  alpha_by = NULL,
  pt_alpha = 0.9,
  pt_clr = "lightgrey",
  pt_clrp = "milo",
  pt_clrsp = "inferno",
  pt_size = 2,
  image = NULL,
  clrp_adjust = NULL,
  use_scattermore = FALSE,
  sctm_pixels = c(1024, 1024),
  sctm_interpolate = FALSE,
  outline = FALSE,
  outline_coords = NULL,
  outline_fct = c(2.125, 2.75),
  order_by = NULL,
  order_desc = FALSE,
  na_rm = TRUE,
  ...
)

# S4 method for class 'SpatialAnnotationScreening'
plotSurface(
  object,
  color_by = "rel_loc",
  line_color = "black",
  line_size = 1,
  fill = ggplot2::alpha("lightgrey", 0.25),
  pt_clrp = "npg",
  ...
)

# S4 method for class 'SpatialGradientScreening'
plotSurface(
  object,
  color_by = "rel_loc",
  line_color = "black",
  line_size = 1,
  pt_clrp = "npg",
  ...
)

plotSurfaceInteractive(object)

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.

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

pt_alpha

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

pt_clr

Character value. Specifies the color of all points.

pt_clrp

The color palette to be used if the specified variable displayed by color is categorical/discrete. Run validColorPalettes() to see valid input.

pt_clrsp

The color spectrum to be used if the specified variable displayed by color is continuous. Run validColorSpectra() to see valid input.

pt_size

Numeric value. Specifies the size of all points.

outline

Logical, indicating whether to add an outline to the points. If TRUE, an outline will be added around the points to enhance visibility. Default is FALSE.

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.

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.

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.

bcs_rm

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

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.

img_alpha

Numeric value. Sets the transparency for the image.

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

verbose

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

(Warning messages will always be printed.)

sctm_interpolate, sctm_pixels

Given to the corresponding arguments of scattermore::geom_scattermore(). Note: With increasing sctm_pixels the point size must be adjusted with the argument pt_size.

order_by

Character value or NULL. If character, the specified variable is used to order the data points.

order_desc

Logical value. If TRUE, reverses the arrangement specified via order_by and/or order.

line_color

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

line_size

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

fill

Character value or NA. If character, specifies the color with which the outline of the spatial annotation is filled.

outline_width

Numeric vector of length 2, specifying the factor with which the pt_size is multiplied to create the white layer (first value) and the black layer (second value).

Value

Returns a ggplot that can be additionally customized according to the rules of the ggplot2 framework.

Note

The methods for SpatialAnnotationScreening- and SpatialTrajectoryScreening exist to quickly visualize the set up with which the screening was conducted. The ... can be used to reach the plotSurface() method for data.frames with all its plotting parameters. For more controll, please use a combination of plotSurface() with the SPATA2 object and ggpLayer* functions.