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"))

1D gating methods

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")
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")
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)

To choose one way or the other or combining both is highly dependent on how your data. The more contrains will give you more controls on how gating proceeds yet at cost of robustness of your gating pipeline sometime.

tailgate

This gating method is used in the senarios where there is only one major peak detected thus automatically disqualify the usage of mindensity. tol is to control how far the cut point should be placed away from the peak.

fr <- gh_pop_get_data(gs[[1]], "lymph")
chnl <- "Live"
g <- openCyto:::.tailgate(fr, channels = chnl, tol = 0.05)
p <- autoplot(fr, chnl) + mylimits
p + geom_gate(g)
autoplot(fr, chnl, "SSC-A") + geom_gate(g)

quantileGate

This method is an alternative to tailgate and it determines the cutpoint by the events quantile.

g <- openCyto:::.quantileGate(fr, channels = chnl, probs = 0.99)
p <- autoplot(fr, chnl) + mylimits
p + geom_gate(g)
autoplot(fr, chnl, "SSC-A") + geom_gate(g)