We cluster the observations in fr into K clusters. We set the cutpoint to be the point at which the density between the first and second smallest cluster centroids is minimum.

gate_flowclust_2d(
fr,
xChannel,
yChannel,
filterId = "",
K = 2,
usePrior = "no",
prior = list(NA),
trans = 0,
min.count = -1,
max.count = -1,
nstart = 1,
plot = FALSE,
target = NULL,
transitional = FALSE,
quantile = 0.9,
translation = 0.25,
transitional_angle = NULL,
min = NULL,
max = NULL,
...
)

## Arguments

fr a flowFrame object character specifying channels to be gated on A character string that identifies the filter created. the number of clusters to find Should we use the Bayesian version of flowClust? Answers are "yes", "no", or "vague". The answer is passed along to flowClust. list of prior parameters for the Bayesian version of flowClust. If usePrior is set to no, then the list is unused. some flowClust parameters. see flowClust a logical value indicating if the fitted mixture model should be plotted. By default, no. a numeric vector of length 2 (number of dimensions) containing the location of the cluster of interest. See details. logical value indicating if a transitional gate should be constructed from the target flowClust cluster. By default, no. the contour level of the target cluster from the flowClust fit to construct the gate a numeric value between 0 and 1 used to position a transitional gate if transitional = TRUE. This argument is ignored if transitional = FALSE. See details the angle (in radians) of the transitional gate. It is also used to determine which quadrant the final gate resides in. See details. Ignored if transitional = FALSE. A vector of length 2. Truncate observations less than this minimum value. The first value truncates the xChannel, and the second value truncates the yChannel. By default, this vector is NULL and is ignored. A vector of length 2. Truncate observations greater than this maximum value. The first value truncates the xChannel, and the second value truncates the yChannel. By default, this vector is NULL and is ignored. additional arguments that are passed to flowClust

## Value

a polygonGate object containing the contour (ellipse) for 2D gating.

## Details

The cluster for the population of interest is selected as the one with cluster centroid nearest the target in Euclidean distance. By default, the largest cluster (i.e., the cluster with the largest proportion of observations) is selected as the population of interest.

We also provide the option of constructing a transitional gate from the selected population of interest. The location of the gate can be controlled with the translation argument, which translates the gate along the major axis of the targest cluster as a function of the appropriate chi-squared coefficient. The larger translation is, the more gate is shifted in a positive direction. Furthermore, the width of the transitional gate can be controlled with the quantile argument.

The direction of the transitional gate can be controlled with the transitional_angle argument. By default, it is NULL, and we use the eigenvector of the target cluster that points towards the first quadrant (has positive slope). If transitional_angle is specified, we rotate the eigenvectors so that the angle between the x-axis (with the cluster centroid as the origin) and the major eigenvector (i.e., the eigenvector with the larger eigenvalue) is transitional_angle. So based on range that the angle falls in, the final rectangleGate will be constructed at the corresponding quadrant. i.e. Clockwise, [0,pi/2] UR, (pi/2, pi] LR, (pi, 3/2 * pi] LL, (3/2 * pi, 2 * pi] UL

## Examples

if (FALSE) {
gate <- gate_flowclust_2d(fr, xChannel = "FSC-A", xChannel = "SSC-A", K = 3) # fr is a flowFrame
}