# extend the original flowWorkspace:::.mergeGates function to restore quadGate when applicable

Source: `R/merge.quad.gates.R`
`merge.quad.gates.Rd`

For internal usage.

    # S3 method for quad.gates
    merge(gh, pops, bool = TRUE)

## Arguments

gh | a GatingHierarchy
pops | a vector of population names
bool | whether to deal with boolean gate

## Value

a nested list of data structure that captures the information of parent, grouped populations (with the same projections) and the reconstructed quadGate object and the respective quadrant pattern

## Examples

    library(flowWorkspace)
    dataDir <- system.file("extdata",package="flowWorkspaceData")
    gs <- load_gs(file.path(dataDir, "gs_manual"))
    #get the GatingHierarchy object
    gh <- gs[[1]]
    pops <- gs_pop_get_children(gh, "CD4")
    grps  <- ggcyto:::merge.quad.gates(gh, pops)
    length(grps) # pops are grouped into two#> [1] 2grps[[1]] # each group is annotaed with quadGate information#> $popIds
    #> $popIds$quad.gate
    #> Quadrant gate 'defaultQuadGate' with dimensions:
    #>   <R660-A>: 1892.233
    #>   <V545-A>: 1968.89
    #>
    #> $popIds$quad.pattern
    #> [1] "-+" "++" "+-" "--"
    #>
    #> $popIds$pop.name
    #> [1] "/not debris/singlets/CD3+/CD4/38- DR+"
    #> [2] "/not debris/singlets/CD3+/CD4/38+ DR+"
    #> [3] "/not debris/singlets/CD3+/CD4/38+ DR-"
    #> [4] "/not debris/singlets/CD3+/CD4/38- DR-"
    #>
    #>
    #> $parentId
    #> [1] "CD4"
    #>
    ggcyto:::merge.quad.gates(gh, gs_pop_get_children(gh, "CD3+")) # cd3 subsets are not coercible to quadgate thus return as they are#> $`/not debris/singlets/CD3+/CD4`
    #> $`/not debris/singlets/CD3+/CD4`$popIds
    #> [1] "/not debris/singlets/CD3+/CD4" "/not debris/singlets/CD3+/CD8"
    #> [3] "/not debris/singlets/CD3+/DNT" "/not debris/singlets/CD3+/DPT"
    #>
    #> $`/not debris/singlets/CD3+/CD4`$parentId
    #> [1] "CD3+"
    #>
    #>