getSpatialAnnotation.Rd
Extracts object of class SpatialAnnotation
by
it's ID.
getSpatialAnnotation(object, ...)
# S4 method for class 'SPATA2'
getSpatialAnnotation(
object,
id = idSA(object),
add_image = containsHistoImages(object),
expand = 0,
square = FALSE,
...
)
# S4 method for class 'SpatialData'
getSpatialAnnotation(
object,
id = idSA(object),
add_image = TRUE,
expand = 0,
square = FALSE,
...
)
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 specifying the ID of the spatial annotation of interest. If there is only one spatial annotation in the object, the function will default to using it. However, if there are multiple annotations, this argument must be explicitly specified to identify the target annotation.
Logical. If TRUE, the area of the histology image that
is occupied by the annotated structure is added to the SpatialAnnotation
object in slot @image. Dimensions of the image can be adjusted with square
and expand
.
Specifies image expansion. An image that is cropped based on an image
annotation centers around the image annotation. If expand = 0
, the default, the dimensions of the image,
that is width/x-axis and height/y-axis, are set to include only the image annotation area
and nothing more. Using expand
, the cropped image section can be adjusted. See section
Expansion of cropped image sections for more information.
Logical value. Most image annotations come in variable shapes and
have different horizontal and vertical diameters. Therefore, height and width of the image
section are usually not equal. If square = TRUE
, the cropped section of the image that
contains the annotated structure is forced into a square: the bigger diameter of both is taken
as default. E.g. if the horizontal diameter of the image annotation is 1mm and the
vertical diameter is 1.5mm, the output image will have height and width of 1.5mm. That is,
in terms of coordinates, an x-range and a y-range of 1.5mm.
Processing of the image output depending on argument expand
happens afterwards.
An object of class SpatialAnnotation
.
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!')
.