ggpLayerImage.RdCreates ggplot2 layer with the histology image as a raster.
ggpLayerImage(object, ...)
# S4 method for class 'SPATA2'
ggpLayerImage(
object,
img_name = activeImage(object),
transform = TRUE,
img_alpha = 1,
scale_fct = 1,
...
)
# S4 method for class 'SpatialData'
ggpLayerImage(
object,
img_name = activeImage(object),
transform = TRUE,
img_alpha = 1,
scale_fct = 1,
...
)
# S4 method for class 'HistoImage'
ggpLayerImage(object, transform = TRUE, scale_fct = 1, img_alpha = 1, ...)
# S4 method for class 'SpatialAnnotation'
ggpLayerImage(object, img_alpha = 1, rescale_axes = TRUE, scale_fct = 1, ...)
# S4 method for class 'Image'
ggpLayerImage(object, scale_fct = 1, img_alpha = 1, ...)
# S4 method for class 'data.frame'
ggpLayerImage(object, fill_by, img_alpha = 1)An object of class SPATA2 or, in case of S4 generics,
objects of classes for which a method has been defined.
Used to absorb deprecated arguments or functions.
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().
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.
Numeric value. Sets the transparency for the image.
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.
The image is plotted via ggplot2::geom_raster() by mapping the pixel position
to the x-axis and the y-axis. See section Image visualization
with ggplot2 for more details.
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.