suppressMessages(library(flowStats))
data("GvHD")
foo = GvHD[1:5]
outDir = file.path(tempdir(), "foo")
# plot(foo[[1]], c("FSC-H", "SSC-H"))
suppressWarnings(write.flowSet(foo, outDir))
## [1] "/tmp/Rtmpn23afM/foo"
list.files(outDir)
## [1] "annotation.txt" "s5a01.fcs" "s5a02.fcs" "s5a03.fcs"
## [5] "s5a04.fcs" "s5a05.fcs"
plot(read.FCS(list.files(outDir, full = T)[2]), c("FSC-H", "SSC-H"))

# this code will output the fcs files with filtering
#plot(foo[[1]], c("FSC-H", "SSC-H"))
#write.flowSet(foo, outDir)
g <- lymphGate(foo, channels = c("FSC-H","SSC-H"), preselection=NULL, scale = 2.5, bwFac = 1.3, filterId = "defaultLymphGate")
output <- Subset(foo, g$n2gate)
# plot(output[[1]], c("FSC-H", "SSC-H"))
suppressWarnings(write.flowSet(output, outDir))
## [1] "/tmp/Rtmpn23afM/foo"
plot(read.FCS(list.files(outDir, full = T)[2]), c("FSC-H", "SSC-H"))
