SpatialExperiment-rotate-mirror: Methods for spatial attributes

SpatialExperiment-rotate-mirrorR Documentation

Methods for spatial attributes

Description

The SpatialExperiment class provides methods to rotate and mirror SpatialExperiment objects and their spatialCoords.

Usage

## S4 method for signature 'SpatialExperiment'
rotateCoords(x, sample_id = NULL, degrees = 90, warn = TRUE)

## S4 method for signature 'SpatialExperiment'
mirrorCoords(x, sample_id = NULL, axis = c("h", "v"), warn = TRUE)

## S4 method for signature 'SpatialExperiment'
rotateObject(x, sample_id = NULL, image_id = NULL, degrees = 90)

## S4 method for signature 'SpatialExperiment'
mirrorObject(x, sample_id = NULL, image_id = NULL, axis = c("h", "v"))

Arguments

x

A SpatialExperiment object.

sample_id

Logical value or character vector specifying sample identifier(s) for scaleFactors. Default = TRUE (all samples).

degrees

single numeric in +/-[0,90,...,360] specifying how many degrees to rotate. A negative/positive value corresponds to counter-/clockwise rotation. Applicable for rotateCoords and rotateObject methods.

warn

Logical value indicating whether to print a warning about mismatches between coordinates and images, possible with the spatialCoords transformation methods rotateCoords and mirrorCoords.

axis

character string specifying whether to mirror horizontally ("h") or vertically ("v"). Applicable for mirrorCoords and mirrorObject methods.

image_id

Logical value or character vector specifying image identifier(s) for scaleFactors. Default = TRUE (all images).

Details

Additional details for each type of data attribute are provided below.

Value

Return value varies depending on method, as described below.

spatialCoords transformation methods

rotateCoords(x, sample_id, degrees, warn):

Apply a rotation to the spatialCoords of x, potentially subsetted to sample sample_id (or without subsetting if sample_id is NULL), by the specified number of degrees clockwise. Warn about mismatches with images if warn.

mirrorCoords(x, sample_id, axis, warn):

Reflect the spatialCoords of x across either the horizontal or vertical axis, specified by supplying "h" or "v" to the axis argument, respectively. Subset x to just the sample sample_id, if not NULL. Warn about mismatches with images if warn.

SpatialExperiment transformation wrapper methods

rotateObject(x, sample_id, image_id, degrees):

Apply a rotation to the spatialCoords and imgData of x, potentially subsetted to sample sample_id (or without subsetting if sample_id is NULL), by the specified number of degrees clockwise. Wrapper around rotateCoords and rotateImg.

mirrorObject(x, sample_id, image_id, axis):

Reflect the spatialCoords and imgData of x across either the horizontal or vertical axis, specified by supplying "h" or "v" to the axis argument, respectively. Subset x to just the sample sample_id, if not NULL. Wrapper around mirrorCoords and mirrorImg.

Author(s)

Nicholas J. Eagles

Examples

example(read10xVisium)

# rotateCoords(), mirrorCoords(), rotateObject(), and mirrorObject() return a
# SpatialExperiment, potentially subsetted by sample.

# Subset to just "section1"; rotate coordinates 90 degrees clockwise followed
# by a reflection across the vertical axis
spe_coords <- rotateCoords(spe, sample_id = "section1", degrees = 90)
spe_coords <- mirrorCoords(spe_coords, axis = "v")

# Subset to just "section2"; transform both the imgData() and spatialCoords()
# by a 180-degree rotation then reflection across the vertical axis
spe_wrapper <- rotateObject(spe, sample_id = "section2", degrees = 180)
spe_wrapper <- mirrorObject(spe_wrapper, axis = "v")

drighelli/VisiumExperiment documentation built on April 10, 2024, 8:01 a.m.