library(openCyto)
library(ggcyto)
create and register plugin function
tmix2DGate.wrapper <- function(fr, pp_res = NULL, channels, ...){
res <- flowClust::flowClust(fr, varNames = channels, ...)
#exact clustering label
labels <- flowClust::Map(res)
as.factor(labels)
}
registerPlugins(tmix2DGate.wrapper, "tmix2DGate.wrapper")
## Registered tmix2DGate.wrapper
## [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
add_pop(gs, alias = "cd4,cd8"
, pop = "*"
, parent = "cd3"
, dims = "cd4,cd8"
, gating_method = "tmix2DGate.wrapper"
, gating_args = "K = 2, trans = 0"
, parallel_type = "multicore"
, mc.core = 2
)
p <- ggcyto(gs, aes(cd4, cd8), subset = "cd3") + geom_hex() + ggcyto_par_set(limits = "instrument")
p <- p + geom_overlay("cd4", size = 0.01, alpha = 1) + geom_overlay("cd8", color = "pink", size = 0.01, alpha = 1)
print(p)