library(openCyto)
library(ggcyto)
load data
data(GvHD)
fs <- GvHD[1:2]
gs <- GatingSet(fs)
Before the time gate
autoplot(fs, x = "time", y = "SSC-H", bins = 64)

create timeFilters
tf <- timeFilter("SSC-H", bandwidth=0.5, filterId="myTimeFilter")
it is not a geometrical gate thus can not be added to gatingset directly
tf
## time filter 'myTimeFilter' with settings:
## bandwidth=0.5
but we do support adding the logicalFilterResult as a special logicalGate
fres <- filter(fs, tf)
fres
## A list of filterResults for a flowSet containing 2 frames
## produced by the filter named 'myTimeFilter'
is(fres[[1]], "logicalFilterResult")
## [1] TRUE
add(gs, fres, name = "time gate", parent = "root")
## NULL
getNodes(gs)
## [1] "root" "/time gate"
Visualizing the cleaned data
cleaned <- getData(gs, "time gate")
autoplot(cleaned, x = "time", y = "SSC-H", bins = 64)
## Warning: Removed 78 rows containing missing values (geom_hex).

Or visualize the gate as overlay dots
ggcyto(gs, aes(x = "time", y = "SSC-H")) + geom_hex() + geom_gate("time gate")
## Warning: Removed 107 rows containing missing values (geom_hex).

Create a plugin wrapper function that returns a filterResult object
myTimeGate <- function(fr, pp_res = NULL, channels, ...){
tf <- timeFilter(channels, ...)
fres <- filter(fr, tf)
return(fres)
}
registerPlugins(myTimeGate, "timeGate")
## Registered timeGate
## [1] TRUE
now timeGate is ready to be used in openCyto template