shift_gate: Simplified geometric translation of gates

View source: R/transform_gate-methods.R

shift_gateR Documentation

Simplified geometric translation of gates

Description

Shift a Gate-type filter object in one or more dimensions

Usage

## Default S3 method:
shift_gate(obj, dx = NULL, dy = NULL, center = NULL, ...)

Arguments

obj

A Gate-type filter object (quadGate, rectangleGate, ellipsoidGate, or polygonGate)

dx

Either a numeric scalar or numeric vector. If it is scalar, this is just the desired shift of the gate in its first dimension. If it is a vector, it specifies both dx and dy as (dx,dy). This provides an alternate syntax for shifting gates, as well as allowing shifts of ellipsoidGate objects in more than 2 dimensions.

dy

A numeric scalar specifying the desired shift of the gate in its second dimension.

center

A numeric vector specifying where the center or centroid should be moved (rather than specifiying dx and/or dy)

...

Additional arguments not used

Details

This method allows for geometric translation of filter types defined by simple geometric gates (rectangleGate, quadGate, ellipsoidGate, or polygonGate). The method provides two approaches to specify a translation. For rectangleGate objects, this will shift the min and max bounds by the same amount in each specified dimension. For quadGate objects, this will simply shift the divinding boundary in each dimension. For ellipsoidGate objects, this will shift the center (and therefore all points of the ellipse). For polgonGate objects, this will simply shift all of the points defining the polygon.

The method allows two different approaches to shifting a gate. Through the dx and/or dy arguments, a direct shift in each dimension can be provided. Alternatively, through the center argument, the gate can be directly moved to a new location in relation to the old center of the gate. For quadGate objects, this center is the intersection of the two dividing boundaries (so the value of the boundary slot). For rectangleGate objects, this is the center of the rectangle defined by the intersections of the centers of each interval. For ellipsoidGate objects, it is the center of the ellipsoid, given by the mean slot. For polygonGate objects, the centroid of the old polygon will be calculated and shifted to the new location provided by center and all other points on the polygon will be shifted by relation to the centroid.

Value

A Gate-type filter object of the same type as gate, with the translation applied

Examples

## Not run: 
# Moves the entire gate +500 in its first dimension and 0 in its second dimension
shifted_gate <- shift_gate(original_gate, dx = 500)

#Moves the entire gate +250 in its first dimension and +700 in its second dimension
shifted_gate <- shift_gate(original_gate, dx = 500, dy = 700)

# Same as previous
shifted_gate <- shift_gate(original_gate, c(500,700))

# Move the gate based on shifting its center to (700, 1000)
shifted_gate <- shift_gate(original_gate, center = c(700, 1000))

## End(Not run)


RGLab/flowCore documentation built on Aug. 26, 2024, 8:52 a.m.