section_dummy: Section dummy

View source: R/documentation-dummies.R

section_dummyR Documentation

Section dummy

Description

Section dummy

Usage

section_dummy()

Area measures

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

Distance measures

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

Expansion of cropped image sections

The argument expand is a versatile way, to specify how a cropped image section is extracted. If you want the cropped image as is, specify expand = 0. Else, there are multiple options. In general, expand takes three kinds of values, namely percentages, distances and distance exclamations.

  • Percentage: A string suffixed with %. E.g. expand = '50%' adds 50% of the distance from the center to the border of the image annotation to the image frame.

  • Distance measures: In pixel or European units of length. E.g. expand = list(x = '1mm') expands the x-axis on both sides with 1mm. ⁠expand = list(x = c('0.5mm', 1.5mm')⁠ expands the x-axis on the left side with 0.5mm and on the right side with 1.5mm.

  • Exclam distance measures: Distance measure with an exclamation mark suffix. E.g. expand = '1mm!' centers the image and forces an axis length of 1 millimeter. (Example 5)

Depending on how the values are specified different parts of the image can be expanded.

Single values, like expand = 50, are recycled: Every end of each image axis is expanded by 50 pixel. (Example 2)

Vectors of length two, like expand = c('1mm', '2mm'), are recycled: The beginning of each axis is expanded by 1 millimeter. The end of each axis is expanded by 2mm. (Example 3)

Named lists can be more precise. expand = list(x = c('1mm', '0.5mm'), y = c('0.25mm', '1mm')). Applies the vectors to expand the corresponding axis. (Example 4)

Using exclam input the side of the axis must not be specified as the axis is fixed as a whole. E.g expand = list(x = '1mm!', y = '2mm!') results in the same output as ⁠expand = list(x = c('1mm!', '1mm!'), y = c('2mm!', '2mm!')⁠.

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.

Selection of spatial annotations

Selection of spatial annotations via the arguments ids, class, tags and test works in three steps:

First, if ids is a character it prefilters the annotations by ID and only the specified ones are submitted to the next steps. If it is NULL, all annotations are submitted to the next steps.

Secondd, if class is a character it filters the annotations remaining after the first step by their class. If NULL, the step is skipped.

Third, if tags is a character it is used in combination with test to select from the spatial annotations that remain after the second step based on the meta data they are tagged with. There are multiple options:

  1. Argument test set to 'any' or 1: To be included, an image annotation must be tagged with at least one of the input tags.

  2. Argument test set to 'all' or 2: To be included, an image annotation must be tagged with all of the input tags. Can contain tags that are not specified.

  3. Argument test set to 'identical' or 3: To be included, an image annotation must be tagged with all of the input tags. Can not be tagged with anything else.

  4. Argument test set to not_identical or 4: To be included, an image annotation must not be tagged with the combination of input tags.

  5. Argument test set to 'none' or 5: To be included, an image annotation must not contain any of the input tags.

If tags is NULL, the step is skipped. Therefore, if ids, class and tags are all NULL, which is the default, all annotations are selected as all subsetting steps are skipped. Eventually, the remaining spatial annotations are submitted to whatever the respective function does.


theMILOlab/SPATA2 documentation built on Feb. 8, 2025, 11:41 p.m.