Yes, you can do this via a Boolean gate. Here is a quick example, which I hope that you can adapt to your own data. In this example, I am interested in a population of cells that fall outside the main density of cells, which are identified via a polynomial gate. After I negate it, I then do a rectangle gate on the identified cells - note the very specific notation when using booleanFilter()
, which includes the exclamation mark and backticks:
# gate for RFP+GFP+ cloud, then negate with boolean
message('--------gating for PE-A (RFP) GFP-A cloud')
gates <- c('PE.A', 'GFP.A')
gs_add_gating_method(
gs, alias = 'RFP GFP cloud',
pop = '+', parent = 'BV421-A-',
dims = paste(gates, collapse = ','),
gating_method = 'flowClust.2d',
gating_args = 'K=1,q=0.99')
# negate the gate
bg <- booleanFilter(`!RFP GFP cloud`, filterId = 'neg RFP GFP cloud')
gs_pop_add(gs, bg, parent = 'BV421-A-')
gs_get_pop_paths(gs[[1]])
# make a further specific selection on the cells selected via booleanGate
gates <- c('PE.A', 'GFP.A')
rfp_min <- quantile(exprs(ff)[,'PE-A'], 0.05)
rfp_max <- quantile(exprs(ff)[,'PE-A'], 0.95)
gfp_min <- quantile(exprs(ff)[,'GFP-A'], 0.60)
gfp_max <- max(exprs(ff)[,'GFP-A'])
rg <- rectangleGate(
'PE-A' = c(rfp_min,rfp_max),
'GFP-A' = c(gfp_min, gfp_max),
filterId = 'target RFP+GFP+')
gs_pop_add(gs, rg, parent = 'neg RFP GFP cloud')
gs_get_pop_paths(gs[[1]])
recompute(gs)
Kevin