add,GatingSet,list-method {flowWorkspace} | R Documentation

## Create a GatingSet and add/remove the flowCore gate(or population) to/from a GatingHierarchy/GatingSet.

### Description

`GatingSet` method creates a gatingset from a flowSet with the ungated data as the root node. `add` method add the flowCore gate to a GatingHierarchy/GatingSet. `setGate` method update the gate of one population node in GatingHierarchy/GatingSet. `Rm` method Remove the population node from a GatingHierarchy/GatingSet. They are equivalent to the `workFlow`,`add` and `Rm` methods in `flowCore` package. `recompute` method does the actual gating after the gate is added,i.e. calculating the event indices according to the gate definition.

### Usage

    ## S4 method for signature 'GatingSet,list'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSetList,list'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSet,filtersList'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSet,filterList'
    add(wf, action, validityCheck = TRUE,
      ...)

    ## S4 method for signature 'GatingSetList,filterList'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSetList,filtersList'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSet,filter'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSet,filters'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSetList,filter'
    add(wf, action, ...)

    ## S4 method for signature 'GatingSetList,filters'
    add(wf, action, ...)

    ## S4 method for signature 'GatingHierarchy,filter'
    add(wf, action, ...)

    ## S4 method for signature 'GatingHierarchy,filters'
    add(wf, action, names = NULL, ...)

    ## S4 method for signature 'GatingHierarchy,quadGate'
    add(wf, action, names = NULL, ...)

    ## S4 method for signature 'GatingHierarchy,logical'
    add(wf, action, parent, name,
      recompute, cluster_method_name = NULL, ...)

    ## S4 method for signature 'GatingHierarchy,factor'
    add(wf, action, name = NULL, ...)

    ## S4 method for signature 'GatingHierarchy,logicalFilterResult'
    add(wf, action, ...)

    ## S4 method for signature 'GatingHierarchy,multipleFilterResult'
    add(wf, action,
      name = NULL, ...)

    ## S4 method for signature 'character,GatingSet,character'
    Rm(symbol, envir, subSymbol, ...)

    ## S4 method for signature 'character,GatingSetList,character'
    Rm(symbol, envir, subSymbol,
      ...)

    ## S4 method for signature 'character,GatingHierarchy,character'
    Rm(symbol, envir,
      subSymbol, ...)

### Arguments

`wf` | A `GatingHierrarchy` or `GatingSet`
`action` | A `filter` or a list of `filter`s to be added to the `GatingHierarchy` or `GatingSet`.
`...` | some other arguments to specify how the gates are added to the gating tree. negated: a `logical` scalar to specify whether the gate is negated,which means the the population outside of the gate will be kept as the result population. It is FALSE by default.
`validityCheck` | `logical` whether to check the consistency of tree structure across samples. default is TRUE. Can be turned off when speed is prefered to the robustness.
`names` | a `character` vector of length four,which specifies the population names resulted by adding a `quadGate`.
`parent` | a `character` scalar to specify the parent node name where the new gate to be added to, by default it is NULL,which indicates the root node
`name` | a `character` scalar to specify the node name of population that is generated by the gate to be added.
`recompute` | a `logical` flag The order of the names is clock-wise starting from the top left quadrant population.
`cluster_method_name` | when adding the logical vectors as the gates, the name of the cluster method can be used to tag the populations as the extra meta information associated with the gates.
`symbol` | A `character` identifies the population node in a `GatingHierrarchy` or `GatingSet` to remove
`envir` | A `GatingHierrarchy` or `GatingSet`
`subSymbol` | Not used.

### Value

`GatingSet` method returns a `GatingSet` object with just root node. `add` method returns a population node ID (or four population node IDs when adding a `quadGate`) that uniquely identify the population node within a `GatingHierarchy`.

### See Also

`GatingSet-class`

### Examples

    ## Not run:
        data(GvHD)
    #select raw flow data
        fs<-GvHD[1:3]

    #transform the raw data
        tf <- transformList(colnames(fs[[1]])[3:6], asinh, transformationId="asinh")
        fs_trans<-transform(fs,tf)

    #add transformed data to a gatingset
        gs <- GatingSet(fs_trans)
        gs
        getNodes(gs[[1]]) #only contains root node

    #add one gate
        rg <- rectangleGate("FSC-H"=c(200,400), "SSC-H"=c(250, 400),
            filterId="rectangle")

        nodeID<-add(gs, rg)#it is added to root node by default if parent is not specified
        nodeID
        getNodes(gs[[1]]) #the second population is named after filterId of the gate

    #add a quadGate
        qg <- quadGate("FL1-H"=2, "FL2-H"=4)
        nodeIDs<-add(gs,qg,parent="rectangle")
        nodeIDs #quadGate produces four population nodes
        getNodes(gs[[1]]) #population names are named after dimensions of gate if not specified

    #add a boolean Gate
        bg<-booleanFilter(`CD15 FITC-CD45 PE+`|`CD15 FITC+CD45 PE-`)
        bg
        nodeID2<-add(gs,bg,parent="rectangle")
        nodeID2
        getNodes(gs[[1]])
    #do the actual gating
        recompute(gs)

    #plot one gate for one sample
        plotGate(gs[[1]],"rectangle")
        plotGate(gs[[1]],nodeIDs) #may be smoothed automatically if there are not enough events after gating

    #plot gates across samples using lattice plot
        plotGate(gs,nodeID)
    #plot all gates for one sample
        plotGate(gs[[1]])#boolean gate is skipped by default
        plotGate(gs[[1]],bool=TRUE)

    #plot the gating hierarchy
        require(Rgraphviz)
        plot(gs[[1]])
    #remove one node causing the removal of all the descendants
        Rm('rectangle', gs)
        getNodes(gs[[1]])

    ## End(Not run)

[Package flowWorkspace version 3.32.0 Index]