rectangleGate-class.RdClass and constructor for n-dimensional rectangular
filter objects.
rectangleGate(..., .gate, filterId="defaultRectangleGate")
| filterId | An optional parameter that sets the |
|---|---|
| .gate | A definition of the gate. This can be either a list, or a matrix, as described below. |
| ... | You can also directly provide the boundaries of a
|
Returns a rectangleGate object for use in filtering
flowFrames or other flow cytometry objects.
This class describes a rectangular region in n dimensions, which is a
Cartesian product of n orthogonal intervals in these dimensions.
n=1 corresponds to a range gate, n=2 to a rectangle gate,
n=3 corresponds to a box region and n>3 to a hyper-rectangular
regions. Intervals may be open on one side, in which case the value for the
boundary is supposed to be Inf or -Inf, respectively.
rectangleGates are inclusive, that means that events on the
boundaries are considered to be in the gate.
The constructor is designed to be useful in both direct and programmatic
usage. To use it programmatically, you may either construct a named list or
you may construct a matrix with n columns and 2 rows. The
first row corresponds to the minimal value for each parameter while the
second row corresponds to the maximal value for each parameter. The names
of the parameters are taken from the column names or from the list names,
respectively. Alternatively, the boundaries of the rectangleGate can
be given as additional named arguments, where each of these arguments should
be a numeric vector of length 2; the function tries to collapse these
boundary values into a matrix.
Note that boundaries of rectangleGates where min > max are
syntactically valid, however when evaluated they will always be empty.
rectangleGate objects can also be multiplied using the *
operator, provided that both gates have orthogonal axes. This results in
higher-dimensional rectangleGates. The inverse operation of
subsetting by parameter name(s) is also available.
Evaluating a rectangleGate generates an object of class
logicalFilterResult. Accordingly, rectangleGates
can be used to subset and to split flow cytometry data sets.
min,maxObjects of class "numeric". The
minimum and maximum values of the n-dimensional rectangular
region.
parametersObject of class "character",
indicating the parameters for which the rectangleGate is
defined.
filterIdObject of class "character",
referencing the filter.
See the documentation in the flowViz
package for details on plotting of rectangleGates.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("rectangleGate",
...), by using the constructor rectangleGate or by combining
existing rectangleGates using the * method. Using the
constructor is the recommended way of object instantiation.
signature(x = "flowFrame", table =
"rectangleGate"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user, but
internally by calls to the filter methods.
signature(object = "rectangleGate"): Print
information about the filter.
signature(e1 = "rectangleGate", e2 =
"rectangleGate"): combining two rectangleGates into one
higher dimensional representation.
signature(x = "rectangleGate", i = "character"):
Subsetting of a rectangleGate by parameter name(s). This
is essentially the inverse to *.
flowFrame, polygonGate,
ellipsoidGate, polytopeGate,
filter for evaluation of rectangleGates and
split and Subsetfor splitting and subsetting of
flow cytometry data sets based on that.
Other Gate classes:
ellipsoidGate-class,
polygonGate-class,
polytopeGate-class,
quadGate-class
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) #Create directly. Most likely from a command line rectangleGate(filterId="myRectGate", "FSC-H"=c(200, 600), "SSC-H"=c(0, 400))#> Rectangular gate 'myRectGate' with dimensions: #> FSC-H: (200,600) #> SSC-H: (0,400)#To facilitate programmatic construction we also have the following rg <- rectangleGate(filterId="myRectGate", list("FSC-H"=c(200, 600), "SSC-H"=c(0, 400))) mat <- matrix(c(200, 600, 0, 400), ncol=2, dimnames=list(c("min", "max"), c("FSC-H", "SSC-H"))) rg <- rectangleGate(filterId="myRectGate", .gate=mat) ## Filtering using rectangleGates fres <- filter(dat, rg) fres#> A filterResult produced by the filter named 'myRectGate'summary(fres)#> myRectGate+: 7380 of 10000 events (73.80%)#> flowFrame object '0877408774.B08' #> with 7380 cells and 8 observables: #> name desc range minRange maxRange #> $P1 FSC-H FSC-H 1024 0.000000 1023 #> $P2 SSC-H SSC-H 1024 0.000000 1023 #> $P3 FL1-H <NA> 1024 1.009044 10000 #> $P4 FL2-H <NA> 1024 1.009044 10000 #> $P5 FL3-H <NA> 1024 1.009044 10000 #> $P6 FL1-A <NA> 1024 0.000000 1023 #> $P7 FL4-H <NA> 1024 1.009044 10000 #> $P8 Time Time (51.20 sec.) 1024 0.000000 1023 #> 164 keywords are stored in the 'description' slot## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres)#> $`myRectGate+` #> flowFrame object '0877408774.B08 (myRectGate+)' #> with 7380 cells and 8 observables: #> name desc range minRange maxRange #> $P1 FSC-H FSC-H 1024 0.000000 1023 #> $P2 SSC-H SSC-H 1024 0.000000 1023 #> $P3 FL1-H <NA> 1024 1.009044 10000 #> $P4 FL2-H <NA> 1024 1.009044 10000 #> $P5 FL3-H <NA> 1024 1.009044 10000 #> $P6 FL1-A <NA> 1024 0.000000 1023 #> $P7 FL4-H <NA> 1024 1.009044 10000 #> $P8 Time Time (51.20 sec.) 1024 0.000000 1023 #> 164 keywords are stored in the 'description' slot #> #> $`myRectGate-` #> flowFrame object '0877408774.B08 (myRectGate-)' #> with 2620 cells and 8 observables: #> name desc range minRange maxRange #> $P1 FSC-H FSC-H 1024 0.000000 1023 #> $P2 SSC-H SSC-H 1024 0.000000 1023 #> $P3 FL1-H <NA> 1024 1.009044 10000 #> $P4 FL2-H <NA> 1024 1.009044 10000 #> $P5 FL3-H <NA> 1024 1.009044 10000 #> $P6 FL1-A <NA> 1024 0.000000 1023 #> $P7 FL4-H <NA> 1024 1.009044 10000 #> $P8 Time Time (51.20 sec.) 1024 0.000000 1023 #> 164 keywords are stored in the 'description' slot #>## Multiply rectangle gates rg1 <- rectangleGate(filterId="FSC-", "FSC-H"=c(-Inf, 50)) rg2 <- rectangleGate(filterId="SSC+", "SSC-H"=c(50, Inf)) rg1 * rg2#> Rectangular gate 'defaultRectangleGate' with dimensions: #> FSC-H: (-Inf,50) #> SSC-H: (50,Inf)## Subset rectangle gates rg["FSC-H"]#> Rectangular gate 'myRectGate' with dimensions: #> FSC-H: (200,600)##2d rectangleGate can be coerced to polygonGate as(rg, "polygonGate")#> Polygonal gate 'myRectGate' with 4 vertices in dimensions FSC-H and SSC-H