Last data update: 2014.03.03

R: Class "expressionFilter"
expressionFilter-classR Documentation

Class "expressionFilter"

Description

A filter holding an expression that can be evaluated to a logical vector or a vector of factors.

Usage


expressionFilter(expr, ..., filterId="defaultExpressionFilter")
char2ExpressionFilter(expr, ..., filterId="defaultExpressionFilter")

Arguments

filterId

An optional parameter that sets the filterId of this filter. The object can later be identified by this name.

expr

A valid R expression or a character vector that can be parsed into an expression.

...

Additional arguments that are passed to the evaluation environment of the expression.

Details

The expression is evaluated in the environment of the flow cytometry values, hence the parameters of a flowFrame can be accessed through regular R symbols. The convenience function char2ExpressionFilter exists to programmatically construct expressions.

Value

Returns a expressionFilter object for use in filtering flowFrames or other flow cytometry objects.

Extends

Class "concreteFilter", directly.

Class "filter", by class concreteFilter, distance 2.

Slots

expr:

The expression that will be evaluated in the context of the flow cytometry values.

args:

An environment providing additional parameters.

deparse:

A character scalar of the deparsed expression.

filterId:

The identifier of the filter

Objects from the Class

Objects can be created by calls of the form new("expressionFilter", ...), using the expressionFilter constructor or, programmatically, from a character string using the char2ExpressionFilter function.

Methods

%in%

signature(x = "flowFrame", table = "expressionFilter"): The workhorse used to evaluate the gate on data. This is usually not called directly by the user, but internally by calls to the filter methods.

show

signature(object = "expressionFilter"): Print information about the gate.

Author(s)

F. Hahne, B. Ellis

See Also

flowFrame, filter for evaluation of sampleFilters and split and Subsetfor splitting and subsetting of flow cytometry data sets based on that.

Examples


## Loading example data
dat <- read.FCS(system.file("extdata","0877408774.B08",
package="flowCore"))

#Create the filter
ef <- expressionFilter(`FSC-H` > 200, filterId="myExpressionFilter")
ef

## Filtering using sampeFilters
fres <- filter(dat, ef)
fres
summary(fres)

## The result of sample filtering is a logical subset
newDat <- Subset(dat, fres)
all(exprs(newDat)[,"FSC-H"] > 200)

## We can also split, in which case we get those events in and those
## not in the gate as separate populations
split(dat, fres)

## Programmatically construct an expression
dat <- dat[,-8]
r <- range(dat)
cn <- paste("`", colnames(dat), "`", sep="")
exp <- paste(cn, ">", r[1,], "&", cn, "<", r[2,], collapse=" & ")
ef2 <- char2ExpressionFilter(exp, filterId="myExpressionFilter")
ef2
fres2 <- filter(dat, ef2)
fres2
summary(fres2)

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/expressionFilter-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: expressionFilter-class
> ### Title: Class "expressionFilter"
> ### Aliases: expressionFilter-class expressionFilter
> ###   show,expressionFilter-method char2ExpressionFilter
> ### Keywords: methods classes classes
> 
> ### ** Examples
> 
> 
> ## Loading example data
> dat <- read.FCS(system.file("extdata","0877408774.B08",
+ package="flowCore"))
> 
> #Create the filter
> ef <- expressionFilter(`FSC-H` > 200, filterId="myExpressionFilter")
> ef
expression filter 'myExpressionFilter' evaluating the expression:
`FSC-H` > 200
> 
> ## Filtering using sampeFilters
> fres <- filter(dat, ef)
> fres
A filterResult produced by the filter named 'myExpressionFilter'
> summary(fres)
myExpressionFilter+: 9465 of 10000 events (94.65%)
> 
> ## The result of sample filtering is a logical subset
> newDat <- Subset(dat, fres)
> all(exprs(newDat)[,"FSC-H"] > 200)
[1] TRUE
> 
> ## We can also split, in which case we get those events in and those
> ## not in the gate as separate populations
> split(dat, fres)
$`myExpressionFilter+`
flowFrame object '0877408774.B08 (myExpressionFilter+)'
with 9465 cells and 8 observables:
     name              desc range minRange maxRange
$P1 FSC-H             FSC-H  1024        0     1023
$P2 SSC-H             SSC-H  1024        0     1023
$P3 FL1-H              <NA>  1024        1    10000
$P4 FL2-H              <NA>  1024        1    10000
$P5 FL3-H              <NA>  1024        1    10000
$P6 FL1-A              <NA>  1024        0     1023
$P7 FL4-H              <NA>  1024        1    10000
$P8  Time Time (51.20 sec.)  1024        0     1023
164 keywords are stored in the 'description' slot

$`myExpressionFilter-`
flowFrame object '0877408774.B08 (myExpressionFilter-)'
with 535 cells and 8 observables:
     name              desc range minRange maxRange
$P1 FSC-H             FSC-H  1024        0     1023
$P2 SSC-H             SSC-H  1024        0     1023
$P3 FL1-H              <NA>  1024        1    10000
$P4 FL2-H              <NA>  1024        1    10000
$P5 FL3-H              <NA>  1024        1    10000
$P6 FL1-A              <NA>  1024        0     1023
$P7 FL4-H              <NA>  1024        1    10000
$P8  Time Time (51.20 sec.)  1024        0     1023
164 keywords are stored in the 'description' slot

> 
> ## Programmatically construct an expression
> dat <- dat[,-8]
> r <- range(dat)
> cn <- paste("`", colnames(dat), "`", sep="")
> exp <- paste(cn, ">", r[1,], "&", cn, "<", r[2,], collapse=" & ")
> ef2 <- char2ExpressionFilter(exp, filterId="myExpressionFilter")
> ef2
expression filter 'myExpressionFilter' evaluating the expression:
`FSC-H` > 0 & `FSC-H` < 1023 & `SSC-H` > 0 & `SSC-H` < 1023 & `FL1-H` > 1 & `FL1-H` < 10000 & `FL2-H` > 1 & `FL2-H` < 10000 & `FL3-H` > 1 & `FL3-H` < 10000 & `FL1-A` > 0 & `FL1-A` < 1023 & `FL4-H` > 1 & `FL4-H` < 10000
> fres2 <- filter(dat, ef2)
> fres2
A filterResult produced by the filter named 'myExpressionFilter'
> summary(fres2)
myExpressionFilter+: 4237 of 10000 events (42.37%)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>