RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
75 stars 29 forks source link

creating a NOT gate for gating out a single quadrant in a quadrant gate openCyto #242

Open noeldtz opened 1 year ago

noeldtz commented 1 year ago

Hi all,

I'm wondering whether someone knows if it is possible to create something like a NOT gate in Opencyto (preferably in the CSV template that holds the gating strategy) in two dimensions (e.g. a continueing down-stream gating with all events that fall outside of 1 of the 4 quadrants of a quadrant gate).

Any help will be greatly appreciated!

Thanks!

djhammill commented 1 year ago

@noeldtz, you can combine multiple gates using a boolean gate which is supported in openCyto through the boolGate gating method. See example below:

# add quadrant gates for populations A, B, C & D
gs_add_gating_method(
  gs,
  alias = "A,B,C,D",
  pop = "*",
  parent = "root",
  dims = "CD4,CD8",
  gating_method = "gate_quad_sequential",
  gating_args = list(
    gFunc = "mindensity"
  )
)
# combine populations A, B & C - call new population E
gs_add_gating_method(
  gs,
  alias = "E",
  pop = "+",
  parent = "root",
  dims = "CD4,CD8",
  gating_method = "boolGate",
  gating_args = "A|B|C"
)

The gating_args contains the boolean logic to use for the new population - | = OR & = AND ! = NOT. In this case we want all events in A, B OR C.

You can then easily gate downstream of the new combined population E by passing it as the parent to gs_add_gating_method().

Note: & will give the intersection of two gates (i.e. A&B - all events in BOTH A and B).