Here we will illustrate how to choose and use the appropriate gating
methods that are pre-registered in openCyto
package. And
users can always define their own gating
algorithms and
register them as the plugin
functions in
openCyto
framework, see ?registerPlugins
for
more details.
Note that all the function names illustrated below are prefixed with
.
indicating that they are simply the wrapper function
registered in openCyto
. The actual
gating engine
behind the wrapper can come from other
packages (e.g. flowCore
, flowClust
). All these
wrappers have these common interfaces: * fr
: a
flowFrame
object * pp_res
: an optional
pre-preocessing
result, which can be ignored in this
document * channels
: channel names used for gating *
...
: any other gating parameters pass on to the actual
gating engine
library(flowCore)
library(flowWorkspace)
library(openCyto)
library(ggcyto)
gs <- load_gs(system.file("extdata/gs_bcell_auto", package = "flowWorkspaceData"))
mindensity
The name of this gating function is self-explaining, that is to find
the minimum as the cutpoint between negative and postive peaks in 1d
density plot. It is fast,robust and extremely easy to use especially
when there is a good separation between +
and
-
populations/peaks.
For example, it is usually easy to gate on CD3
channel
and no need to supply any arguments to the method.
fr <- gh_pop_get_data(gs[[2]], "Live", returnType = "flowFrame")
chnl <- "CD3"
g <- openCyto:::.mindensity(fr, channels = chnl)
autoplot(fr, chnl) + geom_gate(g)
autoplot(fr, chnl, "SSC-A") + geom_gate(g)
However, it may need some guidance when there are more than
2
major peaks/populations detected in densit profile.
fr <- gh_pop_get_data(gs[[1]], "boundary", returnType = "flowFrame")
chnl <- "FSC-A"
g <- openCyto:::.mindensity(fr, channels = chnl)
mylimits <- ggcyto_par_set(limits = "instrument")
p <- autoplot(fr, chnl) + mylimits
p + geom_gate(g)
autoplot(fr, chnl, "SSC-A") + geom_gate(g)
Here we actually want to remove the debris cells
that
are represented by the first negative peak. But mindensity
cuts between the second and third peaks since they are more
predorminant. So we can simply specify a range
that will
limit the locations where the cut point should be placed.
g <- openCyto:::.mindensity(fr, channels = chnl, gate_range=c(7e4,1e5), adjust = 1.5)
p + geom_gate(g)
autoplot(fr, chnl, "SSC-A") + geom_gate(g)
And as shown, we also changed the kernal density
smoothing factor adjust
from 2
(default value
set in openCtyo
) to 1.5
to avoid
over-smoothing.
Alternatively you can achieve the same effect by setting
min
or max
to pre-filter the data before the
mindenstiy
works on it.
g <- openCyto:::.mindensity(fr, channels = chnl, min = 7e4, max = 1e5)
p + geom_gate(g)