library(openCyto)
library(flowStats)
multipleFilterResult as the output of the gating functionThis function returns a multipleFilterResult object which will be added as multiple logicalGates (similar to boolGate)
curv2gate <- function(fr, pp_res, channels, ...){
filter(fr, curv2Filter(x = channels, ...))
}
registerPlugins(curv2gate, "curv2gate")
## Registered curv2gate
## [1] TRUE
the pop is set to * indicating this gating method will generate multiple gates alias is set to * so that the population names will be automatically assigned according to the filterID from filterResults
| alias | pop | parent | dims | gating_method | gating_args | |
|---|---|---|---|---|---|---|
| 7 | * | * | cd3 | cd4,cd8 | curv2gate | bwFac=5 |
filters as the output of the gating functionfilters is a container that stores multiple geometrical gates that shares the same dimensions Here we extract the geometrical gates from the filterResult from curv2Gate and wrap them into a filters object
curv2gate_geom <- function(fr, pp_res, channels,...){
#call curv2Filter to get gating result
res <- curv2gate(fr, channels = channels, ...)
#extract polygonGates
pops <- names(res)
pops <- pops[-1] #exclude `rest`
polygons <- filterDetails(res)[[1]]$polygons
glist <-mapply(pops, polygons , FUN = function(thisPop, pg){
pg <- cbind(pg$x, pg$y)
colnames(pg) <- channels
polygonGate(.gate= pg, filterId = thisPop)
})
#construct filters object
filters(glist)
}
registerPlugins(curv2gate_geom, "curv2gate_geom")
## Registered curv2gate_geom
## [1] TRUE
the pop is set to * indicating this gating method will generate multiple gates population names are manually defined in alias and follow the same order as the gates arranged in filters container
| alias | pop | parent | dims | gating_method | gating_args | |
|---|---|---|---|---|---|---|
| 6 | cd4,cd8 | * | cd3 | cd4,cd8 | curv2gate_geom | bwFac=5 |
run gating
gating(gt, gs)
visualize the gating tree
plot(gs)
the gate generated by curv2gate is booleanFilter
getGate(gs[[1]], "area 1")
## booleanFilter filter 'area 1' evaluating the expression:
## ""
visualize the logical/bool gates
plotGate(gs[[1]], c("area 1", "area 2"), bool = T
, projection = list("area 1" = c(x = "cd4" , y = "cd8")
, "area 2" = c(x = "cd4" , y = "cd8"))
, gpar = list(nrow = 1)
)
the gate generated by curv2gate_geom is regular geometrical gate
getGate(gs[[1]], "cd4")
## Polygonal gate 'cd4' with 109 vertices in dimensions <APC Cy7-A> and <PerCP Cy55 Blue-A>
plotGate(gs[[1]], c("cd4", "cd8"))