# Generate a marginal gate.

Source: `R/utility.R`
`marginalFilter.Rd`

It simply constructs an boundaryFilter that removes the marginal events. It can be passed directly to ggcyto constructor. See the examples for details.

    marginalFilter(fs, dims, ...)

## Arguments

fs | flowSet (not used.)
dims | the channels involved
... | arguments passed to boundaryFilter

## Value

an boundaryFilter

## Examples

    data(GvHD)
    fs <- GvHD[1]
    chnls <- c("FSC-H", "SSC-H")
    #before removign marginal events
    summary(fs[, chnls])#> $s5a01
    #>             FSC-H     SSC-H
    #> Min.      59.0000    6.0000
    #> 1st Qu.  115.0000   82.0000
    #> Median   197.0000  145.5000
    #> Mean     245.2456  202.8588
    #> 3rd Qu.  338.0000  237.0000
    #> Max.    1023.0000 1023.0000
    #>
    # create merginal filter
    g <- marginalFilter(fs, chnls)
    g#> boundaryFilter 'defaultBoundaryFilter' operating on channels:
    #>  FSC-H (tolerance=2.22e-16, boundary=both)
    #>  SSC-H (tolerance=2.22e-16, boundary=both)
    #after remove marginal events
    fs.clean <- Subset(fs, g)
    summary(fs.clean[, chnls])#> $s5a01
    #>            FSC-H     SSC-H
    #> Min.     59.0000    6.0000
    #> 1st Qu. 114.0000   80.0000
    #> Median  193.0000  142.0000
    #> Mean    236.7293  185.7215
    #> 3rd Qu. 331.0000  228.0000
    #> Max.    943.0000 1009.0000
    #>
    #pass the function directly to ggcyto
    dataDir <- system.file("extdata",package="flowWorkspaceData")
    gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
    # with marginal events
    ggcyto(gs, aes(x = CD4, y = CD8), subset = "CD3+") + geom_hex(bins = 64)
    # using marginalFilter to remove these events
    ggcyto(gs, aes(x = CD4, y = CD8), subset = "CD3+", filter = marginalFilter) + geom_hex(bins = 64)