Last data update: 2014.03.03

R: Filter FCS files
filterR Documentation

Filter FCS files

Description

These methods link filter descriptions to a particular set of flow cytometry data allowing for the lightweight calculation of summary statistics common to flow cytometry analysis.

Usage

filter(x, filter, method = c("convolution", "recursive"), 
    sides = 2L, circular = FALSE, init = NULL)

Arguments

x

Object of class flowFrame or flowSet.

filter

An object of class filter or a named list filters.

method,sides,circular,init

These arguments are not used.

Details

The filter method conceptually links a filter description, represented by a filter object, to a particular flowFrame. This is accomplished via the filterResult object, which tracks the linked frame as well as caching the results of the filtering operation itself, allowing for fast calculation of certain summary statistics such as the percentage of events accepted by the filter. This method exists chiefly to allow the calculation of these statistics without the need to first Subset a flowFrame, which can be quite large.

When applying on a flowSet, the filter argument can either be a single filter object, in which case it is recycled for all frames in the set, or a named list of filter objects. The names are supposed to match the frame identifiers (i.e., the output of sampleNames(x) of the flowSet. If some frames identifiers are missing, the particular frames are skipped during filtering. Accordingly, all filters in the filter list that can't be mapped to the flowSet are ignored. Note that all filter objects in the list must be of the same type, e.g. rectangleGates.

Value

A filterResult object or a filterResultList object if x is a flowSet. Note that filterResult objects are themselves filters, allowing them to be used in filter expressions or Subset operations.

Author(s)

F Hahne, B. Ellis, N. Le Meur

See Also

Subset, filterResult

Examples


## Filtering a flowFrame
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore"))
rectGate <- rectangleGate(filterId="nonDebris","FSC-H"=c(200,Inf))
fr <- filter(samp,rectGate)
class(fr)
summary(fr)

## filtering a flowSet
data(GvHD)
foo <- GvHD[1:3]
fr2 <- filter(foo, rectGate)
class(fr2)
summary(fr2)

## filtering a flowSet using different filters for each frame
rg2 <- rectangleGate(filterId="nonDebris","FSC-H"=c(300,Inf))
rg3 <- rectangleGate(filterId="nonDebris","FSC-H"=c(400,Inf))
flist <- list(rectGate, rg2, rg3)
names(flist) <- sampleNames(foo)
fr3 <- filter(foo, flist)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(flowCore)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/flowCore/filter-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: filter
> ### Title: Filter FCS files
> ### Aliases: filter filter,flowFrame-method filter,flowFrame,filter-method
> ###   filter,flowFrame,rectangleGate filter,flowFrame,polygonGate
> ###   filter,flowFrame,norm2Filter filter,flowFrame,filterSet-method
> ###   filter,flowSet,filter-method filter,flowSet,filterSet-method
> ###   filter,flowSet,list-method filter,flowSet,filterList-method
> ###   summary,filter-method show,filter-method length,filter-method
> ###   formula,filter-method character,filter-method name,filter-method
> ###   call,filter-method identifier<-,filter,character-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> 
> ## Filtering a flowFrame
> samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore"))
> rectGate <- rectangleGate(filterId="nonDebris","FSC-H"=c(200,Inf))
> fr <- filter(samp,rectGate)
> class(fr)
[1] "logicalFilterResult"
attr(,"package")
[1] "flowCore"
> summary(fr)
nonDebris+: 9470 of 10000 events (94.70%)
> 
> ## filtering a flowSet
> data(GvHD)
> foo <- GvHD[1:3]
> fr2 <- filter(foo, rectGate)
> class(fr2)
[1] "filterResultList"
attr(,"package")
[1] "flowCore"
> summary(fr2)
filter summary for frame 's5a01'
 nonDebris+: 1695 of 3420 events (49.56%)

filter summary for frame 's5a02'
 nonDebris+: 1295 of 3405 events (38.03%)

filter summary for frame 's5a03'
 nonDebris+: 2281 of 3435 events (66.40%)

> 
> ## filtering a flowSet using different filters for each frame
> rg2 <- rectangleGate(filterId="nonDebris","FSC-H"=c(300,Inf))
> rg3 <- rectangleGate(filterId="nonDebris","FSC-H"=c(400,Inf))
> flist <- list(rectGate, rg2, rg3)
> names(flist) <- sampleNames(foo)
> fr3 <- filter(foo, flist)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>