RGLab / flowWorkspace

flowWorkspace
GNU Affero General Public License v3.0
44 stars 21 forks source link

Feature Request: Parsing of BooleanFilters by gh_pop_get_gate/gs_pop_get_gate #360

Open DillonHammill opened 3 years ago

DillonHammill commented 3 years ago

Hi @mikejiang,

The logic stored in booleanFilters (deparse slot) refers to nodes that exist within the GatingHierarchy/GatingSet. When we extract a booleanFilter from a GatingHierarchy/GatingSet we do not get a filter that can be applied to the data because the reference to the gates in the logic is lost (booleanFilters only store names of the gates and not coordinates).

Would it be possible to automatically parse the booleanFilter logic when extracting it from the GatingHierarchy/GatingSet to produce a valid filter? See example below:

library(CytoExploreRData)

# GatingSet
gs <- load_gs(
    system.file(
     "extdata/Activation-GatingSet",
     package = "CytoExploreRData"
    )
)

# Parental population
cs <- gs_pop_get_data(gs, "Single Cells")

# BooleanFilter
bool <- gh_pop_get_gate(gs[[1]], "Live Cells")
bool@deparse # logic - requires 'Dead Cells' gate

# Cannot subset by booleanFilter
Subset(cs, bool)

# Parse logic into valid filter
bool <- !gh_pop_get_gate(gs[[1]], "Dead Cells")
Subset(cs, bool)

It would be great if gh_pop_get_gate/gs_pop_get_gate could extract the required gates by extracting the nodes from bool@deparse and then apply the required operators !|& to produce a valid filter that can be applied to the data.