| Title: | flowCore: Basic structures for flow cytometry data |
|---|---|
| Description: | Provides S4 data structures and basic functions to deal with flow cytometry data. |
| Authors: | B Ellis [aut], Perry Haaland [aut], Florian Hahne [aut], Nolwenn Le Meur [aut], Nishant Gopalakrishnan [aut], Josef Spidlen [aut], Mike Jiang [aut, cre], Greg Finak [aut], Samuel Granjeaud [ctb] |
| Maintainer: | Mike Jiang <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 2.25.1 |
| Built: | 2026-05-27 22:34:44 UTC |
| Source: | https://github.com/bioc/flowCore |
Provides S4 data structures and basic infrastructure and functions to deal with flow cytometry data.
Define important flow cytometry data classes:
flowFrame,
flowSet and their accessors.
Provide important transformation, filter, gating, workflow, and summary functions for flow cytometry data analysis.
Most of flow cytometry related Bioconductor packages (such as flowStats, flowFP, flowQ, flowViz, flowMerge, flowClust) are heavily dependent on this package.
| Package: | flowCore |
| Type: | Package |
| Version: | 1.11.20 |
| Date: | 2009-09-16 |
| License: | Artistic-2.0 |
Maintainer: Florian Hahne <[email protected]>
Authors: B. Ellis, P. Haaland, F. Hahne, N. Le Meur, N. Gopalakrishnan
Create the definition of the arcsinh Transformation that will be applied on
some parameter via the transform method. The definition of this
function is currently x<-asinh(a+b*x)+c). The transformation would normally
be used to convert to a linear valued parameter to the natural logarithm
scale. By default a and b are both equal to 1 and c to 0.
arcsinhTransform(transformationId="defaultArcsinhTransform", a=1, b=1, c=0)arcsinhTransform(transformationId="defaultArcsinhTransform", a=1, b=1, c=0)
transformationId |
character string to identify the transformation |
a |
positive double that corresponds to a shift about 0. |
b |
positive double that corresponds to a scale factor. |
c |
positive double |
Returns an object of class transform.
B. Ellis
transform-class, transform,
asinh
Other Transform functions:
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) asinhTrans <- arcsinhTransform(transformationId="ln-transformation", a=1, b=1, c=1) translist <- transformList('FSC-H', asinhTrans) dataTransform <- transform(samp, translist)samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) asinhTrans <- arcsinhTransform(transformationId="ln-transformation", a=1, b=1, c=1) translist <- transformList('FSC-H', asinhTrans) dataTransform <- transform(samp, translist)
Inverse hyperbolic sine transform class, which represents a transformation defined by the function:
This definition is such that it can function as an inverse of
sinht using the same definitions of the constants a
and b.
.DataObject of class "function".
aObject of class "numeric" – non-zero constant.
bObject of class "numeric" – non-zero constant.
parametersObject of class "transformation" – flow parameter
to be transformed
transformationIdObject of class "character" – unique ID to
reference the transformation.
Objects can be created by calls to the
constructor asinht(parameter,a,b,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The inverse hyperbolic sin transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
sinht
Other mathematical transform classes:
EHtrans-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) asinh1<-asinht(parameters="FSC-H",a=2,b=1,transformationId="asinH1") transOut<-eval(asinh1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) asinh1<-asinht(parameters="FSC-H",a=2,b=1,transformationId="asinH1") transOut<-eval(asinh1)(exprs(dat))
Inverse hyperbolic sin transformation as parameterized in Gating-ML 2.0.
asinhtGml2 is defined by the following function:
where
This transformation is equivalent to Logicle(T, 0, M, A) (i.e., with W=0). It provides an inverse hyperbolic sine transformation that maps a data value onto the interval [0,1] such that:
The top of scale value (i.e., T ) is mapped to 1.
Large data values are mapped to locations similar to an (M + A)-decade logarithmic scale.
A decades of negative data are brought on scale.
In addition, if a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the f function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the f function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
TObject of class numeric – positive constant (top of scale value).
MObject of class numeric – positive constant (desired number of decades).
AObject of class numeric – non-negative constant that is less than or equal
to M (desired number of additional negative decades).
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
asinhtGml2(parameter, T, M, A, transformationId, boundMin, boundMax)
Class singleParameterTransform, directly.
Class transform, by class singleParameterTransform, distance 2.
Class transformation, by class singleParameterTransform, distance 3.
Class characterOrTransformation, by class singleParameterTransform, distance 4.
The inverse hyperbolic sin transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Spidlen, J.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
asinht, transform-class,
transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myASinH1 <- asinhtGml2(parameters = "FSC-H", T = 1000, M = 4.5, A = 0, transformationId="myASinH1") transOut <- eval(myASinH1)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myASinH1 <- asinhtGml2(parameters = "FSC-H", T = 1000, M = 4.5, A = 0, transformationId="myASinH1") transOut <- eval(myASinH1)(exprs(myDataIn))
The 'biexponential' is an over-parameterized inverse of the hyperbolic sine. The function to be inverted takes the form biexp(x) = a*exp(b*(x-w))-c*exp(-d*(x-w))+f with default parameters selected to correspond to the hyperbolic sine.
biexponentialTransform(transformationId="defaultBiexponentialTransform", a = 0.5, b = 1, c = 0.5, d = 1, f = 0, w = 0, tol = .Machine$double.eps^0.25, maxit = as.integer(5000))biexponentialTransform(transformationId="defaultBiexponentialTransform", a = 0.5, b = 1, c = 0.5, d = 1, f = 0, w = 0, tol = .Machine$double.eps^0.25, maxit = as.integer(5000))
transformationId |
A name to assign to the transformation. Used by the transform/filter integration routines. |
a |
See the function description above. Defaults to 0.5 |
b |
See the function description above. Defaults to 1.0 |
c |
See the function description above. Defaults to 0.5 (the same as
|
d |
See the function description above. Defaults to 1 (the same as
|
f |
A constant bias for the intercept. Defaults to 0. |
w |
A constant bias for the 0 point of the data. Defaults to 0. |
tol |
A tolerance to pass to the inversion routine
( |
maxit |
A maximum number of iterations to use, also passed to
|
Returns values giving the inverse of the biexponential within a
certain tolerance. This function should be used with care as numerical
inversion routines often have problems with the inversion process due to the
large range of values that are essentially 0. Do not be surprised if you end
up with population splitting about w and other odd artifacts.
B. Ellis, N Gopalakrishnan
Other Transform functions:
arcsinhTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
# Construct some "flow-like" data which tends to be hetereoscedastic. data(GvHD) biexp <- biexponentialTransform("myTransform") after.1 <- transform(GvHD, transformList('FSC-H', biexp)) biexp <- biexponentialTransform("myTransform",w=10) after.2 <- transform(GvHD, transformList('FSC-H', biexp)) opar = par(mfcol=c(3, 1)) plot(density(exprs(GvHD[[1]])[, 1]), main="Original") plot(density(exprs(after.1[[1]])[, 1]), main="Standard Transform") plot(density(exprs(after.2[[1]])[, 1]), main="Shifted Zero Point")# Construct some "flow-like" data which tends to be hetereoscedastic. data(GvHD) biexp <- biexponentialTransform("myTransform") after.1 <- transform(GvHD, transformList('FSC-H', biexp)) biexp <- biexponentialTransform("myTransform",w=10) after.2 <- transform(GvHD, transformList('FSC-H', biexp)) opar = par(mfcol=c(3, 1)) plot(density(exprs(GvHD[[1]])[, 1]), main="Original") plot(density(exprs(after.1[[1]])[, 1]), main="Standard Transform") plot(density(exprs(after.2[[1]])[, 1]), main="Shifted Zero Point")
Class and constructor for data-driven filter objects that
discard margin events.
boundaryFilter(x, tolerance=.Machine$double.eps, side=c("both", "lower", "upper"), filterId="defaultBoundaryFilter")boundaryFilter(x, tolerance=.Machine$double.eps, side=c("both", "lower", "upper"), filterId="defaultBoundaryFilter")
x |
Character giving the name(s) of the measurement parameter(s) on
which the filter is supposed to work. Note that all events on the margins of
ay of the channels provided by |
tolerance |
Numeric vector, used to set the |
side |
Character vector, used to set the |
filterId |
An optional parameter that sets the |
Flow cytomtery instruments usually operate on a given data range, and the
limits of this range are stored as keywords in the FSC files. Depending on
the amplification settings and the dynamic range of the measured signal,
values can occur that are outside of the measurement range, and most
instruments will simply pile those values at the minimum or maximum range
limit. The boundaryFilter removes these values, either for a single
parameter, or for a combination of parameters. Note that it is often
desirable to treat boundary events on a per-parameter basis, since their
values might be uninformative for one particular channel, but still be
useful in all of the other channels.
The constructor boundaryFilter is a convenience function for object
instantiation. Evaluating a boundaryFilter results in a single
sub-populations, an hence in an object of class filterResult.
Returns a boundaryFilter object for use in filtering
flowFrames or other flow cytometry objects.
toleranceObject of class "numeric". The
machine tolerance used to decide whether an event is on the
measurement boundary. Essentially, this is done by evaluating
x>minRange+tolerance & x<maxRange-tolerance.
sideObject of class "character". The margin
on which to evaluate the filter. Either upper for the
upper margin or lower for the lower margin or both
for both margins.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("boundaryFilter",
...) or using the constructor boundaryFilter. Using the
constructor is the recommended way.
signature(x = "flowFrame", table =
"boundaryFilter"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user, but
internally by calls to the filter methods.
signature(object = "boundaryFilter"): Print
information about the filter.
Florian Hahne
flowFrame, flowSet,
filter for evaluation of
boundaryFilters and Subset for subsetting of flow
cytometry data sets based on that.
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create directly. Most likely from a command line boundaryFilter("FSC-H", filterId="myBoundaryFilter") ## To facilitate programmatic construction we also have the following bf <- boundaryFilter(filterId="myBoundaryFilter", x=c("FSC-H")) ## Filtering using boundaryFilter fres <- filter(dat, bf) fres summary(fres) ## We can subset the data with the result from the filtering operation. Subset(dat, fres) ## A boundaryFilter on the lower margins of several channels bf2 <- boundaryFilter(x=c("FSC-H", "SSC-H"), side="lower")## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create directly. Most likely from a command line boundaryFilter("FSC-H", filterId="myBoundaryFilter") ## To facilitate programmatic construction we also have the following bf <- boundaryFilter(filterId="myBoundaryFilter", x=c("FSC-H")) ## Filtering using boundaryFilter fres <- filter(dat, bf) fres summary(fres) ## We can subset the data with the result from the filtering operation. Subset(dat, fres) ## A boundaryFilter on the lower margins of several channels bf2 <- boundaryFilter(x=c("FSC-H", "SSC-H"), side="lower")
A simple union class of character and numeric.
Objects will be created internally whenever necessary and the user should
not need to explicitly interact with this class.
A virtual Class: No objects may be created from it.
showClass("characterOrNumeric")showClass("characterOrNumeric")
A simple union class of character and parameters.
Objects will be created internally whenever necessary and the user should
not need to explicitly interact with this class.
A virtual Class: No objects may be created from it.
showClass("characterOrParameters")showClass("characterOrParameters")
A simple union class of character and transformation.
Objects will be created internally whenever necessary and the user should
not need to explicitly interact with this class.
A virtual Class: No objects may be created from it.
showClass("characterOrTransformation")showClass("characterOrTransformation")
Fix the offset when its values recorded in header and TEXT don't agree
checkOffset(offsets, x, ignore.text.offset = FALSE, ...)checkOffset(offsets, x, ignore.text.offset = FALSE, ...)
offsets |
the named vector returned by |
x |
the text segmented returned by |
ignore.text.offset |
whether to ignore the offset info stored in TEXT segment |
... |
not used. |
the updated offsets
These functions manage the relations that allow coercing an object to a given class.
from, to
|
The classes between which |
The function supplied as the third argument is to be called to implement
as(x, to) when x has class from. Need we add that the
function should return a suitable object with class to.
F. Hahne, B. Ellis
samp1 <- read.FCS(system.file("extdata","0877408774.E07", package="flowCore")) samp2 <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) samples <-list("sample1"=samp1,"sample2"=samp2) experiment <- as(samples,"flowSet")samp1 <- read.FCS(system.file("extdata","0877408774.E07", package="flowCore")) samp2 <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) samples <-list("sample1"=samp1,"sample2"=samp2) experiment <- as(samples,"flowSet")
Coerce the list of the keywords into a character Also flatten spillover matrix into a string
collapse_desc(d, collapse.spill = TRUE)collapse_desc(d, collapse.spill = TRUE)
d |
a named list of keywords |
collapse.spill |
whether to flatten spillover matrix to a string |
a list of strings
data(GvHD) fr <- GvHD[[1]] collapse_desc(keyword(fr))data(GvHD) fr <- GvHD[[1]] collapse_desc(keyword(fr))
Emission spectral overlap can be corrected by subtracting the amount of spectral overlap from the total detected signals. This compensation process can be described by using spillover matrices.
The compensatedParameter class allows for compensation of specific parameters the user is interested in by creating compensatedParameter objects and evaluating them. This allows for use of compensatedParameter in gate definitions.
.DataObject of class "function".
parametersObject of class "character" – the flow
parameters to be compensated.
spillRefIdObject of class "character" – the name of the
compensation object (The compensation object contains the spillover Matrix).
searchEnvObject of class "environment" -environment in
which the compensation object is defined.
transformationIdObject of class "character" – a unique Id to
reference the compensatedParameter object.
Objects can be created by calls to the constructor of the form
compensatedParameter(parameters,spillRefId,transformationId,searchEnv).
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
The transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N,F.Hahne
compensation
samp <- read.flowSet(path=system.file("extdata", "compdata", "data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat ## create a compensation object comp <- compensation(comp.mat,compensationId="comp1") ## create a compensated parameter object cPar1<-compensatedParameter(c("FL1-H","FL3-H"),"comp",searchEnv=.GlobalEnv) compOut<-eval(cPar1)(exprs(samp[[1]]))samp <- read.flowSet(path=system.file("extdata", "compdata", "data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat ## create a compensation object comp <- compensation(comp.mat,compensationId="comp1") ## create a compensated parameter object cPar1<-compensatedParameter(c("FL1-H","FL3-H"),"comp",searchEnv=.GlobalEnv) compOut<-eval(cPar1)(exprs(samp[[1]]))
Class and methods to compensate for spillover between channels by applying a
spillover matrix to a flowSet or a flowFrame assuming a simple
linear combination of values.
compensation(..., spillover, compensationId="defaultCompensation") compensate(x, spillover, ...)compensation(..., spillover, compensationId="defaultCompensation") compensate(x, spillover, ...)
spillover |
The spillover or compensation matrix. |
compensationId |
The identifier for the compensation object. |
x |
|
... |
Further arguments. The constructor is designed to be useful in both programmatic and interactive settings, and ... serves as a container for possible arguments. The following combinations of values are allowed: Elements in ... are The first element in ... is a Argument ... is missing, in which case all parameter names are taken from the
colnames of |
The essential premise of compensation is that some fluorochromes may register signals in detectors that do not correspond to their primary detector (usually a photomultiplier tube). To compensate for this fact, some sort of standard is used to obtain the background signal (no dye) and the amount of signal on secondary channels for each fluorochrome relative to the signal on their primary channel.
To calculate the spillover percentage we use either the mean or the median
(more often the latter) of the secondary signal minus the background signal
for each dye to obtain n by n matrix, S, of so-called
spillover values, expressed as a percentage of the primary channel. The
observed values are then considered to be a linear combination of the true
fluorescence and the spillover from each other channel so we can obtain the
true values by simply multiplying by the inverse of the spillover matrix.
The spillover matrix can be obtained through several means. Some flow
cytometers provide a spillover matrix calculated during acquisition,
possibly by the operator, that is made available in the metadata of the
flowFrame. While there is a theoretical standard keyword $SPILL it
can also be found in the SPILLOVER or SPILL keyword depending
on the cytometry. More commonly the spillover matrix is calculated using a
series of compensation cells or beads collected before the experiment. If
you have set of FCS files with one file per fluorochrome as well as an
unstained FCS file you can use the
spillover method for
flowSets to automatically calculate a
spillover matrix.
The compensation class is essentially a wrapper around a
matrix that allows for transformed parameters and method dispatch.
A compensation object for the constructor.
A flowFrame or flowSet for the
compensate methods.
spilloverObject of class matrix; the
spillover matrix.
compensationIdObject of class character. An
identifier for the object.
parametersObject of class parameters. The
flow parameters for which the compensation is defined. This can
also be objects of class transform, in which
case the compensation is performed on the compensated parameters.
Objects should be created using the constructor compensation(). See
the Usage and Arguments sections for details.
signature(x = "flowFrame", spillover =
"compensation"): Apply the compensation defined in a
compensation object on a flowFrame.
This returns a compensated flowFrame.
Usage:
compensate(flowFrame, compensation)
signature(x = "flowFrame", spillover =
"matrix"): Apply a compensation matrix to a
flowFrame. This returns a compensated
flowFrame.
Usage:
compensate(flowFrame, matrix)
signature(x = "flowFrame", spillover =
"data.frame"):Try to coerce the data.frame to a
matrix and apply that to a
flowFrame. This returns a compensated
flowFrame.
Usage:
compensate(flowFrame, data.frame)
signature(object =
"compensation"): Accessor and replacement methods for the
compensationId slot.
Usage:
identifier(compensation)
identifier(compensation) <- value
signature(object =
"compensation"): Get the parameter names of the
compensation object. This method also tries to resolve
all transforms and
transformReferences
before returning the parameters as character vectors. Unresolvable
references return NA.
Usage:
parameters(compensation)
signature(object = "compensation"): Print details
about the object.
Usage:
This method is automatically called when the object is printed on the screen.
F.Hahne, B. Ellis, N. Le Meur
## Read sample data and a sample spillover matrix samp <- read.flowSet(path=system.file("extdata", "compdata", "data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat ## compensate using the spillover matrix directly summary(samp) samp <- compensate(samp, comp.mat) summary(samp) ## create a compensation object and compensate using that comp <- compensation(comp.mat) compensate(samp, comp) ## demo the sample-specific compensation ## create a list of comps (each element could be a ## different compensation tailored for the specific sample) comps <- sapply(sampleNames(samp), function(sn)comp, simplify = FALSE) # the names of comps must be matched to sample names of the flowset compensate(samp, comps)## Read sample data and a sample spillover matrix samp <- read.flowSet(path=system.file("extdata", "compdata", "data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat ## compensate using the spillover matrix directly summary(samp) samp <- compensate(samp, comp.mat) summary(samp) ## create a compensation object and compensate using that comp <- compensation(comp.mat) compensate(samp, comp) ## demo the sample-specific compensation ## create a list of comps (each element could be a ## different compensation tailored for the specific sample) comps <- sapply(sampleNames(samp), function(sn)comp, simplify = FALSE) # the names of comps must be matched to sample names of the flowset compensate(samp, comps)
This class represents the logical complement of a single filter, which is
itself a filter that can be incorporated in to further set operations.
complementFilters are constructed using the prefix unary set operator
"!" with a single filter operand.
filtersObject of class "list", containing the component filters.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
B. Ellis
Other setOperationFilter classes:
intersectFilter-class,
setOperationFilter-class,
subsetFilter-class,
unionFilter-class
The concreteFilter serves as a base class for all filters that
actually implement a filtering process. At the moment this includes all
filters except filterReference, the only non-concrete
filter at present.
filterIdThe identifier associated with this class.
Objects of this class should never be created directly. It serves only as a point of inheritance.
Class "filter", directly.
B. Ellis
Reverse the application of a compensation matrix on a flowFrame
## S4 method for signature 'flowFrame,matrix' decompensate(x, spillover) ## S4 method for signature 'flowFrame,compensation' decompensate(x, spillover)## S4 method for signature 'flowFrame,matrix' decompensate(x, spillover) ## S4 method for signature 'flowFrame,compensation' decompensate(x, spillover)
x |
flowFrame. |
spillover |
matrix or data.frame or a compensation object |
a decompensated flowFrame
library(flowCore) f = list.files(system.file("extdata", "compdata", "data", package="flowCore"), full.name=TRUE)[1] f = read.FCS(f) spill = read.csv(system.file("extdata", "compdata", "compmatrix", package="flowCore"), ,sep="\t",skip=2) colnames(spill) = gsub("\\.","-",colnames(spill)) f.comp = compensate(f,spill) f.decomp = decompensate(f.comp,as.matrix(spill)) sum(abs([email protected]@exprs)) all.equal(decompensate(f.comp,spill)@exprs,decompensate(f.comp,as.matrix(spill))@exprs) all.equal(f@exprs,decompensate(f.comp,spill)@exprs)library(flowCore) f = list.files(system.file("extdata", "compdata", "data", package="flowCore"), full.name=TRUE)[1] f = read.FCS(f) spill = read.csv(system.file("extdata", "compdata", "compmatrix", package="flowCore"), ,sep="\t",skip=2) colnames(spill) = gsub("\\.","-",colnames(spill)) f.comp = compensate(f,spill) f.decomp = decompensate(f.comp,as.matrix(spill)) sum(abs(f@exprs-f.decomp@exprs)) all.equal(decompensate(f.comp,spill)@exprs,decompensate(f.comp,as.matrix(spill))@exprs) all.equal(f@exprs,decompensate(f.comp,spill)@exprs)
dg1polynomial allows for scaling,linear combination and translation within a single transformation defined by the function
.DataObject of class "function".
parametersObject of class "parameters" –the flow parameters
that are to be transformed.
aObject of class "numeric" – coefficients of length equal
to the number of flow parameters.
bObject of class "numeric" – coefficient of length 1 that
performs the translation.
transformationIdObject of class "character" unique ID to
reference the transformation.
Objects can be created by using the
constructor dg1polynomial(parameter,a,b,transformationId).
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column.(See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
ratio,quadratic,squareroot
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) dg1<-dg1polynomial(c("FSC-H","SSC-H"),a=c(1,2),b=1,transformationId="dg1") transOut<-eval(dg1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) dg1<-dg1polynomial(c("FSC-H","SSC-H"),a=c(1,2),b=1,transformationId="dg1") transOut<-eval(dg1)(exprs(dat))
Returns a vector or array of values obtained by applying a function to the
margins of a flowFrame. This is equivalent of running apply on
the output of exprs(flowFrame).
each_col(x, FUN, ...) each_row(x, FUN, ...)each_col(x, FUN, ...) each_row(x, FUN, ...)
x |
Object of class |
FUN |
the function to be applied. In the case of functions like '+', '%*%', etc., the function name must be backquoted or quoted. |
... |
optional arguments to 'FUN'. |
B. Ellis, N. LeMeur, F. Hahne
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore"), transformation="linearize") each_col(samp, summary)samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore"), transformation="linearize") each_col(samp, summary)
EH transformation of a parameter is defined by the function
.DataObject of class "function".
aObject of class "numeric" – numeric constant greater than zero.
bObject of class "numeric" – numeric constant greater than zero.
parametersObject of class "transformation" – flow parameter to be
transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
Objects can be created by calls to the
constructor EHtrans(parameters,a,b,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
hyperlog
Other mathematical transform classes:
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) eh1<-EHtrans("FSC-H",a=1250,b=4,transformationId="eh1") transOut<-eval(eh1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) eh1<-EHtrans("FSC-H",a=1250,b=4,transformationId="eh1") transOut<-eval(eh1)(exprs(dat))
Class and constructor for n-dimensional ellipsoidal filter
objects.
ellipsoidGate(..., .gate, mean, distance=1, filterId="defaultEllipsoidGate")ellipsoidGate(..., .gate, mean, distance=1, filterId="defaultEllipsoidGate")
filterId |
An optional parameter that sets the |
.gate |
A definition of the gate via a covariance matrix. |
mean |
Numeric vector of equal length as dimensions in |
distance |
Numeric scalar giving the Mahalanobis distance defining the
size of the ellipse. This mostly exists for compliance reasons to the
gatingML standard as |
... |
You can also directly describe the covariance matrix through named arguments, as described below. |
A convenience method to facilitate the construction of a ellipsoid
filter objects. Ellipsoid gates in n dimensions (n >= 2) are
specified by a a covarinace matrix and a vector of mean values giving the
center of the ellipse.
This function is designed to be useful in both direct and programmatic usage. In the first case, simply describe the covariance matrix through named arguments. To use this function programmatically, you may pass a covarince matrix and a mean vector directly, in which case the parameter names are the colnames of the matrix.
Returns a ellipsoidGate object for use in filtering
flowFrames or other flow cytometry objects.
meanObjects of class "numeric". Vector giving
the location of the center of the ellipse in n dimensions.
covObjects of class "matrix". The covariance
matrix defining the shape of the ellipse.
distanceObjects of class "numeric". The
Mahalanobis distance defining the size of the ellipse.
parametersObject of class "character",
describing the parameter used to filter the flowFrame.
filterIdObject of class "character",
referencing the filter.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("ellipsoidGate",
...) or by using the constructor ellipsoidGate. Using the
constructor is the recommended way.
signature(x = "flowFrame", table =
"ellipsoidGate"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user, but
internally by calls to the filter methods.
signature(object = "ellipsoidGate"): Print
information about the filter.
See the documentation in the flowViz
package for plotting of ellipsoidGates.
F.Hahne, B. Ellis, N. LeMeur
flowFrame, polygonGate,
rectangleGate, polytopeGate,
filter for evaluation of rectangleGates and
split and Subsetfor splitting and subsetting of
flow cytometry data sets based on that.
Other Gate classes:
polygonGate-class,
polytopeGate-class,
quadGate-class,
rectangleGate-class
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Defining the gate cov <- matrix(c(6879, 3612, 3612, 5215), ncol=2, dimnames=list(c("FSC-H", "SSC-H"), c("FSC-H", "SSC-H"))) mean <- c("FSC-H"=430, "SSC-H"=175) eg <- ellipsoidGate(filterId= "myEllipsoidGate", .gate=cov, mean=mean) ## Filtering using ellipsoidGates fres <- filter(dat, eg) fres summary(fres) ## The result of ellipsoid filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres) ##ellipsoidGate can be converted to polygonGate by interpolation pg <- as(eg, "polygonGate") pg## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Defining the gate cov <- matrix(c(6879, 3612, 3612, 5215), ncol=2, dimnames=list(c("FSC-H", "SSC-H"), c("FSC-H", "SSC-H"))) mean <- c("FSC-H"=430, "SSC-H"=175) eg <- ellipsoidGate(filterId= "myEllipsoidGate", .gate=cov, mean=mean) ## Filtering using ellipsoidGates fres <- filter(dat, eg) fres summary(fres) ## The result of ellipsoid filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres) ##ellipsoidGate can be converted to polygonGate by interpolation pg <- as(eg, "polygonGate") pg
Of the negative values for each channel specified, the median of the specified quantiles are used.
estimateMedianLogicle(flow_set, channels, m = 4.5, q = 0.05)estimateMedianLogicle(flow_set, channels, m = 4.5, q = 0.05)
flow_set |
object of class 'flowSet' |
channels |
character vector of channels to transform |
m |
TODO – default value from .lgclTrans |
q |
quantile |
TODO
Exponential transform class, which represents a transformation given by the function
.DataObject of class "function".
aObject of class "numeric" – non-zero constant.
bObject of class "numeric"- non-zero constant.
parametersObject of class "transformation" – flow
parameter to be transformed.
transformationIdObject of class "character" –
unique ID to reference the transformation
Objects can be created by calls to the
constructorexponential(parameters,a,b).
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The exponential transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
logarithm
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) exp1<-exponential(parameters="FSC-H",a=1,b=37,transformationId="exp1") transOut<-eval(exp1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) exp1<-exponential(parameters="FSC-H",a=1,b=37,transformationId="exp1") transOut<-eval(exp1)(exprs(dat))
A filter holding an expression that can be evaluated to a
logical vector or a vector of factors.
expressionFilter(expr, ..., filterId="defaultExpressionFilter") char2ExpressionFilter(expr, ..., filterId="defaultExpressionFilter")expressionFilter(expr, ..., filterId="defaultExpressionFilter") char2ExpressionFilter(expr, ..., filterId="defaultExpressionFilter")
filterId |
An optional parameter that sets the |
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. |
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.
Returns a expressionFilter object for use in filtering
flowFrames or other flow cytometry objects.
exprThe expression that will be evaluated in the context of the flow cytometry values.
argsAn environment providing additional parameters.
deparseA character scalar of the deparsed expression.
filterIdThe identifier of the filter.
Class "concreteFilter", directly.
Class "filter", by class concreteFilter,
distance 2.
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.
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.
signature(object = "expressionFilter"): Print
information about the gate.
F. Hahne, B. Ellis
flowFrame, filter for evaluation of
sampleFilters and split and Subsetfor
splitting and subsetting of flow cytometry data sets based on that.
## 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)## 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)
Transforms FCS data using the iplogicle function from FCSTrans by Quian et
al. The core functionality of FCSTrans has been imported to produce
transformed FCS data rescaled and truncated as produced by FCSTrans. The
w parameter is estimated by iplogicle automatically, then
makes a call to iplogicore which in turn uses the logicle transform
code of Wayne Moore.
FCSTransTransform(transformationId = "defaultFCSTransTransform", channelrange = 2^18, channeldecade = 4.5, range = 4096, cutoff = -111, w = NULL, rescale = TRUE)FCSTransTransform(transformationId = "defaultFCSTransTransform", channelrange = 2^18, channeldecade = 4.5, range = 4096, cutoff = -111, w = NULL, rescale = TRUE)
transformationId |
A name to assign to the transformation. Used by the transform/filter routines. |
channelrange |
is the range of the data. By default, 2^18 = 262144. |
channeldecade |
is the number of logarithmic decades. By default, it is set to 4.5. |
range |
the target resolution. The default value is 2^12 = 4096. |
cutoff |
a threshold below which the logicle transformation maps values to 0. |
w |
the logicle width. This is estimated by |
rescale |
logical parameter whether or not the data should be rescaled
to the number of channels specified in |
For the details of the FCSTrans transformation, we recommend the excellent Supplementary File that accompanies Quian et al. (2012): http://onlinelibrary.wiley.com/doi/10.1002/cyto.a.22037/suppinfo
Wayne Moore, N Gopalakrishnan
Y Quian, Y Liu, J Campbell, E Thompson, YM Kong, RH Scheuermann; FCSTrans: An open source software system for FCS file conversion and data transformation. Cytometry A, 2012
inverseLogicleTransform,
estimateLogicle ,
logicleTransform
data(GvHD) samp <- GvHD[[1]] ## User defined logicle function lgcl <- transformList(c('FL1-H', 'FL2-H'), FCSTransTransform()) after <- transform(samp, lgcl)data(GvHD) samp <- GvHD[[1]] ## User defined logicle function lgcl <- transformList(c('FL1-H', 'FL2-H'), FCSTransTransform()) after <- transform(samp, lgcl)
There are two notions of intersection in flowCore. First, there is
the usual intersection boolean operator & that has been overridden to
allow the intersection of two filters or of a filter and a list for
convenience. There is also the %&% or %subset% operator that
takes an intersection, but with subset semantics rather than simple
intersection semantics. In other words, when taking a subset, calculations
from summary and other methods
are taken with respect to the right hand filter. This primarily affects
calculations, which are ordinarily calculated with respect to the entire
population as well as data-driven gating procedures which will operate only
on elements contained by the right hand filter. This becomes especially
important when using filters such as
norm2Filter
e1 %&% e2 e1 %subset% e2e1 %&% e2 e1 %subset% e2
e1, e2
|
|
B. Ellis
The filter class is the virtual base class for all filter/gating
objects in flowCore. In general you will want to subclass or create a
more specific filter.
filterIdA character vector that identifies this filter.
This is typically user specified but can be automatically deduced by
certain filter operations, particularly boolean and
set operations.
All filter objects in flowCore
should be instantiated through their constructors. These are functions
that share the same name with the respective filter
classes. E.g.,
rectangleGate() is the
constructor function for rectangular gates, and
kmeansFilter() creates
objects of class kmeansFilter. Usually these
constructors can deal with various different inputs, allowing to
utilize the same function in different programmatic or interactive
settings. For all filters that operate on specific flow
parameters (i.e., those inheriting from
parameterFilter), the parameters
need to be passed to the constructor, either as names or colnames of
additional input arguments or explicitly as separate arguments. See
the documentation of the respective filter classes for
details. If parameters are explicitly defined as separate arguments,
they may be of class character, in which case they will be
evaluated literally as colnames in a flowFrame, or of
class transform, in which case the
filtering is performed on a temporarily transformed copy of the input
data. See here for details.
%in%Used in the usual way this returns a vector of
values that identify which events were accepted by the filter. A
single filter may encode several populations so this can return
either a logical vector, a factor vector or a
numeric vector of probabilities that the event is accepted
by the filter. Minimally, you must implement this method when
creating a new type of filter
&, |, !
Two filters can be composed
using the usual boolean operations returning a filter class
of a type appropriate for handling the operation. These methods
attempt to guess an appropriate filterId for the new
filter
%subset%, %&%
Defines a filter as being a
subset of another filter. For deterministic filters the results
will typically be equivalent to using an \& operation to
compose the two filters, though summary methods will use subset
semantics when calculating proportions. Additionally, when the
filter is data driven, such as
norm2Filter, the subset
semantics are
applied to the data used to fit the filter possibly resulting in
quite different, and usually more desirable, results.
%on%Used in conjunction with a
transformList to create a
transformFilter. This filter is similar to the subset
filter in that the filtering operation takes place on transformed
values rather than the original values.
filterA more formal version of %in%, this
method returns a
filterResult object
that can be used in subsequent filter operations as well as providing
more metadata about the results of the filtering operation. See
the documenation for filter
methods for details.
summarizeFilterWhen implementing a new filter this
method is used to update the filterDetails slot of a
filterResult. It is optional and typically only needs to be
implemented for data-driven filters.
B. Ellis, P.D. Haaland and N. LeMeur
Membership methods must be defined for every object of type filter
with respect to a flowFrame object. The operation is considered to
be general and may return a logical, numeric or factor
vector that will be handled appropriately. The ability to handle logical
matrices as well as vectors is also planned but not yet implemented.
x %in% tablex %in% table
x |
|
table |
an object of type |
Vector of type logical, numeric or factor depending on the arguments
F.Hahne, B. Ellis
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.
filter(x, filter, method = c("convolution", "recursive"), sides = 2L, circular = FALSE, init = NULL)filter(x, filter, method = c("convolution", "recursive"), sides = 2L, circular = FALSE, init = NULL)
x |
|
filter |
An object of class |
method, sides, circular, init
|
These arguments are not used. |
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.
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.
F Hahne, B. Ellis, N. Le Meur
## 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)## 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)
This operator is used to construct a transformFilter that first
applies a transformList to the data before applying the filter
operation. You may also apply the operator to a flowFrame or
flowSet to obtain transformed values specified in the list.
e1 %on% e2e1 %on% e2
e1 |
a |
e2 |
a |
B. Ellis
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) plot(transform("FSC-H"=log, "SSC-H"=log) %on% samp) rectangle <- rectangleGate(filterId="rectangleGateI","FSC-H"=c(4.5, 5.5)) sampFiltered <- filter(samp, rectangle %on% transform("FSC-H"=log, "SSC-H"=log)) res <- Subset(samp, sampFiltered) plot(transform("FSC-H"=log, "SSC-H"=log) %on% res)samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) plot(transform("FSC-H"=log, "SSC-H"=log) %on% samp) rectangle <- rectangleGate(filterId="rectangleGateI","FSC-H"=c(4.5, 5.5)) sampFiltered <- filter(samp, rectangle %on% transform("FSC-H"=log, "SSC-H"=log)) res <- Subset(samp, sampFiltered) plot(transform("FSC-H"=log, "SSC-H"=log) %on% res)
A filtering operation captures details about its metadata and stores it in a
filterDetails slot in a filterResult object
that is accessed using the filterDetails method. Each set of metadata
is indexed by the filterId of the filter allowing for all the metadata
in a complex filtering operation to be recovered after the final filtering.
When no particular
filterId is specified all the details are returned
You can also obtain a particular subset of details
B. Ellis, P.D. Haaland and N. LeMeur
Container for a list of filter
objects. The class mainly exists for method dispatch.
filterList(x, filterId=identifier(x[[1]]))filterList(x, filterId=identifier(x[[1]]))
x |
A list of |
filterId |
The global identifier of the filter list. As default, we
take the filterId of the first |
A filterList object for the constructor.
.DataObject of class "list". The class
directly extends list, and this slot holds the list data.
filterIdObject of class "character". The
identifier for the object.
Objects are created from regular lists
using the constructor filterList.
Class "list", from data part.
signature(object = "filterList"): Print
details about the object.
signature(object =
"filterList"): Accessor and replacement method for the object's
filterId slot.
Florian Hahne
f1 <- rectangleGate(FSC=c(100,200), filterId="testFilter") f2 <- rectangleGate(FSC=c(200,400)) fl <- filterList(list(a=f1, b=f2)) fl identifier(fl)f1 <- rectangleGate(FSC=c(100,200), filterId="testFilter") f2 <- rectangleGate(FSC=c(200,400)) fl <- filterList(list(a=f1, b=f2)) fl identifier(fl)
A reference to another filter inside a reference. Users should generally not be aware that they are using this class.
nameThe R name of the referenced filter.
envThe environment where the filter must live.
filterIdThe filterId, not really used since you always resolve.
Objects are generally not created by users so there is no constructor function.
Class "filter", directly.
B. Ellis
Container to store the result of applying a filter on a
flowFrame object
frameIdObject of class "character"
referencing the flowFrame object filtered. Used for sanity checking.
filterDetailsObject of class "list"
describing the filter applied.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
test equality
B. Ellis, N. LeMeur
filter,
"logicalFilterResult",
"multipleFilterResult",
"randomFilterResult"
showClass("filterResult")showClass("filterResult")
Container to store the result of applying a filter on a
flowSet object
.DataObject of class "list". The class
directly extends list, and this slot holds the list data.
frameIdObject of class "character" The IDs of
the flowFrames in the filtered
flowSet.
filterDetailsObject of class "list". Since
filterResultList inherits from filterResult,
this slot has to be set. It contains only the input filter.
filterIdObject of class "character". The
identifier for the object.
Objects are created by applying a filter on a
flowSet. The user doesn't have to deal with manual object
instantiation.
Class "list", from data part.
Class "filterResult", directly.
Class "concreteFilter", by class "filterResult", distance 2.
Class "filter", by class "filterResult", distance 3.
signature(x = "filterResultList", i = "ANY"): Subset
to filterResultList.
signature(x = "filterResultList", i = "ANY"): Subset
to individual filterResult.
signature(x = "filterResultList"): Accessor to
the frameId slot.
signature(object = "filterResultList"):
Return parameters on which data has been filtered.
signature(object = "filterResultList"): Print
details about the object.
signature(x = "flowSet", f =
"filterResultList"): Split a flowSet based on the
results in the filterResultlIst. See split
for details.
signature(object = "filterResultList"):
Summarize the filtering operation. This creates a
filterSummaryList
object.
Florian Hahne
filter, filterResult,
logicalFilterResult,
multipleFilterResult,
randomFilterResult
library(flowStats) ## Loading example data and creating a curv1Filter data(GvHD) dat <- GvHD[1:3] c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) ## applying the filter fres <- filter(dat, c1f) fres ## subsetting the list fres[[1]] fres[1:2] ## details about the object parameters(fres) names(fres) summary(fres) ## splitting based on the filterResults split(dat, fres)library(flowStats) ## Loading example data and creating a curv1Filter data(GvHD) dat <- GvHD[1:3] c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) ## applying the filter fres <- filter(dat, c1f) fres ## subsetting the list fres[[1]] fres[1:2] ## details about the object parameters(fres) names(fres) summary(fres) ## splitting based on the filterResults split(dat, fres)
The filters class is the container for a list of
filter objects.
The filtersList
class is the container for a list of filters objects.
filters(x) filtersList(x)filters(x) filtersList(x)
x |
A list of |
The filters class mainly
exists for displaying multiple filters/gates on one single panel(flowFrame)
of xyplot. Note that it is different from
filterList class which is to be applied to
a flowSet. In other words, filter objects of a fliterList are
to be applied to different flowFrames. However,all of filter objects
of a filters object are for one single flowFrame, more specifically for one
pair of projections(parameters).So these filters should share the common
parameters.
And filtersList is a list of filters objects, which are to be
applied to a flowSet.
A filters or filtersList object from the constructor
.DataObject of class
"list". The class directly extends list, and this slot holds
the list data.
Class "list"
Objects are created from regular lists using the constructors
filters and filtersList:
filters(x)
filtersList(x)
Mike Jiang
Class and methods to handle the summary information of a gating operation.
## S4 method for signature 'filterResult' summary(object, ...)## S4 method for signature 'filterResult' summary(object, ...)
object |
An object inheriting from class |
... |
Further arguments that are passed to the generic. |
Calling summary on a filterResult object prints summary
information on the screen, but also creates objects of class
filterSummary for computational access.
An object of class filterSummary for the summary constructor,
a named list for the subsetting operators. The $ operator returns a
named vector of the respective value, where each named element corresponds
to one sub-population.
nameObject of class "character" The name(s) of
the populations created in the filtering operation. For a
logicalFilterResult this is just a single value; the
name of the link{filter}.
trueObject of class "numeric". The number of
events within the population(s).
countObject of class "numeric". The total
number of events in the gated flowFrame.
pObject of class "numeric" The percentage of
cells in the population(s).
Objects are created by calling summary on a link{filterResult}
object. The user doesn't have to deal with manual object instantiation.
signature(x = "filterSummary", i = "numeric"):
Subset the filterSummary to a single population. This only
makes sense for
multipleFilterResults.
The output is a list of summary statistics.
signature(x = "filterSummary", i = "character"):
see above
signature(x = "filterSummary", name = "ANY"): A
list-like accessor to the slots and more. Valid values are
n and count (those are identical), true and
in (identical), false and out (identical),
name, p and q (1-p).
signature(from = "filterSummary", to =
"data.frame"): Coerce object to data.frame.
signature(x = "filterSummary"): The number of
populations in the fitlerSummary.
signature(x = "filterSummary"): The names of the
populations in the filterSummary.
signature(x = "filterSummary"): Print details
about the object.
signature(object = "filterSummary"): Print
details about the object.
signature(x = "filterSummary"): Coerce object
to data.frame.
Florian Hahne, Byron Ellis
filterResult, logicalFilterResult,
multipleFilterResult, flowFrame
filterSummaryList
library(flowStats) ## Loading example data, creating and applying a curv1Filter dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) fres <- filter(dat, c1f) ## creating and showing the summary summary(fres) s <- summary(fres) ## subsetting s[[1]] s[["peak 2"]] ##accessing details s$true s$n toTable(s)library(flowStats) ## Loading example data, creating and applying a curv1Filter dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) fres <- filter(dat, c1f) ## creating and showing the summary summary(fres) s <- summary(fres) ## subsetting s[[1]] s[["peak 2"]] ##accessing details s$true s$n toTable(s)
Class and methods to handle summary statistics for from filtering operations
on whole flowSets.
object |
An object of class.
|
... |
Further arguments that are passed to the generic. |
Calling summary on a filterResultList object prints summary
information on the screen, but also creates objects of class
filterSummaryList for computational access.
An object of class filterSummaryList.
.DataObject of class "list". The class
directly extends list, and this slot holds the list data.
summary(object, ...)
Objects are created by calling summary on a
link{filterResultList} object. The user doesn't have to deal with
manual object instantiation.
Class "list", from .Data part.
signature(x = "filterSummaryList"): Coerce
object to data.frame. Additional factors are added to
indicate list items in the original object.
Florian Hahne
filterResult, filterResultList,
logicalFilterResult,
multipleFilterResult, flowFrame
filterSummary
library(flowStats) ## Loading example data, creating and applying a curv1Filter data(GvHD) dat <- GvHD[1:3] c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) fres <- filter(dat, c1f) ## creating and showing the summary summary(fres) s <- summary(fres) ## subsetting s[[1]] ##accessing details toTable(s)library(flowStats) ## Loading example data, creating and applying a curv1Filter data(GvHD) dat <- GvHD[1:3] c1f <- curv1Filter(filterId="myCurv1Filter", x=list("FSC-H"), bwFac=2) fres <- filter(dat, c1f) ## creating and showing the summary summary(fres) s <- summary(fres) ## subsetting s[[1]] ##accessing details toTable(s)
This class represents the data contained in a FCS file or similar data structure. There are three parts of the data:
a numeric matrix of the raw measurement values with rows=events and columns=parameters
annotation for the parameters (e.g., the measurement channels, stains, dynamic range)
additional annotation provided through keywords in the FCS file
Objects of class flowFrame can be used to hold arbitrary data of cell
populations, acquired in flow-cytometry.
FCS is the Data File Standard for Flow Cytometry, the current version is FCS 3.0. See the vignette of this package for additional information on using the object system for handling of flow-cytometry data.
exprsObject of class matrix containing the
measured intensities. Rows correspond to cells, columns to the
different measurement channels. The colnames attribute of
the matrix is supposed to hold the names or identifiers for the
channels. The rownames attribute would usually not be set.
parametersAn
AnnotatedDataFrame
containing information about each column of the
flowFrame. This will generally be filled in by
read.FCS or similar functions using data from the
FCS keywords describing the parameters.
descriptionA list containing the meta data included in the FCS file.
Objects can be created using
new("flowFrame", exprs = ...., Object of class matrix
parameters = ...., Object of class AnnotatedDataFrame description
= ...., Object of class list )
or the constructor flowFrame, with mandatory arguments exprs
and optional arguments parameters and description.
flowFrame(exprs, parameters, description=list())
To create a flowFrame directly from an FCS file, use
function read.FCS. This is the recommended and
safest way of object creation, since read.FCS will perform basic data
quality checks upon import. Unless you know exactly what you are doing,
creating objects using new or the constructor is discouraged.
There are separate documentation pages for most of the methods listed here which should be consulted for more details.
Subsetting. Returns an object of class flowFrame.
The subsetting is applied to the exprs slot, while the
description slot is unchanged. The syntax for subsetting is
similar to that of data.frames. In
addition to the usual index vectors (integer and logical by
position, character by parameter names), flowFrames can be
subset via filterResult and
filter objects.
Usage:
flowFrame[i,j]
flowFrame[filter,]
flowFrame[filterResult,]
Note that the value of argument drop is ignored when
subsetting flowFrames.
Subsetting by channel name. This is similar to subsetting
of columns of data.frames, i.e.,
frame$FSC.H is equivalent to frame[, "FSC.H"]. Note
that column names may have to be quoted if they are no valid R
symbols (e.g. frame$"FSC-H").
Extract or replace the raw data
intensities. The replacement value must be a numeric matrix with
colnames matching the parameter definitions. Implicit subsetting
is allowed (i.e. less columns in the replacement value compared to
the original flowFrame, but all have to be defined there).
Usage:
exprs(flowFrame)
exprs(flowFrame) <- value
Show first/last elements of the raw data matrix
Usage:
head(flowFrame)
tail(flowFrame)
Extract the whole list
of annotation keywords and their corresponding values or replace values by keyword
(description<- is equivalent to keyword<-). Usually one would only be
interested in a subset of keywords, in which case the keyword method is
more appropriate. The optional hideInternal parameter can
be used to exclude internal FCS parameters starting
with $.
Usage:
description(flowFrame)
description(flowFrame) <- value
Extract ore replace one or more entries
from the description slot by keyword. Methods are defined
for character vectors (select a keyword by name), functions
(select a keyword by evaluating a function on their content) and
for lists (a combination of the above). See keyword
for details.
Usage:
keyword(flowFrame)
keyword(flowFrame, character)
keyword(flowFrame, list)
keyword(flowFrame) <- list(value)
Extract parameters and return an
object of class
AnnotatedDataFrame,
or replace such an object. To access the actual parameter
annotation, use pData(parameters(frame)). Replacement is
only valid with
AnnotatedDataFrames
containing all varLabels name, desc, range,
minRange and maxRange, and matching entries in the
name column to the colnames of the exprs matrix. See
parameters for more details.
Usage:
parameters(flowFrame)
parameters(flowFrame) <- value
Display details about the flowFrame object.
Return descriptive statistical summary (min, max, mean and quantile) for each channel
Usage:
summary(flowFrame)
Basic plots for flowFrame objects. If the object
has only a single parameter this produces a
histogram. For exactly two parameters
we plot a bivariate density map (see
smoothScatter
and for more than two parameters we produce a simple
splom plot. To select specific parameters
from a flowFrame for plotting, either subset the object or
specify the parameters as a character vector in the second
argument to plot. The smooth parameters lets you toggle
between density-type
smoothScatter
plots and regular scatterplots. This simple method still uses the legacy
flowViz package. For far more sophisticated
plotting of flow cytometry data, see the
ggcyto package.
Usage:
plot(flowFrame, ...)
plot(flowFrame, character, ...)
plot(flowFrame, smooth=FALSE, ...)
Extract the dimensions of the data matrix.
Usage:
ncol(flowFrame)
nrow(flowFrame)
dim(flowFrame)
. colnames and
featureNames are synonyms, they extract parameter names (i.e., the
colnames of the data matrix) .
For colnames there is
also a replacement method. This will update the name column
in the parameters slot as well.
Usage:
featureNames(flowFrame)
colnames(flowFrame)
colnames(flowFrame) <- value
Extract pretty formated names of the parameters including parameter descriptions.
Usage:
names(flowFrame)
Extract GUID of a flowFrame. Returns the
file name if no GUID is available. See identifier
for details.
Usage:
identifier(flowFrame)
Get instrument or actual data range of the flowFame. Note that
instrument dynamic range is not necessarily the same as the range of the actual data values, but
the theoretical range of values the measurement instrument was
able to capture. The values of the dynamic range will be
transformed when using the transformation methods forflowFrames.
parameters:
x: flowFrame object.
type: Range type. either "instrument" or "data". Default is "instrument"
Usage:
range(x, type = "data")
Apply functions over rows or columns of
the data matrix. These are convenience methods. See
each_col for details.
Usage:
each_row(flowFrame, function, ...)
each_col(flowFrame, function, ...)
Apply a transformation function on a
flowFrame object. This uses R's
transform function by treating the
flowFrame like a regular data.frame. flowCore
provides an additional inline mechanism for transformations (see
%on%) which is strictly more limited
than the out-of-line transformation described here.
Usage:
transform(flowFrame, translist, ...)
Apply a filter object on a
flowFrame object. This returns an object of class
filterResult, which could then be used for
subsetting of the data or to calculate summary statistics. See
filter for details.
Usage:
filter(flowFrame, filter)
Split flowFrame object according to a
filter, a filterResult or a
factor. For most types of filters, an optional
flowSet=TRUE parameter will create a
flowSet rather than a simple list. See
split for details.
Usage:
split(flowFrame, filter, flowSet=FALSE, ...)
split(flowFrame, filterResult, flowSet=FALSE, ...)
split(flowFrame, factor, flowSet=FALSE, ...)
Subset a flowFrame according to a filter
or a logical vector. The same can be done using the standard
subsetting operator with a filter, filterResult, or
a logical vector as first argument.
Usage:
Subset(flowFrame, filter)
Subset(flowFrame, logical)
Expand a flowFrame by the data in a
numeric matrix of the same length. The matrix must
have column names different from those of the
flowFrame. The additional method for numerics only
raises a useful error message.
Usage:
cbind2(flowFrame, matrix)
cbind2(flowFrame, numeric)
Apply a compensation matrix (or a
compensation object) on a flowFrame
object. This returns a compensated flowFrame.
Usage:
compensate(flowFrame, matrix)
compensate(flowFrame, data.frame)
Reverse the application of a compensation matrix (or a
compensation object) on a flowFrame
object. This returns a decompensated flowFrame.
Usage:
decompensate(flowFrame, matrix)
decompensate(flowFrame, data.frame)
Extract spillover matrix from description slot if
present. It is equivalent to
keyword(x, c("spillover", "SPILL", "$SPILLOVER"))
Thus will simply return a list of keywords value for "spillover", "SPILL" and "$SPILLOVER".
Usage:
spillover(flowFrame)
Test equality between two flowFrames
These operators basically treat the
flowFrame as a numeric matrix.
initialize(flowFrame):Object instantiation, used
by new; not to be called directly by the user.
F. Hahne, B. Ellis, P. Haaland and N. Le Meur
## load example data data(GvHD) frame <- GvHD[[1]] ## subsetting frame[1:4,] frame[,3] frame[,"FSC-H"] frame$"SSC-H" ## accessing and replacing raw values head(exprs(frame)) exprs(frame) <- exprs(frame)[1:3000,] frame exprs(frame) <- exprs(frame)[,1:6] frame ## access FCS keywords head(keyword(frame)) keyword(frame, c("FILENAME", "$FIL")) ## parameter annotation parameters(frame) pData(parameters(frame)) ## summarize frame data summary(frame) ## plotting plot(frame) if(require(flowViz)){ plot(frame) plot(frame, c("FSC-H", "SSC-H")) plot(frame[,1]) plot(frame, c("FSC-H", "SSC-H"), smooth=FALSE) } ## frame dimensions ncol(frame) nrow(frame) dim(frame) ## accessing and replacing parameter names featureNames(frame) all(featureNames(frame) == colnames(frame)) colnames(frame) <- make.names(colnames(frame)) colnames(frame) parameters(frame)$name names(frame) ## accessing a GUID identifier(frame) identifier(frame) <- "test" ## range of a frame range(frame) #instrument range range(frame, type = "data") #actual data range range(frame)$FSC.H ## iterators head(each_row(frame, mean)) head(each_col(frame, mean)) ## transformation opar <- par(mfcol=c(1:2)) if(require(flowViz)) plot(frame, c("FL1.H", "FL2.H")) frame <- transform(frame, transformList(c("FL1.H", "FL2.H"), log)) if(require(flowViz)) plot(frame, c("FL1.H", "FL2.H")) par(opar) range(frame) ## filtering of flowFrames rectGate <- rectangleGate(filterId="nonDebris","FSC.H"=c(200,Inf)) fres <- filter(frame, rectGate) summary(fres) ## splitting of flowFrames split(frame, rectGate) split(frame, rectGate, flowSet=TRUE) split(frame, fres) f <- cut(exprs(frame$FSC.H), 3) split(frame, f) ## subsetting according to filters and filter results Subset(frame, rectGate) Subset(frame, fres) Subset(frame, as.logical(exprs(frame$FSC.H) < 300)) frame[rectGate,] frame[fres,] ## accessing the spillover matrix try(spillover(frame)) ## check equality frame2 <- frame frame == frame2 exprs(frame2) <- exprs(frame)*2 frame == frame2## load example data data(GvHD) frame <- GvHD[[1]] ## subsetting frame[1:4,] frame[,3] frame[,"FSC-H"] frame$"SSC-H" ## accessing and replacing raw values head(exprs(frame)) exprs(frame) <- exprs(frame)[1:3000,] frame exprs(frame) <- exprs(frame)[,1:6] frame ## access FCS keywords head(keyword(frame)) keyword(frame, c("FILENAME", "$FIL")) ## parameter annotation parameters(frame) pData(parameters(frame)) ## summarize frame data summary(frame) ## plotting plot(frame) if(require(flowViz)){ plot(frame) plot(frame, c("FSC-H", "SSC-H")) plot(frame[,1]) plot(frame, c("FSC-H", "SSC-H"), smooth=FALSE) } ## frame dimensions ncol(frame) nrow(frame) dim(frame) ## accessing and replacing parameter names featureNames(frame) all(featureNames(frame) == colnames(frame)) colnames(frame) <- make.names(colnames(frame)) colnames(frame) parameters(frame)$name names(frame) ## accessing a GUID identifier(frame) identifier(frame) <- "test" ## range of a frame range(frame) #instrument range range(frame, type = "data") #actual data range range(frame)$FSC.H ## iterators head(each_row(frame, mean)) head(each_col(frame, mean)) ## transformation opar <- par(mfcol=c(1:2)) if(require(flowViz)) plot(frame, c("FL1.H", "FL2.H")) frame <- transform(frame, transformList(c("FL1.H", "FL2.H"), log)) if(require(flowViz)) plot(frame, c("FL1.H", "FL2.H")) par(opar) range(frame) ## filtering of flowFrames rectGate <- rectangleGate(filterId="nonDebris","FSC.H"=c(200,Inf)) fres <- filter(frame, rectGate) summary(fres) ## splitting of flowFrames split(frame, rectGate) split(frame, rectGate, flowSet=TRUE) split(frame, fres) f <- cut(exprs(frame$FSC.H), 3) split(frame, f) ## subsetting according to filters and filter results Subset(frame, rectGate) Subset(frame, fres) Subset(frame, as.logical(exprs(frame$FSC.H) < 300)) frame[rectGate,] frame[fres,] ## accessing the spillover matrix try(spillover(frame)) ## check equality frame2 <- frame frame == frame2 exprs(frame2) <- exprs(frame)*2 frame == frame2
This is a simple helper function for splitting a flowSet
in to a list of its constituent flowFrames.
flowSet_to_list(fs)flowSet_to_list(fs)
fs |
a flowSet |
a list of flowFrames
This class is a container for a set of flowFrame
objects
framesAn environment
containing one or more flowFrame objects.
phenoDataAn
AnnotatedDataFrame
containing the phenotypic data for the whole data set. Each row
corresponds to one of the flowFrames in the
frames slot. The sampleNames of phenoData
(see below) must match the names of the
flowFrame in the frames environment.
Objects can be created using new('flowSet', frames =
...., # environment with flowFrames phenoData = .... # object of
class AnnotatedDataFrame colnames = .... # object of class
character )
or via the constructor flowSet, which takes arbitrary numbers of
flowFrames, either as a list or directly as arguments, along with an
optional AnnotatedDataFrame
for the phenoData slot and a character scalar for the
name by which the object can be referenced.
flowSet(..., phenoData)
Alternatively, flowSets can be coerced from list and
environment objects.
as(list("A"=frameA,"B"=frameB),"flowSet")
The safest and easiest way to create flowSets directly from
FCS files is via the read.flowSet function, and
there are alternative ways to specify the files to read. See the separate
documentation for details.
Subsetting. x[i] where i is a scalar,
returns a flowSet object, and x[[i]] a
flowFrame object. In this respect the
semantics are similar to the behavior of the subsetting operators
for lists. x[i, j] returns a flowSet for which the
parameters of each flowFrame have been subset
according to j, x[[i,j]] returns the subset of a
single flowFrame for all parameters in
j. Similar to data frames, valid values for i and
j are logicals, integers and characters.
Usage:
flowSet[i]
flowSet[i,j]
flowSet[[i]]
Subsetting by frame name. This will return a single
flowFrame object. Note that names may have to
be quoted if they are no valid R symbols
(e.g. flowSet$"sample 1"
Extract or replace the colnames
slot.
Usage:
colnames(flowSet)
colnames(flowSet) <- value
Extract or replace the name
item from the environment.
Usage:
identifier(flowSet)
identifier(flowSet) <- value
Extract or replace the
AnnotatedDataFrame
from the phenoData slot.
Usage:
phenoData(flowSet)
phenoData(flowSet) <- value
Extract or replace the data frame (or columns
thereof) containing actual phenotypic information from the
phenoData slot.
Usage:
pData(flowSet)
pData(flowSet)$someColumn <- value
Extract and set varLabels in the
AnnotatedDataFrame
of the phenoData slot.
Usage:
varLabels(flowSet)
varLabels(flowSet) <- value
Extract and replace sample names from the
phenoData object. Sample names correspond to frame
identifiers, and replacing them will also replace the GUID
slot for each frame. Note that sampleName need to be
unique.
Usage:
sampleNames(flowSet)
sampleNames(flowSet) <- value
Extract or replace keywords specified in a character
vector or a list from the description slot of each
frame. See keyword for details.
Usage:
keyword(flowSet, list(keywords))
keyword(flowSet, keywords)
keyword(flowSet) <- list(foo="bar")
number of flowFrame objects in
the set.
Usage:
length(flowSet)
display object summary.
Return descriptive statistical summary (min, max,
mean and quantile) for each channel of each
flowFrame
Usage:
summary(flowSet)
Apply a function on all frames in a flowSet
object. Similar to sapply, but with additional
parameters. See separate documentation for details.
Usage:
fsApply(flowSet, function, ...)
fsApply(flowSet, function, use.exprs=TRUE, ...)
Apply a compensation matrix on all frames in a
flowSet object. See separate documentation for details.
Usage:
compensate(flowSet, matrix)
Apply a transformation function on all frames of a
flowSet object. See separate documentation for details.
Usage:
transform(flowSet, ...)
Apply a filter object on a flowSet
object. There are methods for filters
and lists of filters. The latter has to
be a named list, where names of the list items are matching
sampleNames of the flowSet. See filter
for details.
Usage:
filter(flowSet, filter)
filter(flowSet, list(filters))
Split all flowSet objects according to a
filter, filterResult or a list of such
objects, where the length of the list has to be the same as the
length of the flowSet. This returns a list of
flowFrames or an object of class
flowSet if the flowSet argument is set to
TRUE. Alternatively, a flowSet can be split into
separate subsets according to a factor (or any vector that can be
coerced into factors), similar to the behaviour of
split for lists. This will return a list of
flowSets. See split for details.
Usage:
split(flowSet, filter)
split(flowSet, filterResult)
split(flowSet, list(filters))
split(flowSet, factor)
Returns a flowSet of
flowFrames that have been subset according
to a filter or
filterResult, or according to a list of such
items of equal length as the flowSet.
Usage:
Subset(flowSet, filter)
Subset(flowSet, filterResult)
Subset(flowSet, list(filters))
Combine two flowSet objects, or one
flowSet and one flowFrame object.
Usage:
rbind2(flowSet, flowSet)
rbind2(flowSet, flowFrame)
Compute spillover matrix from a compensation set. See separate documentation for details.
The bulk of the data in a flowSet object is stored in an
environment, and is therefore not
automatically copied when the flowSet object is copied. If
x is an object of class flowSet, then the code
y <- x
will create an object y that contains
copies of the phenoData and administrative data in x,
but refers to the same environment with the actual fluorescence
data. See below for how to create proper copies.
The reason for this is performance. The pass-by-value semantics of
function calls in R can result in numerous copies of the same
data object being made in the course of a series of nested function
calls. If the data object is large, this can result in considerable
cost of memory and performance. flowSet objects are intended to
contain experimental data in the order of hundreds of Megabytes, which
can effectively be treated as read-only: typical tasks are the
extraction of subsets and the calculation of summary statistics. This
is afforded by the design of the flowSet class: an object of
that class contains a phenoData slot, some administrative
information, and a reference to an environment with the
fluorescence data; when it is copied, only the reference is copied,
but not the potentially large set of fluorescence data themselves.
However, note that subsetting operations, such as y <- x[i] do
create proper copies, including a copy of the appropriate part of the
fluorescence data, as it should be expected. Thus, to make a proper
copy of a flowSet x, use y <- x[seq(along=x)]
F. Hahne, B. Ellis, P. Haaland and N. Le Meur
## load example data and object creation data(GvHD) ## subsetting to flowSet set <- GvHD[1:4] GvHD[1:4,1:2] sel <- sampleNames(GvHD)[1:2] GvHD[sel, "FSC-H"] GvHD[sampleNames(GvHD) == sel[1], colnames(GvHD[1]) == "SSC-H"] ## subsetting to flowFrame GvHD[[1]] GvHD[[1, 1:3]] GvHD[[1, "FSC-H"]] GvHD[[1, colnames(GvHD[1]) == "SSC-H"]] GvHD$s5a02 ## constructor flowSet(GvHD[[1]], GvHD[[2]]) pd <- phenoData(GvHD)[1:2,] flowSet(s5a01=GvHD[[1]], s5a02=GvHD[[2]],phenoData=pd) ## colnames colnames(set) colnames(set) <- make.names(colnames(set)) ## object name identifier(set) identifier(set) <- "test" ## phenoData pd <- phenoData(set) pd pd$test <- "test" phenoData(set) <- pd pData(set) varLabels(set) varLabels(set)[6] <- "Foo" varLabels(set) ## sampleNames sampleNames(set) sampleNames(set) <- LETTERS[1:length(set)] sampleNames(set) ## keywords keyword(set, list("transformation")) ## length length(set) ## compensation samp <- read.flowSet(path=system.file("extdata","compdata","data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat summary(samp[[1]]) samp <- compensate(samp, as.matrix(comp.mat)) summary(samp[[1]]) ## transformation opar <- par(mfcol=c(1:2)) plot(set[[1]], c("FL1.H", "FL2.H")) set <- transform(set, transformList(c("FL1.H", "FL2.H"), log)) plot(set[[1]], c("FL1.H", "FL2.H")) par(opar) ## filtering of flowSets rectGate <- rectangleGate(filterId="nonDebris", FSC.H=c(200,Inf)) fres <- filter(set, rectGate) class(fres) summary(fres[[1]]) rectGate2 <- rectangleGate(filterId="nonDebris2", SSC.H=c(300,Inf)) fres2 <- filter(set, list(A=rectGate, B=rectGate2, C=rectGate, D=rectGate2)) ## Splitting frames of a flowSet split(set, rectGate) split(set[1:2], rectGate, populatiuon="nonDebris2+") split(set, c(1,1,2,2)) ## subsetting according to filters and filter results Subset(set, rectGate) Subset(set, filter(set, rectGate)) Subset(set, list(A=rectGate, B=rectGate2, C=rectGate, D=rectGate2)) ## combining flowSets rbind2(set[1:2], set[3:4]) rbind2(set[1:3], set[[4]]) rbind2(set[[4]], set[1:2])## load example data and object creation data(GvHD) ## subsetting to flowSet set <- GvHD[1:4] GvHD[1:4,1:2] sel <- sampleNames(GvHD)[1:2] GvHD[sel, "FSC-H"] GvHD[sampleNames(GvHD) == sel[1], colnames(GvHD[1]) == "SSC-H"] ## subsetting to flowFrame GvHD[[1]] GvHD[[1, 1:3]] GvHD[[1, "FSC-H"]] GvHD[[1, colnames(GvHD[1]) == "SSC-H"]] GvHD$s5a02 ## constructor flowSet(GvHD[[1]], GvHD[[2]]) pd <- phenoData(GvHD)[1:2,] flowSet(s5a01=GvHD[[1]], s5a02=GvHD[[2]],phenoData=pd) ## colnames colnames(set) colnames(set) <- make.names(colnames(set)) ## object name identifier(set) identifier(set) <- "test" ## phenoData pd <- phenoData(set) pd pd$test <- "test" phenoData(set) <- pd pData(set) varLabels(set) varLabels(set)[6] <- "Foo" varLabels(set) ## sampleNames sampleNames(set) sampleNames(set) <- LETTERS[1:length(set)] sampleNames(set) ## keywords keyword(set, list("transformation")) ## length length(set) ## compensation samp <- read.flowSet(path=system.file("extdata","compdata","data", package="flowCore")) cfile <- system.file("extdata","compdata","compmatrix", package="flowCore") comp.mat <- read.table(cfile, header=TRUE, skip=2, check.names = FALSE) comp.mat summary(samp[[1]]) samp <- compensate(samp, as.matrix(comp.mat)) summary(samp[[1]]) ## transformation opar <- par(mfcol=c(1:2)) plot(set[[1]], c("FL1.H", "FL2.H")) set <- transform(set, transformList(c("FL1.H", "FL2.H"), log)) plot(set[[1]], c("FL1.H", "FL2.H")) par(opar) ## filtering of flowSets rectGate <- rectangleGate(filterId="nonDebris", FSC.H=c(200,Inf)) fres <- filter(set, rectGate) class(fres) summary(fres[[1]]) rectGate2 <- rectangleGate(filterId="nonDebris2", SSC.H=c(300,Inf)) fres2 <- filter(set, list(A=rectGate, B=rectGate2, C=rectGate, D=rectGate2)) ## Splitting frames of a flowSet split(set, rectGate) split(set[1:2], rectGate, populatiuon="nonDebris2+") split(set, c(1,1,2,2)) ## subsetting according to filters and filter results Subset(set, rectGate) Subset(set, filter(set, rectGate)) Subset(set, list(A=rectGate, B=rectGate2, C=rectGate, D=rectGate2)) ## combining flowSets rbind2(set[1:2], set[3:4]) rbind2(set[1:3], set[[4]]) rbind2(set[[4]], set[1:2])
Append data columns to a flowFrame
fr_append_cols(fr, cols)fr_append_cols(fr, cols)
fr |
A |
cols |
A numeric matrix containing the new data columns to be added. Must have unique column names to be used as new channel names. |
It is used to add extra data columns to the existing flowFrame. It handles
keywords and parameters properly to ensure the new flowFrame can be written
as a valid FCS through the function write.FCS .
Mike Jiang
data(GvHD) tmp <- GvHD[[1]] kf <- kmeansFilter("FSC-H"=c("Pop1","Pop2","Pop3"), filterId="myKmFilter") fres <- filter(tmp, kf) cols <- as.integer(fres@subSet) cols <- matrix(cols, dimnames = list(NULL, "km")) tmp <- fr_append_cols(tmp, cols) tmpfile <- tempfile() write.FCS(tmp, tmpfile)data(GvHD) tmp <- GvHD[[1]] kf <- kmeansFilter("FSC-H"=c("Pop1","Pop2","Pop3"), filterId="myKmFilter") fres <- filter(tmp, kf) cols <- as.integer(fres@subSet) cols <- matrix(cols, dimnames = list(NULL, "km")) tmp <- fr_append_cols(tmp, cols) tmpfile <- tempfile() write.FCS(tmp, tmpfile)
fsApply, like many of the apply-style functions in R, acts as an
iterator for flowSet objects, allowing the application of a function
to either the flowFrame or the data matrix itself. The output can then
be reconstructed as either a flowSet, a list, or a matrix depending on
options and the type of objects returned.
fsApply(x, FUN, ..., simplify=TRUE, use.exprs=FALSE)fsApply(x, FUN, ..., simplify=TRUE, use.exprs=FALSE)
x |
|
FUN |
the function to be applied to each element of |
... |
optional arguments to |
simplify |
logical (default: TRUE); if all true and all objects are
|
use.exprs |
logical (default: FALSE); should the |
B. Ellis
fcs.loc <- system.file("extdata",package="flowCore") file.location <- paste(fcs.loc, dir(fcs.loc), sep="/") samp <- read.flowSet(file.location[1:3]) #Get summary information about each sample. fsApply(samp,summary) #Obtain the median of each parameter in each frame. fsApply(samp,each_col,median)fcs.loc <- system.file("extdata",package="flowCore") file.location <- paste(fcs.loc, dir(fcs.loc), sep="/") samp <- read.flowSet(file.location[1:3]) #Get summary information about each sample. fsApply(samp,summary) #Obtain the median of each parameter in each frame. fsApply(samp,each_col,median)
flowFrame that matches to the given keywordThis function tries best to guess the flow parameter based on the keyword supplied by name
It first does a complete word match(case insensitive) between name and flow channels and markers.
If there are duplcated matches, throw the error. If no matches, it will try the partial match.
getChannelMarker(frm, name, ...)getChannelMarker(frm, name, ...)
frm |
|
name |
|
... |
other arguments: not used. |
an one-row data.frame that contains "name"(i.e. channel) and "desc"(i.e. stained marker) columns.
Retrieve a data frame of index sorted data and sort indices from an FCS file.
The input FCS file should already be compensated. Index sorting permits
association of cell-level fluorescence intensities with downstream data
collection on the sorted cells. Cells are sorted into a plate with
X,Y coordinates, and those coordinates are stored in the FCS file.
This function will extract the data frame of flow data and the X,Y
coordinates for the cell-level data, which can be written to a text file, or
concatenated with sample-level information and analyzed in R. The
coordinates are names 'XLoc','YLoc', and a 'name' column is also prepended
with the FCS file name.
Matrix of fluorescence intensities and sort indices for plate location. When no index sorting data is available, invisibly returns 0. Test for 0 to check success.
Return a matrix of fluorescence intensities and indices into the sorting plate for each cell.
G. Finak
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) # This will return a message that no index sorting data is available getIndexSort(samp)samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) # This will return a message that no index sorting data is available getIndexSort(samp)
A flow cytometry high throughput screening was used to identify biomarkers that would predict the development of GvHD. The GvHD dataset is an extract of a collection of weekly peripheral blood samples obtained from patients following allogenic blood and marrow transplant. Samples were taken at various time points before and after graft.
data(GvHD)data(GvHD)
The format is an object of class flowSet composed of 35
flowFrames. Each flowFrame corresponds to one sample at one
time point.
The phenodata lists:
The patient Id code
The number of visits to the hospital
The number of days since the graft. Negative values correpond to days before the graft.
Grade of the cancer
This GvHD dataset represents the measurements of one biomarker (leukocyte) for 5 patients over 7 visits (7 time points). The blood samples were labeled with four different fluorescent probes to identify the biomarker and the fluorescent intensity was determined for at least ten thousand cells per sample.
Complete dataset available at http://www.ficcs.org/software.html#Data_Files, the Flow Informatics and Computational Cytometry Society website (FICCS)
Rizzieri DA et al. J Clin Oncol. 2007 Jan 16; [Epub ahead of print] PMID: 17228020
Hyperlog transformation of a parameter is defined by the function
where EH is a function defined by
.DataObject of class "function".
aObject of class "numeric" – numeric constant
treater than zero.
bObject of class "numeric" numeric constant greater than zero.
parametersObject of class "transformation" – flow parameter to be
transformed.
transformationIdObject of class "character" – unique ID to
reference the transformation.
Objects can be created by calls to the
constructor hyperlog(parameter,a,b,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
EHtrans
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) hlog1<-hyperlog("FSC-H",a=1,b=1,transformationId="hlog1") transOut<-eval(hlog1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) hlog1<-hyperlog("FSC-H",a=1,b=1,transformationId="hlog1") transOut<-eval(hlog1)(exprs(dat))
Hyperlog transformation parameterized according to Gating-ML 2.0.
hyperlogtGml2 is defined by the following function:
where
and
is defined as:
where
x is the value that is being transformed (an FCS dimension value). Typically, x is less than or equal to T, although the transformation function is also defined for x greater than T.
y is the result of the transformation.
T is greater than zero and represents the top of scale value.
M is greater than zero and represents the number of decades that the true logarithmic scale approached at the high end of the Hyperlog scale would cover in the plot range.
W is positive and not greater than half of M and represents the number of such decades in the approximately linear region.
A is the number of additional decades of negative data values to be included. A
shall be greater than or equal to , and less than or equal to
root is a standard root finding algorithm (e.g., Newton's
method) that finds y such as .
and ,
, and are defined by means of , ,
, , , , , , ,
and as:
In addition, if a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the hyperlog function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the hyperlog function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
TObject of class numeric – positive constant (top of scale value).
MObject of class numeric – positive constant (desired number of decades).
WObject of class numeric – positive constant that is not greater than half of M
(the number of such decades in the approximately linear region)
AObject of class numeric – a constant that is greater than or equal to -W, and also
less than or equal to M-2W. (A represents the number of additional decades of negative data values to
be included.)
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
hyperlogtGml2(parameter, T, M, W, A, transformationId, boundMin,
boundMax)
Class singleParameterTransform, directly.
Class transform, by class singleParameterTransform, distance 2.
Class transformation, by class singleParameterTransform, distance 3.
Class characterOrTransformation, by class singleParameterTransform, distance 4.
That hyperlogtGml2 transformation brings "reasonable" data
values to the scale of . The transformation is somewhat similar
to logicletGml2. (See Gating-ML 2.0 for detailed comparison)
The hyperlog transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Spidlen, J., Moore, W.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
hyperlog, logicleTransform,
transform-class, transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myHyperLg <- hyperlogtGml2(parameters = "FSC-H", T = 1023, M = 4.5, W = 0.5, A = 0, transformationId="myHyperLg") transOut <- eval(myHyperLg)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myHyperLg <- hyperlogtGml2(parameters = "FSC-H", T = 1023, M = 4.5, W = 0.5, A = 0, transformationId="myHyperLg") transOut <- eval(myHyperLg)(exprs(myDataIn))
Retrieve the GUID (globally unique identifier) of a flowFrame
that was generated by the cytometer or the identifier of a
filter or filterResult given by
the analyst.
identifier(object)identifier(object)
object |
Object of class |
GUID or Globally Unique Identifier is a pseudo-random number used in software applications. While each generated GUID is not guaranteed to be unique, the total number of unique keys (2\^128) is so large that the probability of the same number being generated twice is very small.
Note that if no GUID has been recorded along with the FCS file, the name of the file is returned.
Character vector representing the GUID or the name of the file.
Return identifier of a filter
object.
Return identifier of a
filterReference object.
Return identifier of a
filterResult object.
Return identifier of a
transform object.
Return GUID from the description slot of
a flowFrame object or, alternatively, the name of the
input FCS file in case none can be found. For
flowFrame objects there also exists a replacement
method.
N. LeMeur
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) identifier(samp)samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) identifier(samp)
This class represents the intersection of two filters, which is itself a filter
that can be incorporated in to further set operations. intersectFilters
are constructed using the binary set operator "&" with operands consisting
of a single filter or list of filters.
filtersObject of class "list", containing the component filters.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
B. Ellis
Other setOperationFilter classes:
complementFilter-class,
setOperationFilter-class,
subsetFilter-class,
unionFilter-class
inverseLogicleTransform can be use to compute the inverse of the Logicle transformation. The parameters w, t, m, a for calculating the inverse are obtained from the 'trans' input passed to the 'inverseLogicleTransform' function. (The inverseLogicleTransform method makes use of the C++ implementation of the inverse logicle transform contributed by Wayne Moore et al.)
inverseLogicleTransform(trans,transformationId,...)inverseLogicleTransform(trans,transformationId,...)
trans |
An object of class 'transform' created using the 'logicleTransform' function or class 'transformList' created by 'estimateLogicle'. The parameters w, t, m, a for calculating the inverse are obtained from the 'trans' input passed to the 'inverseLogicleTransform' function. |
transformationId |
A name to assigned to the inverse transformation. Used by the transform routines. |
... |
not used. |
Wayne Moore, N. Gopalakrishnan
Parks D.R., Roederer M., Moore W.A.(2006) A new "logicle" display method avoids deceptive effects of logarithmic scaling for low signals and compensated data. CytometryA, 96(6):541-51.
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
data(GvHD) samp <- GvHD[[1]] #########inverse the transform object############### logicle <- logicleTransform(t = 10000, w = 0.5, m = 4.5 , a =0 ,"logicle") ## transform FL1-H parameter using logicle transformation after <- transform(samp, transformList('FL1-H', logicle)) ## Inverse transform the logicle transformed data to retrieve the original data invLogicle <- inverseLogicleTransform(trans = logicle) before <- transform (after, transformList('FL1-H', invLogicle)) #########inverse the transformList object############### translist <- estimateLogicle(samp, c("FL1-H", "FL2-H")) after <- transform(samp, translist) ## Inverse invLogicle <- inverseLogicleTransform(translist) before <- transform (after, invLogicle)data(GvHD) samp <- GvHD[[1]] #########inverse the transform object############### logicle <- logicleTransform(t = 10000, w = 0.5, m = 4.5 , a =0 ,"logicle") ## transform FL1-H parameter using logicle transformation after <- transform(samp, transformList('FL1-H', logicle)) ## Inverse transform the logicle transformed data to retrieve the original data invLogicle <- inverseLogicleTransform(trans = logicle) before <- transform (after, transformList('FL1-H', invLogicle)) #########inverse the transformList object############### translist <- estimateLogicle(samp, c("FL1-H", "FL2-H")) after <- transform(samp, translist) ## Inverse invLogicle <- inverseLogicleTransform(translist) before <- transform (after, invLogicle)
As its name suggests, the inverse split scale transformation class represents the inverse transformation of a split scale transformation that has a logarithmic scale at high values and a linear scale at low values.
The inverse split scale transformation is defined by the function
where
.DataObject of class "function".
rObject of class "numeric" – a positive value indicating
the range of the logarithmic part of the dispmlay.
maxValueObject of class "numeric" – a positive value
indicating the maximum value the transformation is applied to.
transitionChannelObject of class "numeric" – non negative
value that indicates where to split the linear vs. logarithmic transformation.
parametersObject of class "transformation" – flow parameter
to be transformed.
transformationIdObject of class "character" – unique ID to
reference the transformation.
Objects can be created by calls to the
constructor
invsplitscale(parameters,r,maxValue,transitionChannel,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N,F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry
splitscale
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) sp1<-invsplitscale("FSC-H",r=512,maxValue=2000,transitionChannel=512) transOut<-eval(sp1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) sp1<-invsplitscale("FSC-H",r=512,maxValue=2000,transitionChannel=512) transOut<-eval(sp1)(exprs(dat))
Accessor and replacement methods for items in the description slot (usually
read in from a FCS file header). It lists the keywords and its values
for a flowFrame specified by a character vector. Additional methods for
function and lists exists for more programmatic access to the
keywords.
keyword(object, keyword, ...)keyword(object, keyword, ...)
object |
Object of class |
keyword |
Character vector or list of potential keywords or function. If missing all keywords are returned. |
... |
compact: logical scaler to indicate whether to hide all the cytometer instrument and laser settings from keywords. |
The keyword methods allow access to the keywords stored in the FCS
files, either for a flowFrame or for a list of frames in a
flowSet. The most simple use case is to provide a character vector or
a list of character strings of keyword names. A more sophisticated version
is to provide a function which has to take one mandatory argument, the value
of this is the flowFrame. This can be used to query arbitrary
information from the flowFrames description slot or even the
raw data. The function has to return a single character string. The
list methods allow to combine functional and direct keyword access.
The replacement method takes a named character vector or a named list as
input.
Return values for
all keywords from the description slot in object that match
the character vector keyword.
Apply the function in
keyword on the flowFrame object. The function
needs to be able to cope with a single argument and it needs to return a
single character string. A typical use case is for instance to paste
together values from several different keywords or to compute some statistic
on the flowFrame and combine it with one or several other keywords.
Combine characters and functions in a list to select keyword values.
This is essentially an
alias for description and returns all keyword-value pairs.
This is a wrapper around
fsApply(object, keyword, keyword) which essentially iterates over the
frames in the flowSet.
This first coerces the
keyword (mostly a character vector) to a list and then calls the next
applicable method.
N LeMeur,F Hahne,B Ellis
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) keyword(samp) keyword(samp, compact = TRUE) keyword(samp, "FCSversion") keyword(samp, function(x,...) paste(keyword(x, "SAMPLE ID"), keyword(x, "GUID"), sep="_")) keyword(samp)[["foo"]] <- "bar" data(GvHD) keyword(GvHD, list("GUID", cellnumber=function(x) nrow(x)))samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) keyword(samp) keyword(samp, compact = TRUE) keyword(samp, "FCSversion") keyword(samp, function(x,...) paste(keyword(x, "SAMPLE ID"), keyword(x, "GUID"), sep="_")) keyword(samp)[["foo"]] <- "bar" data(GvHD) keyword(GvHD, list("GUID", cellnumber=function(x) nrow(x)))
A filter that performs one-dimensional k-means (Lloyd-Max) clustering on a single flow parameter.
kmeansFilter(..., filterId="defaultKmeansFilter")kmeansFilter(..., filterId="defaultKmeansFilter")
... |
or
If the parameter is not fully realized, but instead is the result of a
|
filterId |
An optional parameter that sets the |
The one-dimensional k-means filter is a multiple population filter capable
of operating on a single flow parameter. It takes a parameter argument
associated with two or more populations and results in the generation of an
object of class multipleFilterResult. Populations are
considered to be ordered such that the population with the smallest mean
intensity will be the first population in the list and the population with
the highest mean intensity will be the last population listed.
Returns a kmeansFilter object for use in filtering
flowFrames or other flow cytometry
objects.
populationsObject of class character. The
names of the k populations (or clusters) that will be
created by the kmeansFilter. These names will later be used
for the respective subpopulations in split
operations and for the summary of the filterResult.
parametersObject of class parameters,
defining a single parameter for which the data in the
flowFrame is to be clustered. This may also
be a transformation object.
filterIdObject of class character, an
identifier or name to reference the kmeansFilter object
later on.
Class parameterFilter, directly.
Class concreteFilter, by class parameterFilter,
distance 2.
Class filter, by class parameterFilter,
distance3.
Like all other filter objects in flowCore,
kmeansFilter objects should be instantiated through their
constructor kmeansFilter(). See the Usage section for
details.
signature(x = "flowFrame", table =
"kmeansFilter"): The workhorse used to evaluate the filter on
data.
Usage:
This is usually not called directly by the user, but internally by
the filter methods.
signature(object = "kmeansFilter"): Print
information about the filter.
Usage:
The method is called automatically whenever the object is printed on the screen.
See the documentation in the flowViz
package for plotting of kmeansFilters.
F. Hahne, B. Ellis, N. LeMeur
flowFrame, flowSet, filter for
evaluation of kmeansFilters and split for splitting of
flow cytometry data sets based on the result of the filtering operation.
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create the filter kf <- kmeansFilter("FSC-H"=c("Pop1","Pop2","Pop3"), filterId="myKmFilter") ## Filtering using kmeansFilters fres <- filter(dat, kf) fres summary(fres) names(fres) ## The result of quadGate filtering are multiple sub-populations ## and we can split our data set accordingly split(dat, fres) ## We can limit the splitting to one or several sub-populations split(dat, fres, population="Pop1") split(dat, fres, population=list(keep=c("Pop1","Pop2")))## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create the filter kf <- kmeansFilter("FSC-H"=c("Pop1","Pop2","Pop3"), filterId="myKmFilter") ## Filtering using kmeansFilters fres <- filter(dat, kf) fres summary(fres) names(fres) ## The result of quadGate filtering are multiple sub-populations ## and we can split our data set accordingly split(dat, fres) ## We can limit the splitting to one or several sub-populations split(dat, fres, population="Pop1") split(dat, fres, population=list(keep=c("Pop1","Pop2")))
Create the definition of the linear Transformation that will be applied on
some parameter via the transform method. The definition of this
function is currently x <- a*x+b
linearTransform(transformationId="defaultLinearTransform", a = 1, b = 0)linearTransform(transformationId="defaultLinearTransform", a = 1, b = 0)
transformationId |
character string to identify the transformation |
a |
double that corresponds to the multiplicative factor in the equation |
b |
double that corresponds to the additive factor in the equation |
Returns an object of class transform.
N. LeMeur
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) linearTrans <- linearTransform(transformationId="Linear-transformation", a=2, b=0) dataTransform <- transform(samp, transformList('FSC-H' ,linearTrans))samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) linearTrans <- linearTransform(transformationId="Linear-transformation", a=2, b=0) dataTransform <- transform(samp, transformList('FSC-H' ,linearTrans))
Linear transformation as parameterized in Gating-ML 2.0.
lintGml2 is defined by the following function:
where
This transformation provides a linear display that maps scale values from
the interval to the interval. However, it is
defined for all including outside of the
interval.
In addition, if a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the f function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the f function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
TObject of class numeric – positive constant (top of scale value).
AObject of class numeric – non-negative constant that is less than or equal
to T; it is determining the bottom end of the transformation.
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
lintGml2(parameter, T, A, transformationId, boundMin, boundMax)
Class singleParameterTransform, directly.
Class transform, by class singleParameterTransform, distance 2.
Class transformation, by class singleParameterTransform, distance 3.
Class characterOrTransformation, by class singleParameterTransform, distance 4.
The linear transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Spidlen, J.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
linearTransform, transform-class,
transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLinTr1 <- lintGml2(parameters = "FSC-H", T = 1000, A = 0, transformationId="myLinTr1") transOut <- eval(myLinTr1)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLinTr1 <- lintGml2(parameters = "FSC-H", T = 1000, A = 0, transformationId="myLinTr1") transOut <- eval(myLinTr1)(exprs(myDataIn))
Create the definition of the ln Transformation that will be applied on some
parameter via the transform method. The definition of this function
is currently x<-log(x)*(r/d). The transformation would normally be used to
convert to a linear valued parameter to the natural logarithm scale.
Typically r and d are both equal to 1.0. Both must be positive.
lnTransform(transformationId="defaultLnTransform", r=1, d=1)lnTransform(transformationId="defaultLnTransform", r=1, d=1)
transformationId |
character string to identify the transformation |
r |
positive double that corresponds to a scale factor. |
d |
positive double that corresponds to a scale factor |
Returns an object of class transform.
B. Ellis and N. LeMeur
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
data(GvHD) lnTrans <- lnTransform(transformationId="ln-transformation", r=1, d=1) ln1 <- transform(GvHD, transformList('FSC-H', lnTrans)) opar = par(mfcol=c(2, 1)) plot(density(exprs(GvHD[[1]])[ ,1]), main="Original") plot(density(exprs(ln1[[1]])[ ,1]), main="Ln Transform")data(GvHD) lnTrans <- lnTransform(transformationId="ln-transformation", r=1, d=1) ln1 <- transform(GvHD, transformList('FSC-H', lnTrans)) opar = par(mfcol=c(2, 1)) plot(density(exprs(GvHD[[1]])[ ,1]), main="Original") plot(density(exprs(ln1[[1]])[ ,1]), main="Ln Transform")
Logartithmic transform class, which represents a transformation defined by the function
.DataObject of class "function"
aObject of class "numeric" – non-zero multiplicative constant.
bObject of class "numeric" – non-zero multiplicative constant.
parametersObject of class "transformation" – flow parameters to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
Objects can be created by calls to the
constructor logarithm(parameters,a,b,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The logarithm transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
exponential, quadratic
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) lg1<-logarithm(parameters="FSC-H",a=2,b=1,transformationId="lg1") transOut<-eval(lg1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) lg1<-logarithm(parameters="FSC-H",a=2,b=1,transformationId="lg1") transOut<-eval(lg1)(exprs(dat))
Container to store the result of applying a filter on a
flowFrame object
subSetObject of class "numeric", which is a logical
vector indicating the population membership of the data in the gated
flowFrame.
frameIdObject of class "character" referencing the
flowFrame object filtered. Used for sanity checking.
filterDetailsObject of class "list" describing the filter
applied.
filterIdObject of class "character" referencing the filter
applied.
Class "filterResult", directly.
Class "filter", by class "filterResult", distance 2.
B. Ellis
showClass("logicalFilterResult")showClass("logicalFilterResult")
Logicle transformation as published by Moore and Parks.
logicletGml2 is defined by the following function:
where
and
is a modified biexponential function:
where
x is the value that is being transformed (an FCS dimension value). Typically, x is less than or equal to T, although the transformation function is also defined for x greater than T.
y is the result of the transformation.
T is greater than zero and represents the top of scale value.
M is greater than zero and represents the number of decades that the true logarithmic scale approached at the high end of the Logicle scale would cover in the plot range.
W is non-negative and not greater than half of M and represents the
number of such decades in the approximately linear region. The choice of
specifies a scale that is essentially linear over the whole
range except for a small region of large data values. For situations in which
values of W approaching might be chosen, ordinary linear display scales
will usually be more appropriate. The choice of gives essentially the
hyperbolic sine function.
A is the number of additional decades of negative data
values to be included. A shall be greater than or equal to , and
less than or equal to
root is a standard root finding
algorithm (e.g., Newton's method) that finds y such as .
and , , , and are defined by
means of , , , , , , ,
, and as:
and
is a constant so that
given
and , and
The Logicle scale is the inverse of a modified biexponential function. It
provides a Logicle display that maps scale values onto the
interval such that the data value is mapped to 1, large data values
are mapped to locations similar to an (M + A)-decade logarithmic scale, and
A decades of negative data are brought on scale. For implementation
purposes, it is recommended to follow guidance in Moore and Parks
publication.
In addition, if a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the logicle function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the logicle function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
TObject of class numeric – positive constant (top of scale value).
MObject of class numeric – positive constant (desired number of decades).
WObject of class numeric – non-negative constant that is not greater than half of M
(the number of such decades in the approximately linear region).
AObject of class numeric – a constant that is greater than or equal to -W, and also
less than or equal to M-2W. (A represents the number of additional decades of negative data values to
be included.)
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
logicletGml2(parameter, T, M, W, A, transformationId, boundMin,
boundMax)
Class singleParameterTransform, directly.
Class transform, by class singleParameterTransform, distance 2.
Class transformation, by class singleParameterTransform, distance 3.
Class characterOrTransformation, by class singleParameterTransform, distance 4.
Please note that logicletGml2 and
logicleTransform are similar transformations; however, the
Gating-ML 2.0 compliant logicletGml2 brings "reasonable" data values
to the scale of while the logicleTransform scales
these values to .
The logicle transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Spidlen, J., Moore, W.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
Moore, WA and Parks, DR. Update for the logicle data scale including operational code implementations. Cytometry A., 2012:81A(4):273-277.
Parks, DR and Roederer, M and Moore, WA. A new "Logicle" display method avoids deceptive effects of logarithmic scaling for low signals and compensated data. Cytometry A., 2006:69(6):541-551.
logicleTransform, transform-class,
transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLogicle <- logicletGml2(parameters = "FSC-H", T = 1023, M = 4.5, W = 0.5, A = 0, transformationId="myLogicle") transOut <- eval(myLogicle)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLogicle <- logicletGml2(parameters = "FSC-H", T = 1023, M = 4.5, W = 0.5, A = 0, transformationId="myLogicle") transOut <- eval(myLogicle)(exprs(myDataIn))
Logicle transformation creates a subset of
biexponentialTransform hyperbolic sine transformation
functions that provides several advantages over linear/log transformations
for display of flow cytometry data. (The logicleTransform method makes use
of the C++ implementation of the logicle transform contributed by Wayne
Moore et al.)
logicleTransform(transformationId="defaultLogicleTransform", w = 0.5, t = 262144, m = 4.5, a = 0) estimateLogicle(x, channels,...)logicleTransform(transformationId="defaultLogicleTransform", w = 0.5, t = 262144, m = 4.5, a = 0) estimateLogicle(x, channels,...)
transformationId |
A name to assign to the transformation. Used by the transform/filter routines. |
w |
w is the linearization width in asymptotic decades. w should be > 0 and determines the slope of transformation at zero. w can be estimated using the equation w=(m-log10(t/abs(r)))/2, where r is the most negative value to be included in the display |
t |
Top of the scale data value, e.g, 10000 for common 4 decade data or 262144 for a 18 bit data range. t should be greater than zero |
m |
m is the full width of the transformed display in asymptotic decades. m should be greater than zero |
a |
Additional negative range to be included in the display in asymptotic decades. Positive values of the argument brings additional negative input values into the transformed display viewing area. Default value is zero corresponding to a Standard logicle function. |
x |
Input flow frame for which the logicle transformations are to be estimated. |
channels |
channels or markers for which the logicle transformation is to be estimated. |
... |
other arguments: q: a numeric type specifying quantile value, default is 0.05 |
Wayne Moore, N Gopalakrishnan
Parks D.R., Roederer M., Moore W.A.(2006) A new "logicle" display method avoids deceptive effects of logarithmic scaling for low signals and compensated data. CytometryA, 96(6):541-51.
inverseLogicleTransform,
estimateLogicle
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
data(GvHD) samp <- GvHD[[1]] ## User defined logicle function lgcl <- logicleTransform( w = 0.5, t= 10000, m =4.5) trans <- transformList(c("FL1-H", "FL2-H"), lgcl) after <- transform(samp, trans) invLgcl <- inverseLogicleTransform(trans = lgcl) trans <- transformList(c("FL1-H", "FL2-H"), invLgcl) before <- transform (after, trans) ## Automatically estimate the logicle transformation based on the data lgcl <- estimateLogicle(samp, channels = c("FL1-H", "FL2-H", "FL3-H", "FL2-A", "FL4-H")) ## transform parameters using the estimated logicle transformation after <- transform(samp, lgcl)data(GvHD) samp <- GvHD[[1]] ## User defined logicle function lgcl <- logicleTransform( w = 0.5, t= 10000, m =4.5) trans <- transformList(c("FL1-H", "FL2-H"), lgcl) after <- transform(samp, trans) invLgcl <- inverseLogicleTransform(trans = lgcl) trans <- transformList(c("FL1-H", "FL2-H"), invLgcl) before <- transform (after, trans) ## Automatically estimate the logicle transformation based on the data lgcl <- estimateLogicle(samp, channels = c("FL1-H", "FL2-H", "FL3-H", "FL2-A", "FL4-H")) ## transform parameters using the estimated logicle transformation after <- transform(samp, lgcl)
Log transformation as parameterized in Gating-ML 2.0.
logtGml2 is defined by the following function:
where
This transformation provides a logarithmic display that maps scale values
from the interval to the interval such that the
data value T is mapped to 1 and M decades of data are mapped into the
interval. Also, the limit for x going to 0 is -Inf.
In addition, if a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the f function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the f function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
TObject of class numeric – positive constant (top of scale value).
MObject of class numeric – positive constant (number of decades).
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
logtGml2(parameter, T, M, transformationId, boundMin, boundMax)
Class singleParameterTransform, directly.
Class transform, by class singleParameterTransform, distance 2.
Class transformation, by class singleParameterTransform, distance 3.
Class characterOrTransformation, by class singleParameterTransform, distance 4.
The log transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as a matrix with a single column. (See example below)
Spidlen, J.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
logTransform, transform-class,
transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLogTr1 <- logtGml2(parameters = "FSC-H", T = 1023, M = 4.5, transformationId="myLogTr1") transOut <- eval(myLogTr1)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myLogTr1 <- logtGml2(parameters = "FSC-H", T = 1023, M = 4.5, transformationId="myLogTr1") transOut <- eval(myLogTr1)(exprs(myDataIn))
Create the definition of the log Transformation that will be applied on some
parameter via the transform method. The definition of this function
is currently x<-log(x,logbase)*(r/d). The transformation would normally be
used to convert to a linear valued parameter to the natural logarithm scale.
Typically r and d are both equal to 1.0. Both must be positive. logbase =
10 corresponds to base 10 logarithm.
logTransform(transformationId="defaultLogTransform", logbase=10, r=1, d=1)logTransform(transformationId="defaultLogTransform", logbase=10, r=1, d=1)
transformationId |
character string to identify the transformation |
logbase |
positive double that corresponds to the base of the logarithm. |
r |
positive double that corresponds to a scale factor. |
d |
positive double that corresponds to a scale factor |
Returns an object of class transform.
B. Ellis, N. LeMeur
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) logTrans <- logTransform(transformationId="log10-transformation", logbase=10, r=1, d=1) trans <- transformList('FSC-H', logTrans) dataTransform <- transform(samp, trans)samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) logTrans <- logTransform(transformationId="log10-transformation", logbase=10, r=1, d=1) trans <- transformList('FSC-H', logTrans) dataTransform <- transform(samp, trans)
The result of a several related, but possibly overlapping filter results.
The usual creator of this object will usually be a filter
operation on a flowFrame object.
subSetObject of class "matrix".
frameIdObject of class "character" referencing the
flowFrame object filtered. Used for sanity checking.
filterDetailsObject of class "list" describing the
filter applied.
filterIdObject of class "character" referencing the
filter applied.
dependencyAny dependencies between the filters. Currently not used.
Class "filterResult", directly.
Class "filter", by class "filterResult", distance 2.
subsetting. If x is manyFilterResult,
then x[[i]] a filterResult object. The semantics is
similar to the behavior of the subsetting operators for lists.
number of filterResult objects in the set.
names of the filterResult objects in the set.
summary filterResult objects in the set.
B. Ellis
showClass("manyFilterResult")showClass("manyFilterResult")
marker names corresponds to the 'desc' column of the phenoData of the flowFrame.
markernames(object, ...) ## S4 method for signature 'flowFrame' markernames(object) markernames(object) <- value ## S4 replacement method for signature 'flowFrame' markernames(object) <- value ## S4 method for signature 'flowSet' markernames(object) ## S4 replacement method for signature 'flowSet' markernames(object) <- valuemarkernames(object, ...) ## S4 method for signature 'flowFrame' markernames(object) markernames(object) <- value ## S4 replacement method for signature 'flowFrame' markernames(object) <- value ## S4 method for signature 'flowSet' markernames(object) ## S4 replacement method for signature 'flowSet' markernames(object) <- value
object |
flowFrame or flowSet |
... |
not used |
value |
a named list or character vector. the names corresponds to the name(channel) and actual values are the desc(marker). |
When extract marker names from a flowSet, it throws the warning if the marker names are not all the same across samples.
marker names as a character vector. The marker names for FSC,SSC and Time channels are automatically excluded in the returned value. When object is a flowSet and the marker names are not consistent across flowFrames, it returns a list of unique marker sets.
data(GvHD) fr <- GvHD[[1]] markernames(fr) chnls <- c("FL1-H", "FL3-H") markers <- c("CD15", "CD14") names(markers) <- chnls markernames(fr) <- markers markernames(fr) fs <- GvHD[1:3] markernames(fs)data(GvHD) fr <- GvHD[[1]] markernames(fr) chnls <- c("FL1-H", "FL3-H") markers <- c("CD15", "CD14") names(markers) <- chnls markernames(fr) <- markers markernames(fr) fs <- GvHD[1:3] markernames(fs)
Container to store the result of applying filter on set of
flowFrame objects
subSetObject of class "factor" indicating the population
membership of the data in the gated flowFrame.
frameIdObject of class "character"
referencing the flowFrame object filtered. Used for
sanity checking.
filterDetailsObject of class "list"
describing the filter applied.
filterIdObject of class "character"
referencing the filter applied.
Class "filterResult", directly.
Class "filter", by class "filterResult", distance 2.
subsetting. If x is multipleFilterResult,
then x[[i]] a FilterResult object. The semantics is
similar to the behavior of the subsetting operators for lists.
number of FilterResult objects in the set.
names of the FilterResult objects in the set.
summary FilterResult objects in the set.
B. Ellis
showClass("multipleFilterResult")showClass("multipleFilterResult")
Class and methods to normalize a a flowSet using a potentially
complex normalization function.
normalization(parameters, normalizationId="defaultNormalization", normFunction, arguments=list()) normalize(data, x,...)normalization(parameters, normalizationId="defaultNormalization", normFunction, arguments=list()) normalize(data, x,...)
parameters |
Character vector of parameter names. |
normalizationId |
The identifier for the normalization object. |
x |
An object of class |
normFunction |
The normalization function |
arguments |
The list of additional arguments to |
data |
The |
... |
other arguments: see
|
Data normalization of a flowSet is a rather fuzzy concept. The idea is
to have a rather general function that takes a flowSet and a list of
parameter names as input and applies any kind of normalization to the
respective data columns. The output of the function has to be a
flowSet again. Although we don't formally check for it, the
dimensions of the input and of the output set should remain the same.
Additional arguments may be passed to the normalization function via the
arguments list. Internally we evaluate the function using
do.call and one should check its documentation for details.
Currently, the most prominent example for a normalization function is
warping, as provided by the flowStats package.
A normalization object for the constructor.
A flowSet for the normalize methods.
parametersObject of class "character". The
flow parameters that are supposed to be normalized by the
normalization function.
normalizationIdObject of class "character". An
identifier for the object.
normFunctionObject of class "function" The
normalization function. It has to take two mandatory arguments:
x, the flowSet, and parameters, a character
of parameter names that are to be normalized by the
function. Additional arguments have to be passed in via
arguments.
argumentsObject of class "list" A names list
of additional arguments. Can be NULL.
Objects should be created using the constructor normalization(). See
the Usage and Arguments sections for details.
signature(object = "normalization", value
= "character"): Set method for the identifier slot.
signature(object = "normalization"): Get
method for the identifier slot.
signature(data = "flowSet", x =
"normalization"): Apply a normalization to a flowSet.
signature(object = "normalization"): The
more generic constructor.
F. Hahne
A class used internally for coercing transforms to characters for a return value when a coercion cannot be performed. The user should never need to interact with this class.
Objects will be created internally whenever necessary and this should not be of any concern to the user.
A concrete filter that acts on a set of parameters.
parametersThe names of the parameters employed by this filter.
filterIdThe filter identifier.
parameterFilter objects are never
created directly. This class serves as an inheritance point for filters that
depends on particular parameters.
Class "concreteFilter", directly.
Class "filter", by class "concreteFilter", distance 2.
B. Ellis
A representation of flow parameters that allows for referencing.
.DataA list of the individual parameters.
Objects will be created internally whenever necessary and this should not be of any concern to the user.
Class "list", from data part.
Class "vector", by class "list", distance 2.
Nishant Gopalakrishnan
Many different objects in flowCore are associated with one or more
parameters. This includes filter,
flowFrame and parameterFilter
objects that all either describe or use parameters.
parameters(object, ...)parameters(object, ...)
object |
Object of class |
... |
Further arguments that get passed on to the methods. |
When applied to a flowFrame object, the result is an
AnnotatedDataFrame
describing the parameters recorded by the cytometer. For other objects it
will usually return a vector of names used by the object for its
calculations.
Returns for all objects that inherit from
filter a vector of parameters on which a gate is
defined.
see above
see above
see above
Returns an
AnnotatedDataFrame
containing detailed descriptions about the measurement parameters of the
flowFrame. For flowFrame objects
there also exists a replacement method.
B. Ellis, N. Le Meur, F. Hahne
samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) parameters(samp) print(samp@parameters@data)samp <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) parameters(samp) print(samp@parameters@data)
Link a transformation to particular flow parameters
.DataObject of class "function", the
transformation function.
parametersObject of class "character" The
parameters the transformation is applied to.
transformationIdObject of class
"character". The identifier for the object.
Objects are created by using the %on% operator and are usually not
directly instantiated by the user.
Class "transform", directly.
Class "function", by class "transform", distance 2.
signature(e1 = "filter", e2 =
"parameterTransform"): Apply the transformation.
signature(e1 = "parameterTransform", e2 =
"flowFrame"): see above
signature(object = "parameterTransform"):
Accessor to the parameters slot
Byron Ellis
Class and constructor for 2-dimensional polygonal filter
objects.
polygonGate(..., .gate, boundaries, filterId="defaultPolygonGate")polygonGate(..., .gate, boundaries, filterId="defaultPolygonGate")
filterId |
An optional parameter that sets the |
.gate, boundaries
|
A definition of the gate. This can be either a list or a named matrix as described below. Note the argument boundaries is deprecated and will go away in the next release. |
... |
You can also directly describe a gate without wrapping it in a list or matrix, as described below. |
Polygons are specified by the coordinates of their vertices in two
dimensions. The constructor is designed to be useful in both direct and
programmatic usage. It takes either a list or a named matrix with 2
columns and at least 3 rows containing these coordinates.
Alternatively, vertices can be given as named arguments, in which case the
function tries to convert the values into a matrix.
Returns a polygonGate object for use in filtering
flowFrames or other flow cytometry objects.
boundariesObject of class "matrix". The
vertices of the polygon in two dimensions. There need to be at
least 3 vertices specified for a valid polygon.
parametersObject of class "character",
describing the parameter used to filter the flowFrame.
filterIdObject of class "character",
referencing the filter.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("polygonGate",
...) or by using the constructor polygonGate. Using the
constructor is the recommended way.
signature(x = "flowFrame", table =
"polygonGate"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user, but
internally by calls to the filter methods.
signature(object = "polygonGate"): Print
information about the filter.
See the documentation in the flowViz
package for plotting of polygonGates.
F.Hahne, B. Ellis N. Le Meur
flowFrame, rectangleGate,
ellipsoidGate, polytopeGate,
filter for evaluation of rectangleGates and
split and Subsetfor splitting and subsetting of
flow cytometry data sets based on that.
Other Gate classes:
ellipsoidGate-class,
polytopeGate-class,
quadGate-class,
rectangleGate-class
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Defining the gate sqrcut <- matrix(c(300,300,600,600,50,300,300,50),ncol=2,nrow=4) colnames(sqrcut) <- c("FSC-H","SSC-H") pg <- polygonGate(filterId="nonDebris", boundaries= sqrcut) pg ## Filtering using polygonGates fres <- filter(dat, pg) fres summary(fres) ## The result of polygon filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres)## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Defining the gate sqrcut <- matrix(c(300,300,600,600,50,300,300,50),ncol=2,nrow=4) colnames(sqrcut) <- c("FSC-H","SSC-H") pg <- polygonGate(filterId="nonDebris", boundaries= sqrcut) pg ## Filtering using polygonGates fres <- filter(dat, pg) fres summary(fres) ## The result of polygon filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres)
Convenience methods to facilitate the construction of filter
objects
polytopeGate(..., .gate, b, filterId="defaultPolytopeGate")polytopeGate(..., .gate, b, filterId="defaultPolytopeGate")
filterId |
An optional parameter that sets the |
.gate |
A definition of the gate. This can be either a list, vector or matrix, described below. |
b |
Need documentation |
... |
You can also directly describe a gate without wrapping it in a list or matrix, as described below. |
These functions are designed to be useful in both direct and programmatic usage.
For rectangle gate in n dimensions, if n=1 the gate correspond to a range
gate. If n=2, the gate is a rectangle gate. To use this function
programmatically, you may either construct a list or you may construct a
matrix with n columns and 2 rows. The first row corresponds
to the minimal value for each parameter while the second row corresponds to
the maximal value for each parameter. The names of the parameters are taken
from the column names as in the third example.
Rectangle gate objects can also be multiplied together using the *
operator, provided that both gate have orthogonal axes.
For polygon gate, the boundaries are specified as vertices in 2 dimensions, for polytope gate objects as vertices in n dimensions.
Polytope gate objects will represent the convex polytope determined
by the vertices and parameter b which together specify the polytope as
an intersection of half-spaces represented as a system of linear inequalities,
For quadrant gates, the boundaries are specified as a named list or vector of length two.
Returns a rectangleGate or polygonGate object
for use in filtering flowFrames or other flow cytometry
objects.
F.Hahne, B. Ellis N. Le Meur
Other Gate classes:
ellipsoidGate-class,
polygonGate-class,
quadGate-class,
rectangleGate-class
Class and constructors for quadrant-type filter objects.
quadGate(..., .gate, filterId="defaultQuadGate")quadGate(..., .gate, filterId="defaultQuadGate")
filterId |
An optional parameter that sets the |
.gate |
A definition of the gate for programmatic access. This can be either a named list or a named numeric vector, as described below. |
... |
The parameters of |
quadGates are defined by two parameters, which specify a separation
of a two-dimensional parameter space into four quadrants. The
quadGate function is designed to be useful in both direct and
programmatic usage.
For the interactive use, these parameters can be given as additional named
function arguments, where the names correspond to valid parameter names in a
flowFrame or flowSet. For a more programmatic
approach, a named list or numeric vector of the gate boundaries can be
passed on to the function as argument .gate.
Evaluating a quadGate results in four sub-populations, and hence in
an object of class multipleFilterResult. Accordingly,
quadGates can be used to split flow cytometry data sets.
Returns a quadGate object for use in filtering
flowFrames or other flow cytometry objects.
boundaryObject of class "numeric", length
2. The boundaries of the quadrant regions.
parametersObject of class "character",
describing the parameter used to filter the flowFrame.
filterIdObject of class "character",
referencing the gate.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("quadGate",
...) or using the constructor quadGate. The latter is the
recommended way.
signature(x = "flowFrame", table =
"quadGate"): 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.
signature(object = "quadGate"): Print
information about the gate.
See the documentation in the flowViz
package for plotting of quadGates.
F.Hahne, B. Ellis N. Le Meur
flowFrame, flowSet, filter for
evaluation of quadGates and split for splitting of flow
cytometry data sets based on that.
Other Gate classes:
ellipsoidGate-class,
polygonGate-class,
polytopeGate-class,
rectangleGate-class
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create directly. Most likely from a command line quadGate(filterId="myQuadGate1", "FSC-H"=100, "SSC-H"=400) ## To facilitate programmatic construction we also have the following quadGate(filterId="myQuadGate2", list("FSC-H"=100, "SSC-H"=400)) ## FIXME: Do we want this? ##quadGate(filterId="myQuadGate3", .gate=c("FSC-H"=100, "SSC-H"=400)) ## Filtering using quadGates qg <- quadGate(filterId="quad", "FSC-H"=600, "SSC-H"=400) fres <- filter(dat, qg) fres summary(fres) names(fres) ## The result of quadGate filtering are multiple sub-populations ## and we can split our data set accordingly split(dat, fres) ## We can limit the splitting to one or several sub-populations split(dat, fres, population="FSC-H-SSC-H-") split(dat, fres, population=list(keep=c("FSC-H-SSC-H-", "FSC-H-SSC-H+")))## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) ## Create directly. Most likely from a command line quadGate(filterId="myQuadGate1", "FSC-H"=100, "SSC-H"=400) ## To facilitate programmatic construction we also have the following quadGate(filterId="myQuadGate2", list("FSC-H"=100, "SSC-H"=400)) ## FIXME: Do we want this? ##quadGate(filterId="myQuadGate3", .gate=c("FSC-H"=100, "SSC-H"=400)) ## Filtering using quadGates qg <- quadGate(filterId="quad", "FSC-H"=600, "SSC-H"=400) fres <- filter(dat, qg) fres summary(fres) names(fres) ## The result of quadGate filtering are multiple sub-populations ## and we can split our data set accordingly split(dat, fres) ## We can limit the splitting to one or several sub-populations split(dat, fres, population="FSC-H-SSC-H-") split(dat, fres, population=list(keep=c("FSC-H-SSC-H-", "FSC-H-SSC-H+")))
Quadratic transform class which represents a transformation defined by the function
.DataObject of class "function".
aObject of class "numeric" – non-zero multiplicative
constant.
parametersObject of class "transformation" – flow
parameter to be transformed.
transformationIdObject of class "character" – unique
ID to reference the transformation.
Objects can be created by calls to the
constructor quadratic(parameters,a,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform",
distance 2.
Class "transformation", by class "singleParameterTransform",
distance 3.
Class "characterOrTransformation", by class "singleParameterTransform",
distance 4.
The quadratic transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a column vector. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
dg1polynomial,ratio,squareroot
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) quad1<-quadratic(parameters="FSC-H",a=2,transformationId="quad1") transOut<-eval(quad1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) quad1<-quadratic(parameters="FSC-H",a=2,transformationId="quad1") transOut<-eval(quad1)(exprs(dat))
Create the definition of the quadratic Transformation that will be applied
on some parameter via the transform method. The definition of this
function is currently x <- a*x\^2 + b*x + c
quadraticTransform(transformationId="defaultQuadraticTransform", a = 1, b = 1, c = 0)quadraticTransform(transformationId="defaultQuadraticTransform", a = 1, b = 1, c = 0)
transformationId |
character string to identify the transformation |
a |
double that corresponds to the quadratic coefficient in the equation |
b |
double that corresponds to the linear coefficient in the equation |
c |
double that corresponds to the intercept in the equation |
Returns an object of class transform.
N. Le Meur
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
scaleTransform(),
splitScaleTransform(),
truncateTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) quadTrans <- quadraticTransform(transformationId="Quadratic-transformation", a=1, b=1, c=0) dataTransform <- transform(samp, transformList('FSC-H', quadTrans))samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) quadTrans <- quadraticTransform(transformationId="Quadratic-transformation", a=1, b=1, c=0) dataTransform <- transform(samp, transformList('FSC-H', quadTrans))
Container to store the result of applying a filter on a
flowFrame object, with the population membership considered to be
stochastic rather than absolute. Currently not utilized.
subSetObject of class "numeric", which is a logical vector
indicating the population membership of the data in the gated flowFrame.
frameIdObject of class "character" referencing the
flowFrame object filtered. Used for sanity checking.
filterDetailsObject of class "list" describing the filter applied.
filterIdObject of class "character" referencing the filter applied.
Class "filterResult", directly.
Class "filter", by class "filterResult", distance 2.
B. Ellis
ratio transform calculates the ratio of two parameters defined by the function
.DataObject of class "function".
numeratorObject of class "transformation" – flow parameter
to be transformed
denominatorObject of class "transformation" – flow parameter
to be transformed.
transformationIdObject of class "character" – unique ID to
reference the transformation.
Objects can be created by calls to the
constructor ratio(parameter1,parameter2,transformationId) .
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
The ratio transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as matrix with one column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
dg1polynomial,quadratic,squareroot
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) rat1<-ratio("FSC-H","SSC-H",transformationId="rat1") transOut<-eval(rat1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) rat1<-ratio("FSC-H","SSC-H",transformationId="rat1") transOut<-eval(rat1)(exprs(dat))
Ratio transformation as parameterized in Gating-ML 2.0.
ratiotGml2 is defined by the following function:
where
If a boundary is defined by the boundMin and/or boundMax parameters, then the result of this transformation is restricted to the [boundMin,boundMax] interval. Specifically, should the result of the f function be less than boundMin, then let the result of this transformation be boundMin. Analogically, should the result of the f function be more than boundMax, then let the result of this transformation be boundMax. The boundMin parameter shall not be greater than the boundMax parameter.
.DataObject of class function.
numeratorObject of class "transformation" – flow parameter to be
used as numerator in the transformation function.
denominatorObject of class "transformation" – flow parameter to be
used as denominator in the transformation function.
pAObject of class numeric constant A.
pBObject of class numeric constant B.
pCObject of class numeric constant C.
transformationIdObject of class "character" – unique ID to reference
the transformation.
boundMinObject of class numeric – lower bound of the transformation, default -Inf.
boundMaxObject of class numeric – upper bound of the transformation, default Inf.
Objects can be created by calls to the constructor
ratiotGml2(p1, p2, A, B, C, transformationId, boundMin, boundMax)
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
The ratiotGml2 transformation object can be evaluated using the eval method by passing the data frame as an argument. The transformed parameters are returned as matrix with one column. (See example below)
Spidlen, J.
Gating-ML 2.0: International Society for Advancement of Cytometry (ISAC) standard for representing gating descriptions in flow cytometry. http://flowcyt.sourceforge.net/gating/20141009.pdf
ratio, transform-class,
transform
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
sinht-class,
splitscale-class,
squareroot-class,
unitytransform-class
myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myRatioT <- ratiotGml2("FSC-H", "SSC-H", pA = 2, pB = 3, pC = -10, transformationId = "myRatioT") transOut <- eval(myRatioT)(exprs(myDataIn))myDataIn <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) myRatioT <- ratiotGml2("FSC-H", "SSC-H", pA = 2, pB = 3, pC = -10, transformationId = "myRatioT") transOut <- eval(myRatioT)(exprs(myDataIn))
Check validity and Read Data File Standard for Flow Cytometry
isFCSfile(files) read.FCS(filename, transformation="linearize", which.lines=NULL, alter.names=FALSE, column.pattern=NULL, invert.pattern = FALSE, decades=0, ncdf = FALSE, min.limit=NULL, truncate_max_range = TRUE, dataset=NULL, emptyValue=TRUE, channel_alias = NULL, ...)isFCSfile(files) read.FCS(filename, transformation="linearize", which.lines=NULL, alter.names=FALSE, column.pattern=NULL, invert.pattern = FALSE, decades=0, ncdf = FALSE, min.limit=NULL, truncate_max_range = TRUE, dataset=NULL, emptyValue=TRUE, channel_alias = NULL, ...)
filename |
Character of length 1: filename |
transformation |
An character string that defines the type of
transformation. Valid values are |
which.lines |
Numeric vector to specify the indices of the lines to be
read. If NULL all the records are read, if of length 1, a random sample of
the size indicated by |
alter.names |
boolean indicating whether or not we should rename the
columns to valid R names using |
column.pattern |
An optional regular expression defining parameters we should keep when loading the file. The default is NULL. |
invert.pattern |
logical. By default, |
decades |
When scaling is activated, the number of decades to use for the output. |
ncdf |
Deprecated. Please use 'ncdfFlow' package for cdf based storage. |
min.limit |
The minimum value in the data range that is allowed. Some
instruments produce extreme artifactual values. The positive data range for
each parameter is completely defined by the measurement range of the
instrument and all larger values are set to this threshold. The lower data
boundary is not that well defined, since compensation might shift some
values below the original measurement range of the instrument. This can be
set to an arbitrary number or to |
truncate_max_range |
logical type. Default is TRUE. can be optionally turned off to avoid truncating the extreme positive value to the instrument measurement range .i.e.'$PnR'. When the transformation keyword of the FCS header is set (typically to "custom" or "applied"), no truncation will occur. |
dataset |
The FCS file specification allows for multiple data segments
in a single file. Since the output of |
emptyValue |
boolean indicating whether or not we allow empty value for keyword values in TEXT segment. It affects how the double delimiters are treated. IF TRUE, The double delimiters are parsed as a pair of start and end single delimiter for an empty value. Otherwise, double delimiters are parsed one part of string as the keyword value. default is TRUE. |
channel_alias |
an optional data.frame used to provide the alias of the channels to standardize and solve the discrepancy across FCS files. It is expected to contain 'alias' and 'channels' column of 'channel_alias'. Each row/entry specifies the common alias name for a collection of channels (comma separated). See examples for details. For each channel in the FCS file, read.FCS will first attempt
to find an exact match in the 'channels' column. If no exact match is found,
it will check for partial matches. That is, if "V545" is in the 'channels'
column of 'channel_alias' and "V545-A" is present in the FCS file, this
partial match will allow the corresponding 'alias' to be assigned. This partial
matching only works in this direction ("V545-A" in the 'channels' column will
not match "V545" in the FCS file) and care should be exercised to ensure no unintended
partial matching of other channel names. If no exact or partial match is found,
the channel is unchanged in the resulting |
... |
ignore.text.offset: whether to ignore the keyword values in TEXT segment when they don't agree with the HEADER. Default is FALSE, which throws the error when such discrepancy is found. User can turn it on to ignore TEXT segment when he is sure of the accuracy of HEADER so that the file still can be read. |
files |
A vector of filenames |
The function isFCSfile determines whether its arguments are valid FCS
files.
The function read.FCS works with the output of the FACS machine
software from a number of vendors (FCS 2.0, FCS 3.0 and List Mode Data LMD).
However, the FCS 3.0 standard includes some options that are not yet
implemented in this function. If you need extensions, please let me know.
The output of the function is an object of class flowFrame.
For specifications of FCS 3.0 see http://www.isac-net.org and the file
../doc/fcs3.html in the doc directory of the package.
The which.lines arguments allow you to read a subset of the record as
you might not want to read the thousands of events recorded in the FCS file.
It is mainly used when there is not enough memory to read one single FCS
(which probably will not happen). It will probably take more time than
reading the entire FCS (due to the multiple disk IO).
isFCSfile returns a logical vector.
read.FCS returns an object of class
flowFrame that contains the data in
the exprs slot, the parameters monitored in the parameters
slot and the keywords and value saved in the header of the FCS file.
F. Hahne, N.Le Meur
## a sample file fcsFile <- system.file("extdata", "0877408774.B08", package="flowCore") ## read file and linearize values samp <- read.FCS(fcsFile, transformation="linearize") exprs(samp[1:3,]) keyword(samp)[3:6] class(samp) ## Only read in lines 2 to 5 subset <- read.FCS(fcsFile, which.lines=2:5, transformation="linearize") exprs(subset) ## Read in a random sample of 100 lines subset <- read.FCS(fcsFile, which.lines=100, transformation="linearize") nrow(subset) #manually supply the alias vs channel options mapping as a data.frame map <- data.frame(alias = c("A", "B") , channels = c("FL2", "FL4") ) fr <- read.FCS(fcsFile, channel_alias = map) fr## a sample file fcsFile <- system.file("extdata", "0877408774.B08", package="flowCore") ## read file and linearize values samp <- read.FCS(fcsFile, transformation="linearize") exprs(samp[1:3,]) keyword(samp)[3:6] class(samp) ## Only read in lines 2 to 5 subset <- read.FCS(fcsFile, which.lines=2:5, transformation="linearize") exprs(subset) ## Read in a random sample of 100 lines subset <- read.FCS(fcsFile, which.lines=100, transformation="linearize") nrow(subset) #manually supply the alias vs channel options mapping as a data.frame map <- data.frame(alias = c("A", "B") , channels = c("FL2", "FL4") ) fr <- read.FCS(fcsFile, channel_alias = map) fr
Read (part of) the TEXT section of a Data File Standard for Flow Cytometry that contains FACS keywords.
read.FCSheader(files, path = ".", keyword = NULL, ...)read.FCSheader(files, path = ".", keyword = NULL, ...)
files |
Character vector of filenames. |
path |
Directory where to look for the files. |
keyword |
An optional character vector that specifies the FCS keyword to read. |
... |
other arguments passed to |
The function read.FCSheader works with the output of the FACS machine
software from a number of vendors (FCS 2.0, FCS 3.0 and List Mode Data LMD).
The output of the function is the TEXT section of the FCS files. The user
can specify some keywords to limit the output to the information of
interest.
A list of character vectors. Each element of the list correspond to one FCS file.
N.Le Meur
link[flowCore]{read.flowSet},
link[flowCore]{read.FCS}
samp <- read.FCSheader(system.file("extdata", "0877408774.B08", package="flowCore")) samp samp <- read.FCSheader(system.file("extdata", "0877408774.B08", package="flowCore"), keyword=c("$DATE", "$FIL")) sampsamp <- read.FCSheader(system.file("extdata", "0877408774.B08", package="flowCore")) samp samp <- read.FCSheader(system.file("extdata", "0877408774.B08", package="flowCore"), keyword=c("$DATE", "$FIL")) samp
Read one or several FCS files: Data File Standard for Flow Cytometry
read.flowSet(files=NULL, path=".", pattern=NULL, phenoData, descriptions,name.keyword, alter.names=FALSE, transformation = "linearize", which.lines=NULL, column.pattern = NULL, invert.pattern = FALSE, decades=0, sep="\t", as.is=TRUE, name, ncdf=FALSE, dataset=NULL, min.limit=NULL, truncate_max_range = TRUE, emptyValue=TRUE, ignore.text.offset = FALSE, channel_alias = NULL, ...)read.flowSet(files=NULL, path=".", pattern=NULL, phenoData, descriptions,name.keyword, alter.names=FALSE, transformation = "linearize", which.lines=NULL, column.pattern = NULL, invert.pattern = FALSE, decades=0, sep="\t", as.is=TRUE, name, ncdf=FALSE, dataset=NULL, min.limit=NULL, truncate_max_range = TRUE, emptyValue=TRUE, ignore.text.offset = FALSE, channel_alias = NULL, ...)
files |
Optional character vector with filenames. |
path |
Directory where to look for the files. |
pattern |
This argument is passed on to
|
phenoData |
An object of class |
descriptions |
Character vector to annotate the object of class
|
name.keyword |
An optional character vector that specifies which FCS keyword to use as the sample names. If this is not set, the GUID of the FCS file is used for sampleNames, and if that is not present (or not unique), then the file names are used. |
alter.names |
see |
transformation |
see |
which.lines |
see |
column.pattern |
see |
invert.pattern |
see |
decades |
see |
sep |
Separator character that gets passed on to
|
as.is |
Logical that gets passed on to
|
name |
An optional character scalar used as name of the object. |
ncdf |
Deprecated. Please refer to 'ncdfFlow' package for cdf based storage. |
dataset |
see |
min.limit |
see |
truncate_max_range |
see |
emptyValue |
see |
ignore.text.offset |
see |
channel_alias |
see |
... |
Further arguments that get passed on to
|
There are four different ways to specify the file from which data is to be imported:
First, if the argument phenoData is present and is of class
AnnotatedDataFrame, then the
file names are obtained from its sample names (i.e. row names of the
underlying data.frame). Also column name will be generated based on
sample names if it is not there. This column is mainly used by visualization
methods in flowViz. Alternatively, the argument phenoData can be of
class character, in which case this function tries to read a
AnnotatedDataFrame object from the file with that name by calling
read.AnnotatedDataFrame(file.path(path,phenoData),...{}).
In some cases the file names are not a reasonable selection criterion and the user might want to import files based on some keywords within the file. One or several keyword value pairs can be given as the phenoData argument in form of a named list.
Third, if the argument phenoData is not present and the argument
files is not NULL, then files is expected to be a
character vector with the file names.
Fourth, if neither the argument phenoData is present nor files
is not NULL, then the file names are obtained by calling
dir(path, pattern).
An object of class flowSet.
F. Hahne, N.Le Meur, B. Ellis
fcs.loc <- system.file("extdata",package="flowCore") file.location <- paste(fcs.loc, dir(fcs.loc), sep="/") samp <- read.flowSet(file.location[1:3])fcs.loc <- system.file("extdata",package="flowCore") file.location <- paste(fcs.loc, dir(fcs.loc), sep="/") samp <- read.flowSet(file.location[1:3])
Class and constructor for n-dimensional rectangular
filter objects.
rectangleGate(..., .gate, filterId="defaultRectangleGate")rectangleGate(..., .gate, filterId="defaultRectangleGate")
filterId |
An optional parameter that sets the |
.gate |
A definition of the gate. This can be either a list, or a matrix, as described below. |
... |
You can also directly provide the boundaries of a
|
This class describes a rectangular region in n dimensions, which is a
Cartesian product of n orthogonal intervals in these dimensions.
n=1 corresponds to a range gate, n=2 to a rectangle gate,
n=3 corresponds to a box region and n>3 to a hyper-rectangular
regions. Intervals may be open on one side, in which case the value for the
boundary is supposed to be Inf or -Inf, respectively.
rectangleGates are inclusive, that means that events on the
boundaries are considered to be in the gate.
The constructor is designed to be useful in both direct and programmatic
usage. To use it programmatically, you may either construct a named list or
you may construct a matrix with n columns and 2 rows. The
first row corresponds to the minimal value for each parameter while the
second row corresponds to the maximal value for each parameter. The names
of the parameters are taken from the column names or from the list names,
respectively. Alternatively, the boundaries of the rectangleGate can
be given as additional named arguments, where each of these arguments should
be a numeric vector of length 2; the function tries to collapse these
boundary values into a matrix.
Note that boundaries of rectangleGates where min > max are
syntactically valid, however when evaluated they will always be empty.
rectangleGate objects can also be multiplied using the *
operator, provided that both gates have orthogonal axes. This results in
higher-dimensional rectangleGates. The inverse operation of
subsetting by parameter name(s) is also available.
Evaluating a rectangleGate generates an object of class
logicalFilterResult. Accordingly, rectangleGates
can be used to subset and to split flow cytometry data sets.
Returns a rectangleGate object for use in filtering
flowFrames or other flow cytometry objects.
min,maxObjects of class "numeric". The
minimum and maximum values of the n-dimensional rectangular
region.
parametersObject of class "character",
indicating the parameters for which the rectangleGate is
defined.
filterIdObject of class "character",
referencing the filter.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("rectangleGate",
...), by using the constructor rectangleGate or by combining
existing rectangleGates using the * method. Using the
constructor is the recommended way of object instantiation.
signature(x = "flowFrame", table =
"rectangleGate"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user, but
internally by calls to the filter methods.
signature(object = "rectangleGate"): Print
information about the filter.
signature(e1 = "rectangleGate", e2 =
"rectangleGate"): combining two rectangleGates into one
higher dimensional representation.
signature(x = "rectangleGate", i = "character"):
Subsetting of a rectangleGate by parameter name(s). This
is essentially the inverse to *.
See the documentation in the flowViz
package for details on plotting of rectangleGates.
F.Hahne, B. Ellis N. Le Meur
flowFrame, polygonGate,
ellipsoidGate, polytopeGate,
filter for evaluation of rectangleGates and
split and Subsetfor splitting and subsetting of
flow cytometry data sets based on that.
Other Gate classes:
ellipsoidGate-class,
polygonGate-class,
polytopeGate-class,
quadGate-class
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) #Create directly. Most likely from a command line rectangleGate(filterId="myRectGate", "FSC-H"=c(200, 600), "SSC-H"=c(0, 400)) #To facilitate programmatic construction we also have the following rg <- rectangleGate(filterId="myRectGate", list("FSC-H"=c(200, 600), "SSC-H"=c(0, 400))) mat <- matrix(c(200, 600, 0, 400), ncol=2, dimnames=list(c("min", "max"), c("FSC-H", "SSC-H"))) rg <- rectangleGate(filterId="myRectGate", .gate=mat) ## Filtering using rectangleGates fres <- filter(dat, rg) fres summary(fres) ## The result of rectangle filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres) ## Multiply rectangle gates rg1 <- rectangleGate(filterId="FSC-", "FSC-H"=c(-Inf, 50)) rg2 <- rectangleGate(filterId="SSC+", "SSC-H"=c(50, Inf)) rg1 * rg2 ## Subset rectangle gates rg["FSC-H"] ##2d rectangleGate can be coerced to polygonGate as(rg, "polygonGate")## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) #Create directly. Most likely from a command line rectangleGate(filterId="myRectGate", "FSC-H"=c(200, 600), "SSC-H"=c(0, 400)) #To facilitate programmatic construction we also have the following rg <- rectangleGate(filterId="myRectGate", list("FSC-H"=c(200, 600), "SSC-H"=c(0, 400))) mat <- matrix(c(200, 600, 0, 400), ncol=2, dimnames=list(c("min", "max"), c("FSC-H", "SSC-H"))) rg <- rectangleGate(filterId="myRectGate", .gate=mat) ## Filtering using rectangleGates fres <- filter(dat, rg) fres summary(fres) ## The result of rectangle filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres) ## Multiply rectangle gates rg1 <- rectangleGate(filterId="FSC-", "FSC-H"=c(-Inf, 50)) rg2 <- rectangleGate(filterId="SSC+", "SSC-H"=c(50, Inf)) rg1 * rg2 ## Subset rectangle gates rg["FSC-H"] ##2d rectangleGate can be coerced to polygonGate as(rg, "polygonGate")
Rotate a Gate-type filter object through a specified angle
## Default S3 method: rotate_gate(obj, deg = NULL, rot_center = NULL, ...)## Default S3 method: rotate_gate(obj, deg = NULL, rot_center = NULL, ...)
obj |
An |
deg |
An angle in degrees by which the gate should be rotated in the counter-clockwise direction |
rot_center |
A separate 2-dimensional center of rotation for the gate, if desired. By default, this will
be the center for |
... |
Additional arguments not used |
This method allows for 2-dimensional geometric rotation of filter types defined by simple geometric gates
(ellipsoidGate, and polygonGate). The method is not defined
for rectangleGate or quadGate objects, due to their definition as having 1-dimensional boundaries.
Further, keep in mind that the 2-dimensional rotation takes place in the plane where the dimensions
of the two variables are evenly linearly scaled. Displaying a rotated ellipse in a plot where the axes are not scaled
evenly may make it appear that the ellipse has been distorted even though this is not the case.
The angle provided in the deg argument should be in degrees rather than radians. By default, the rotation
will be performed around the center of an ellipsoidGate or the centroid of the area encompassed by
a polygonGate. The rot_center argument allows for specification of a different center of rotation
for polygonGate objects (it is not yet implemented for ellipsoidGate objects) but
it is usually simpler to perform a rotation and a translation individually than to manually specify
the composition as a rotation around a shifted center.
A Gate-type filter object of the same type as gate, with the rotation applied
## Not run: #' # Rotates the original gate 15 degrees counter-clockwise rotated_gate <- rotate_gate(original_gate, deg = 15) # Rotates the original gate 270 degrees counter-clockwise rotated_gate <- rotate_gate(original_gate, 270) ## End(Not run)## Not run: #' # Rotates the original gate 15 degrees counter-clockwise rotated_gate <- rotate_gate(original_gate, deg = 15) # Rotates the original gate 270 degrees counter-clockwise rotated_gate <- rotate_gate(original_gate, 270) ## End(Not run)
This non-parameter filter selects a number of events from the primary
flowFrame.
sampleFilter(size, filterId="defaultSampleFilter")sampleFilter(size, filterId="defaultSampleFilter")
filterId |
An optional parameter that sets the |
size |
The number of events to select. |
Selects a number of events without replacement from a flowFrame.
Returns a sampleFilter object for use in filtering
flowFrames or other flow cytometry objects.
sizeObject of class "numeric". Then number of
events that are to be selected.
filterIdA character vector that identifies this
filter.
Class "concreteFilter", directly.
Class "filter", by class concreteFilter,
distance 2.
Objects can be created by calls of the form new("sampleFilter",
...) or using the constructor sampleFilter. The latter is the
recommended way.
signature(x = "flowFrame", table =
"sampleFilter"): 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.
signature(object = "sampleFilter"): Print
information about the gate.
B. Ellis, F.Hahne
flowFrame, filter for evaluation of
sampleFilters and split and Subsetfor
splitting and subsetting of flow cytometry data sets based on that.
## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) #Create the filter sf <- sampleFilter(filterId="mySampleFilter", size=500) sf ## Filtering using sampleFilters fres <- filter(dat, sf) fres summary(fres) ## The result of sample filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres)## Loading example data dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) #Create the filter sf <- sampleFilter(filterId="mySampleFilter", size=500) sf ## Filtering using sampleFilters fres <- filter(dat, sf) fres summary(fres) ## The result of sample filtering is a logical subset Subset(dat, fres) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations split(dat, fres)
Scale a Gate-type filter object in one or more dimensions
## Default S3 method: scale_gate(obj, scale = NULL, ...)## Default S3 method: scale_gate(obj, scale = NULL, ...)
obj |
A Gate-type |
scale |
Either a numeric scalar (for uniform scaling in all dimensions) or numeric vector specifying the factor by which each dimension of the gate should be expanded (absolute value > 1) or contracted (absolute value < 1). Negative values will result in a reflection in that dimension. |
... |
Additional arguments not used |
This method allows uniform or non-uniform geometric scaling of filter types defined by simple geometric gates
(quadGate, rectangleGate, ellipsoidGate, and
polygonGate) Note that these methods are for manually altering
the geometric definition of a gate. To easily transform the definition of a gate with an accompanyging scale
transformation applied to its underlying data, see rescale_gate.
The scale argument passed to scale_gate should be either a scalar or a vector of the same length
as the number of dimensions of the gate. If it is scalar, all dimensions will be multiplicatively scaled uniformly
by the scalar factor provided. If it is a vector, each dimension will be scaled by its corresponding entry in the vector.
The scaling behavior of scale_gate depends on the type of gate passed to it. For rectangleGate
and quadGate objects, this amounts to simply scaling the values of the 1-dimensional boundaries.
For polygonGate objects, the values of scale will be used to determine scale factors
in the direction of each of the 2 dimensions of the gate (scale_gate is not yet defined
for higher-dimensional polytopeGate objects). Important: For ellipsoidGate objects, scale
determines scale factors for the major and minor axes of the ellipse, in that order. Scaling by a negative factor
will result in a reflection in the corresponding dimension.
A Gate-type filter object of the same type as gate, with the scaling applied
## Not run: # Scales both dimensions by a factor of 5 scaled_gate <- scale_gate(original_gate, 5) # Shrinks the gate in the first dimension by factor of 1/2 # and expands it in the other dimension by factor of 3 scaled_gate <- scale_gate(original_gate, c(0.5,3)) ## End(Not run)## Not run: # Scales both dimensions by a factor of 5 scaled_gate <- scale_gate(original_gate, 5) # Shrinks the gate in the first dimension by factor of 1/2 # and expands it in the other dimension by factor of 3 scaled_gate <- scale_gate(original_gate, c(0.5,3)) ## End(Not run)
Create the definition of the scale Transformation that will be applied on
some parameter via the transform method. The definition of this
function is currently x = (x-a)/(b-a). The transformation would normally be
used to convert to a 0-1 scale. In this case, b would be the maximum
possible value and a would be the minimum possible value.
scaleTransform(transformationId="defaultScaleTransform", a, b)scaleTransform(transformationId="defaultScaleTransform", a, b)
transformationId |
character string to identify the transformation |
a |
double that corresponds to the value that will be transformed to 0 |
b |
double that corresponds to the value that will be transformed to 1 |
Returns an object of class transform.
P. Haaland
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
splitScaleTransform(),
truncateTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) scaleTrans <- scaleTransform(transformationId="Truncate-transformation", a=1, b=10^4) dataTransform <- transform(samp, transformList('FSC-H', scaleTrans))samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) scaleTrans <- scaleTransform(transformationId="Truncate-transformation", a=1, b=10^4) dataTransform <- transform(samp, transformList('FSC-H', scaleTrans))
This is a Superclass for the unionFilter, intersectFilter, complementFilter
and subsetFilter classes, which all consist of two or more component filters
and are constructed using set operators (&, |, !, and
%&% or %subset% respectively).
filtersObject of class "list", containing the component filters.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
B. Ellis
Other setOperationFilter classes:
complementFilter-class,
intersectFilter-class,
subsetFilter-class,
unionFilter-class
Shift a Gate-type filter object in one or more dimensions
## Default S3 method: shift_gate(obj, dx = NULL, dy = NULL, center = NULL, ...)## Default S3 method: shift_gate(obj, dx = NULL, dy = NULL, center = NULL, ...)
obj |
A Gate-type |
dx |
Either a numeric scalar or numeric vector. If it is scalar, this is just the desired shift of the gate in
its first dimension. If it is a vector, it specifies both |
dy |
A numeric scalar specifying the desired shift of the gate in its second dimension. |
center |
A numeric vector specifying where the center or centroid should be moved (rather than specifiying |
... |
Additional arguments not used |
This method allows for geometric translation of filter types defined by simple geometric gates
(rectangleGate, quadGate, ellipsoidGate, or polygonGate).
The method provides two approaches to specify a translation. For rectangleGate objects, this will
shift the min and max bounds by the same amount in each specified dimension. For quadGate
objects, this will simply shift the divinding boundary in each dimension. For ellipsoidGate objects, this
will shift the center (and therefore all points of the ellipse). For polgonGate objects, this will simply
shift all of the points defining the polygon.
The method allows two different approaches to shifting a gate. Through the dx and/or dy arguments,
a direct shift in each dimension can be provided. Alternatively, through the center argument, the gate
can be directly moved to a new location in relation to the old center of the gate. For quadGate objects,
this center is the intersection of the two dividing boundaries (so the value of the boundary slot). For
rectangleGate objects, this is the center of the rectangle defined by the intersections of the centers
of each interval. For ellipsoidGate objects, it is the center of the ellipsoid, given by the mean
slot. For polygonGate objects, the centroid of the old polygon will be calculated and shifted to the new
location provided by center and all other points on the polygon will be shifted by relation to the centroid.
A Gate-type filter object of the same type as gate, with the translation applied
## Not run: # Moves the entire gate +500 in its first dimension and 0 in its second dimension shifted_gate <- shift_gate(original_gate, dx = 500) #Moves the entire gate +250 in its first dimension and +700 in its second dimension shifted_gate <- shift_gate(original_gate, dx = 500, dy = 700) # Same as previous shifted_gate <- shift_gate(original_gate, c(500,700)) # Move the gate based on shifting its center to (700, 1000) shifted_gate <- shift_gate(original_gate, center = c(700, 1000)) ## End(Not run)## Not run: # Moves the entire gate +500 in its first dimension and 0 in its second dimension shifted_gate <- shift_gate(original_gate, dx = 500) #Moves the entire gate +250 in its first dimension and +700 in its second dimension shifted_gate <- shift_gate(original_gate, dx = 500, dy = 700) # Same as previous shifted_gate <- shift_gate(original_gate, c(500,700)) # Move the gate based on shifting its center to (700, 1000) shifted_gate <- shift_gate(original_gate, center = c(700, 1000)) ## End(Not run)
A transformation that operates on a single parameter
.DataObject of class "function". The transformation.
parametersObject of class "transformation". The
parameter to transform. Can be a derived parameter from another
transformation.
transformationIdObject of class "character". An
identifier for the object.
Objects can be created by calls of the form
new("singleParameterTransform", ...).
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
F Hahne
showClass("singleParameterTransform")showClass("singleParameterTransform")
Hyperbolic sin transform class, which represents a transformation defined by the function:
This definition is such that it can function as an inverse of
asinht using the same definitions of the constants a
and b.
.DataObject of class "function".
aObject of class "numeric" – non-zero constant.
bObject of class "numeric" – non-zero constant.
parametersObject of class "transformation" – flow parameter
to be transformed
transformationIdObject of class "character" – unique ID to
reference the transformation.
Objects can be created by calls to the
constructor sinht(parameter,a,b,transformationId).
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column.(See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry V 1.5
asinht
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
splitscale-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) sinh1<-sinht(parameters="FSC-H",a=1,b=2000,transformationId="sinH1") transOut<-eval(sinh1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) sinh1<-sinht(parameters="FSC-H",a=1,b=2000,transformationId="sinH1") transOut<-eval(sinh1)(exprs(dat))
Divide a flow cytometry data set into several subset according to the results of a filtering operation. There are also methods available to split according to a factor variable.
The splitting operation in the context of flowFrames
and flowSets is the logical extension of subsetting.
While the latter only returns the events contained within a gate, the former
splits the data into the groups of events contained within and those not
contained within a particular gate. This concept is extremely useful in
applications where gates describe the distinction between positivity and
negativity for a particular marker.
The flow data structures in flowCore can be split into subsets on
various levels:
flowFrame: row-wise splitting of the raw data. In most
cases, this will be done according to the outcome of a filtering operation,
either using a filter that identifiers more than one sub-population or by a
logical filter, in which case the data is split into two populations: "in
the filter" and "not in the filter". In addition, the data can be split
according to a factor (or a numeric or character vector that can be coerced
into a factor).
flowSet: can be either split into subsets of
flowFrames according to a factor or a vector that can
be coerced into a factor, or each individual flowFrame
into subpopulations based on the filters or
filterResults provided as a list of equal length.
Splitting has a special meaning for filters that result in
multipleFilterResults or
manyFilterResults, in which case simple subsetting
doesn't make much sense (there are multiple populations that are defined by
the gate and it is not clear which of those should be used for the
subsetting operation). Accordingly, splitting of multipleFilterResults
creates multiple subsets. The argument population can be used to
limit the output to only one or some of the resulting subsets. It takes as
values a character vector of names of the populations of interest. See the
documentation of the different filter classes on how population names can be
defined and the respective default values. For splitting of
logicalFilterResults, the population argument
can be used to set the population names since there is no reasonable default
other than the name of the gate. The content of the argument prefix
will be prepended to the population names and '+' or '-' are finally
appended allowing for more flexible naming schemes.
The default return value for any of the split methods is a list, but
the optional logical argument flowSet can be used to return a
flowSet instead. This only applies when splitting
flowFrames, splitting of flowSets
always results in lists of flowSet objects.
flowFrame methods:
Catch all input and cast an
error if there is no method for f to dispatch to.
Split a
flowFrame by a factor variable. Length of f should be
the same as nrow(x), otherwise it will be recycled, possibly leading
to undesired outcomes. The optional argument drop works in the usual
way, in that it removes empty levels from the factor before splitting.
Coerce f to a
factor and split on that.
Coerce f to a
factor and split on that.
First applies the
filter to the flowFrame and then
splits on the resulting filterResult object.
Split into
the two subpopulations (in and out of the gate). The optional argument
population can be used to control the names of the results.
Split into the
several subpopulations identified by the filtering operation. Instead of
returning a list, the additional logical argument codeflowSet makes the
method return an object of class flowSet. The optional
population argument takes a character vector indicating the
subpopulations to use for splitting (as identified by the population name in
the filterDetails slot).
Split into
the several subpopulations identified by the filtering operation. Instead of
returning a list, the additional logical argument codeflowSet makes the
method return an object of class flowSet. The optional
population argument takes a character vector indicating the
subpopulations to use for splitting (as identified by the population name in
the filterDetails slot). Alternatively, this can be a list of
characters, in which case the populations for each list item are collapsed
into one flowFrame.
flowSet methods:
Catch all input and cast an
error if there is no method for f to dispatch to.
Split a
flowSet by a factor variable. Length of f needs to be
the same as length(x). The optional argument drop works in the
usual way, in that it removes empty levels from the factor before splitting.
Coerce f to a
factor and split on that.
Coerce f to a
factor and split on that.
Split a
flowSet by a list of filterResults (as
typically returned by filtering operations on a
flowSet). The length of the list has to be equal to the
length of the flowSet and every list item needs to be a
filterResult of equal class with the same parameters.
Instead of returning a list, the additional logical argument codeflowSet
makes the method return an object of class flowSet. The
optional population argument takes a character vector indicating the
subpopulations to use for splitting (as identified by the population name in
the filterDetails slot). Alternatively, this can be a list of
characters, in which case the populations for each list item are collapsed
into one flowFrame. Note that using the
population argument implies common population names for
allfilterResults in the list and there will be an error
if this is not the case.
F Hahne, B. Ellis, N. Le Meur
data(GvHD) qGate <- quadGate(filterId="qg", "FSC-H"=200, "SSC-H"=400) ## split a flowFrame by a filter that creates ## a multipleFilterResult samp <- GvHD[[1]] fres <- filter(samp, qGate) split(samp, qGate) ## return a flowSet rather than a list split(samp, fres, flowSet=TRUE) ## only keep one population names(fres) ##split(samp, fres, population="FSC-Height+SSC-Height+") ## split the whole set, only keep two populations ##split(GvHD, qGate, population=c("FSC-Height+SSC-Height+", ##"FSC-Height-SSC-Height+")) ## now split the flowSet according to a factor split(GvHD, pData(GvHD)$Patient)data(GvHD) qGate <- quadGate(filterId="qg", "FSC-H"=200, "SSC-H"=400) ## split a flowFrame by a filter that creates ## a multipleFilterResult samp <- GvHD[[1]] fres <- filter(samp, qGate) split(samp, qGate) ## return a flowSet rather than a list split(samp, fres, flowSet=TRUE) ## only keep one population names(fres) ##split(samp, fres, population="FSC-Height+SSC-Height+") ## split the whole set, only keep two populations ##split(GvHD, qGate, population=c("FSC-Height+SSC-Height+", ##"FSC-Height-SSC-Height+")) ## now split the flowSet according to a factor split(GvHD, pData(GvHD)$Patient)
The split scale transformation class defines a transformation that has a logarithmic scale at high values and a linear scale at low values. The transition points are chosen so that the slope of the transformation is continuous at the transition points.
The split scale transformation is defined by the function
where,
.DataObject of class "function".
rObject of class "numeric" – a positive value indicating the range of the logarithmic
part of the display.
maxValueObject of class "numeric" – a positive value indicating the maximum value the transformation
is applied to.
transitionChannelObject of class "numeric" – non negative value that indicates where to
split the linear vs. logarithmic transformation.
parametersObject of class "transformation" – flow parameter to be transformed.
transformationIdObject of class "character" – unique ID to reference the transformation.
Objects can be created by calls to the
constructor
splitscale(parameters,r,maxValue,transitionChannel,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a matrix with a single column. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry
invsplitscale
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
squareroot-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) sp1<-splitscale("FSC-H",r=768,maxValue=10000,transitionChannel=256) transOut<-eval(sp1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08",package="flowCore")) sp1<-splitscale("FSC-H",r=768,maxValue=10000,transitionChannel=256) transOut<-eval(sp1)(exprs(dat))
The split scale transformation described by Francis L. Battye [B15] (Figure 13) consists of a logarithmic scale at high values and a linear scale at low values with a fixed transition point chosen so that the slope (first derivative) of the transform is continuous at that point. The scale extends to the negative of the transition value that is reached at the bottom of the display.
splitScaleTransform(transformationId="defaultSplitscaleTransform", maxValue=1023, transitionChannel=64, r=192)splitScaleTransform(transformationId="defaultSplitscaleTransform", maxValue=1023, transitionChannel=64, r=192)
transformationId |
A name to assign to the transformation. Used by the transform/filter integration routines. |
maxValue |
Maximum value the transformation is applied to, e.g., 1023 |
transitionChannel |
Where to split the linear versus the logarithmic transformation, e.g., 64 |
r |
Range of the logarithm part of the display, ie. it may be expressed as the maxChannel - transitionChannel considering the maxChannel as the maximum value to be obtained after the transformation. |
Returns values giving the inverse of the biexponential within a
certain tolerance. This function should be used with care as numerical
inversion routines often have problems with the inversion process due to the
large range of values that are essentially 0. Do not be surprised if you end
up with population splitting about w and other odd artifacts.
N. LeMeur
Battye F.L. A Mathematically Simple Alternative to the Logarithmic Transform for Flow Cytometric Fluorescence Data Displays. http://www.wehi.edu.au/cytometry/Abstracts/AFCG05B.html.
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
truncateTransform()
data(GvHD) ssTransform <- splitScaleTransform("mySplitTransform") after.1 <- transform(GvHD, transformList('FSC-H', ssTransform)) opar = par(mfcol=c(2, 1)) plot(density(exprs(GvHD[[1]])[, 1]), main="Original") plot(density(exprs(after.1[[1]])[, 1]), main="Split-scale Transform")data(GvHD) ssTransform <- splitScaleTransform("mySplitTransform") after.1 <- transform(GvHD, transformList('FSC-H', ssTransform)) opar = par(mfcol=c(2, 1)) plot(density(exprs(GvHD[[1]])[, 1]), main="Original") plot(density(exprs(after.1[[1]])[, 1]), main="Split-scale Transform")
Square root transform class, which represents a transformation defined by the function
.DataObject of class "function"
aObject of class "numeric" – non-zero multiplicative
constant
parametersObject of class "transformation" – flow
parameter to be transformed.
transformationIdObject of class "character" – unique
ID to reference the transformation.
Objects can be created by calls to the
constructor squareroot(parameters,a,transformationId)
Class "singleParameterTransform", directly.
Class "transform", by class "singleParameterTransform", distance 2.
Class "transformation", by class "singleParameterTransform", distance 3.
Class "characterOrTransformation", by class "singleParameterTransform", distance 4.
The squareroot transformation object can be evaluated using the eval method by passing the data frame as an argument.The transformed parameters are returned as a column vector. (See example below)
Gopalakrishnan N, F.Hahne
Gating-ML Candidate Recommendation for Gating Description in Flow Cytometry
dg1polynomial, ratio, quadratic
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
unitytransform-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) sqrt1<-squareroot(parameters="FSC-H",a=2,transformationId="sqrt1") transOut<-eval(sqrt1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) sqrt1<-squareroot(parameters="FSC-H",a=2,transformationId="sqrt1") transOut<-eval(sqrt1)(exprs(dat))
An equivalent of a subset function for
flowFrame or a flowSet object.
Alternatively, the regular subsetting operators can be used for most of the
topics documented here.
Subset(x, subset, ...)Subset(x, subset, ...)
x |
The flow object, frame or set, to subset. |
subset |
A filter object or, in the case of |
... |
Like the original |
The Subset method is the recommended method for obtaining a
flowFrame that only contains events consistent with a
particular filter. It is functionally equivalent to
frame[as(filter(frame,subset),"logical"),] when used in the
flowFrame context. Used in the
flowSet context, it is equivalent to using
fsApply to apply the filtering operation to each
flowFrame.
Additionally, using Subset on a flowSet can also
take a named list as the subset. In this case, the names of the list
object should correspond to the sampleNames of the flowSet, allowing
a different filter to be applied to each frame. If not all of the names are
used or excess names are present, a warning will be generated but the valid
filters will be applied for the rare instances where this is the intended
operation. Note that a filter operation will generate a list
of filterResult objects that can be used directly with
Subset in this manner.
Depending on the original context, either a flowFrame
or a flowSet.
B. Ellis
sample <- read.flowSet(path=system.file("extdata", package="flowCore"), pattern="0877408774") result <- filter(sample, rectangleGate("FSC-H"=c(-Inf, 1024))) result Subset(sample,result)sample <- read.flowSet(path=system.file("extdata", package="flowCore"), pattern="0877408774") result <- filter(sample, rectangleGate("FSC-H"=c(-Inf, 1024))) result Subset(sample,result)
This class represents the action of applying a filter on the subset of data resulting from another filter. This is itself a filter that can be incorporated in to further set operations. This is similar to an intersectFilter, with behavior only differing if the component filters are data-driven.
subsetFilters are constructed using the equivalent binary set operators
"%&%" or "%subset%". The operator is not symmetric, as the
filter on the right-hand side will take the subset of the filter on the
left-hand side as input. Left-hand side operands can be a filter or list of
filters, while the right-hand side operand must be a single
filter.
filtersObject of class "list", containing the component filters.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
B. Ellis
Other setOperationFilter classes:
complementFilter-class,
intersectFilter-class,
setOperationFilter-class,
unionFilter-class
Internal methods to populate the filterDetails slot of a
filterResult object.
summarizeFilter(result, filter)summarizeFilter(result, filter)
result |
A |
filter |
The corresponding |
summarizeFilter
methods are called during the process of filtering. Their output is a list,
and it can be arbitrary data that should be stored along with the results of
a filtering operation.
see above
see above
see above
see above
see above
see above
Define a filter that removes stretches of unusual data
distribution within a single parameter over time. This can be used to
correct for problems during data acquisition like air bubbles or clods.
timeFilter(..., bandwidth=0.75, binSize, timeParameter, filterId="defaultTimeFilter")timeFilter(..., bandwidth=0.75, binSize, timeParameter, filterId="defaultTimeFilter")
... |
The names of the parameters on which the filter is supposed to work on. Names can either be given as individual arguments, or as a list or a character vector. |
filterId |
An optional parameter that sets the |
bandwidth, binSize
|
Numerics used to set the |
timeParameter |
Character used to set the |
Clods and disturbances in the laminar flow of a FACS instrument can cause
temporal aberrations in the data acquisition that lead to artifactual
values. timeFilters try to identify such stretches of disturbance by
computing local variance and location estimates and to remove them from the
data.
Returns a timeFilter object for use in filtering
flowFrames or other flow cytometry objects.
bandwidthObject of class "numeric". The
sensitivity of the filter, i.e., the amount of local variance of
the signal we want to allow.
binSizeObject of class "numeric". The size
of the bins used for the local variance and location
estimation. If NULL, a reasonable default is used when
evaluating the filter.
timeParameterObject of class "character",
used to define the time domain parameter. If NULL, the
filter tries to guess the time domain from the flowFrame.
parametersObject of class "character",
describing the parameters used to filter the flowFrame.
filterIdObject of class "character",
referencing the filter.
Class "parameterFilter", directly.
Class "concreteFilter", by class
parameterFilter, distance 2.
Class "filter", by class parameterFilter,
distance 3.
Objects can be created by calls of the form new("timeFilter",
...) or using the constructor timeFilter. Using the
constructor is the recommended way.
signature(x = "flowFrame", table =
"timeFilter"): The workhorse used to evaluate the filter on
data. This is usually not called directly by the user.
signature(object = "timeFilter"): Print
information about the filter.
See the documentation of timeLinePlot in
the flowViz package for details on
visualizing temporal problems in flow cytometry data.
Florian Hahne
flowFrame, filter for
evaluation of timeFilters and split and
Subsetfor splitting and subsetting of flow cytometry data sets
based on that.
## Loading example data data(GvHD) dat <- GvHD[1:10] ## create the filter tf <- timeFilter("SSC-H", bandwidth=1, filterId="myTimeFilter") tf ## Visualize problems ## Not run: library(flowViz) timeLinePlot(dat, "SSC-H") ## End(Not run) ## Filtering using timeFilters fres <- filter(dat, tf) fres[[1]] summary(fres[[1]]) summary(fres[[7]]) ## The result of rectangle filtering is a logical subset cleanDat <- Subset(dat, fres) ## Visualizing after cleaning up ## Not run: timeLinePlot(cleanDat, "SSC-H") ## End(Not run) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations allDat <- split(dat[[7]], fres[[7]]) par(mfcol=c(1,3)) plot(exprs(dat[[7]])[, "SSC-H"], pch=".") plot(exprs(cleanDat[[7]])[, "SSC-H"], pch=".") plot(exprs(allDat[[2]])[, "SSC-H"], pch=".")## Loading example data data(GvHD) dat <- GvHD[1:10] ## create the filter tf <- timeFilter("SSC-H", bandwidth=1, filterId="myTimeFilter") tf ## Visualize problems ## Not run: library(flowViz) timeLinePlot(dat, "SSC-H") ## End(Not run) ## Filtering using timeFilters fres <- filter(dat, tf) fres[[1]] summary(fres[[1]]) summary(fres[[7]]) ## The result of rectangle filtering is a logical subset cleanDat <- Subset(dat, fres) ## Visualizing after cleaning up ## Not run: timeLinePlot(cleanDat, "SSC-H") ## End(Not run) ## We can also split, in which case we get those events in and those ## not in the gate as separate populations allDat <- split(dat[[7]], fres[[7]]) par(mfcol=c(1,3)) plot(exprs(dat[[7]])[, "SSC-H"], pch=".") plot(exprs(cleanDat[[7]])[, "SSC-H"], pch=".") plot(exprs(allDat[[2]])[, "SSC-H"], pch=".")
Similar to the base transform method, this will transform the values of a flowFrame or flowSet object according to the transformations specified in one of two ways: 1. a [transformList][flowCore::transformList-class] or list of [transform][flowCore::transform-class] objects 2. named arguments specifying transformations to be applied to channels (see details)
## S4 method for signature 'flowFrame' transform(x, translist, ...)## S4 method for signature 'flowFrame' transform(x, translist, ...)
x |
a flowFrame or flowSet object |
translist |
a transformList object |
... |
other arguments. e.g. 'FL1-H' = myFunc('FL1-H') |
To specify the transformations in the second way, the names of these arguments should correspond to the new channel names and the values should be functions applied to channels currently present in the flowFrame or flowSet. There are a few examples below.
data(GvHD) # logarithmically transform FL1-H and FL2-H for the entire flowSet # using a transformList fs <- transform(GvHD, transformList(c("FL1-H", "FL2-H"), list(log, log))) # transform a single flowFrame using named arguments. Note the first # transformation will overwrite FL1-H while the second will create a new # channel fr <- transform(GvHD[[1]], `FL1-H`=log(`FL1-H`), `logFL2`=log(`FL2-H`))data(GvHD) # logarithmically transform FL1-H and FL2-H for the entire flowSet # using a transformList fs <- transform(GvHD, transformList(c("FL1-H", "FL2-H"), list(log, log))) # transform a single flowFrame using named arguments. Note the first # transformation will overwrite FL1-H while the second will create a new # channel fr <- transform(GvHD[[1]], `FL1-H`=log(`FL1-H`), `logFL2`=log(`FL2-H`))
Perform geometric transformations of Gate-type filter objects
## Default S3 method: transform_gate( obj, scale = NULL, deg = NULL, rot_center = NULL, dx = NULL, dy = NULL, center = NULL, ... )## Default S3 method: transform_gate( obj, scale = NULL, deg = NULL, rot_center = NULL, dx = NULL, dy = NULL, center = NULL, ... )
obj |
A Gate-type |
scale |
Either a numeric scalar (for uniform scaling in all dimensions) or numeric vector specifying the factor by which each dimension of the gate should be expanded (absolute value > 1) or contracted (absolute value < 1). Negative values will result in a reflection in that dimension. For |
deg |
An angle in degrees by which the gate should be rotated in the counter-clockwise direction. |
rot_center |
A separate 2-dimensional center of rotation for the gate, if desired. By default, this will
be the center for |
dx |
Either a numeric scalar or numeric vector. If it is scalar, this is just the desired shift of the gate in
its first dimension. If it is a vector, it specifies both |
dy |
A numeric scalar specifying the desired shift of the gate in its second dimension. |
center |
A numeric vector specifying where the center or centroid should be moved (rather than specifiying |
... |
Assignments made to the slots of the particular Gate-type filter object in the form "<slot_name> = <value>" |
This method allows changes to the four filter types defined by simple geometric gates (quadGate,
rectangleGate, ellipsoidGate, and polygonGate) using
equally simple geometric transformations (shifting/translation, scaling/dilation, and rotation). The method also
allows for directly re-setting the slots of each Gate-type object. Note that these methods are for manually altering
the geometric definition of a gate. To easily transform the definition of a gate with an accompanyging scale
transformation applied to its underlying data, see rescale_gate.
First, transform_gate will apply any direct alterations to the slots of the supplied Gate-type filter object.
For example, if "mean = c(1,3)" is present in the argument list when transform_gate is called on a
ellipsoidGate object, the first change applied will be to shift the mean slot to (1,3). The method
will carry over the dimension names from the gate, so there is no need to provide column or row names with arguments
such as mean or cov for ellipsoidGate or boundaries for polygonGate.
transform_gate then passes the geometric arguments (dx, dy, deg, rot_center, scale,
and center) to the methods which perform each respective type of transformation:
shift_gate, scale_gate, or rotate_gate. The order of operations is to first
scale, then rotate, then shift. The default behavior of each operation follows that of its corresponding method but for
the most part these are what the user would expect. A few quick notes:
rotate_gate is not defined for rectangleGate or quadGate objects, due to their definition as
having 1-dimensional boundaries.
The default center for both rotation and scaling of a polygonGate is the centroid of the polygon. This
results in the sort of scaling most users expect, with a uniform scale factor not distorting the shape of the original polygon.
A Gate-type filter object of the same type as gate, with the geometric transformations applied
## Not run: # Scale the original gate non-uniformly, rotate it 15 degrees, and shift it transformed_gate <- transform_gate(original_gate, scale = c(2,3), deg = 15, dx = 500, dy = -700) # Scale the original gate (in this case an ellipsoidGate) after moving its center to (1500, 2000) transformed_gate <- transform_gate(original_gate, scale = c(2,3), mean = c(1500, 2000)) ## End(Not run)## Not run: # Scale the original gate non-uniformly, rotate it 15 degrees, and shift it transformed_gate <- transform_gate(original_gate, scale = c(2,3), deg = 15, dx = 500, dy = -700) # Scale the original gate (in this case an ellipsoidGate) after moving its center to (1500, 2000) transformed_gate <- transform_gate(original_gate, scale = c(2,3), mean = c(1500, 2000)) ## End(Not run)
Transform objects are simply functions that have been extended to allow for specialized dispatch. All of the “...Transform” constructors return functions of this type for use in one of the transformation modalities.
.DataObject of class "function"
transformationIdA name for the transformation object
summaryReturn the parameters
N LeMeur
linearTransform,
lnTransform,
logicleTransform,
biexponentialTransform,
arcsinhTransform,
quadraticTransform,
logTransform
cosTransform <- function(transformId, a=1, b=1){ t = new("transform", .Data = function(x) cos(a*x+b)) t@transformationId = transformId t } cosT <- cosTransform(transformId="CosT",a=2,b=1) summary(cosT)cosTransform <- function(transformId, a=1, b=1){ t = new("transform", .Data = function(x) cos(a*x+b)) t@transformationId = transformId t } cosT <- cosTransform(transformId="CosT",a=2,b=1) summary(cosT)
A virtual class to abstract transformations.
A virtual Class: No objects may be created from it.
Class "characterOrTransformation", directly.
N. Gopalakrishnan
The transformFilter class is a mechanism for including one or more
variable transformations into the filtering process. Using a special case of
transform we can introduce
transformations inline with the filtering process eliminating the need to
process flowFrame objects before
applying a filter.
transformsA list of transforms to perform on the
target flowFrame
filterThe filter to be applied to the transformed frame
filterIdThe name of the filter (chosen automatically)
Objects of this type are not generally created “by hand”. They are a side
effect of the use of the %on%
method with a filter object on the
left hand side and a
transformList on the right hand
side.
Class "filter", directly.
B. Ellis
"filter", "transform",
transform
require(flowStats) samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) ## Gate this object after log transforming the forward and side ## scatter variables filter(samp, norm2Filter("FSC-H", "SSC-H", scale.factor=2) %on% transform("FSC-H"=log,"SSC-H"=log))require(flowStats) samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) ## Gate this object after log transforming the forward and side ## scatter variables filter(samp, norm2Filter("FSC-H", "SSC-H", scale.factor=2) %on% transform("FSC-H"=log,"SSC-H"=log))
A list of transformMaps to be applied to a list of parameters.
transformList(from, tfun, to=from, transformationId = "defaultTransformation")transformList(from, tfun, to=from, transformationId = "defaultTransformation")
from, to
|
Characters giving the names of the measurement parameter on which to transform on and into which the result is supposed to be stored. If both are equal, the existing parameters will be overwritten. |
tfun |
A list if functions or a character vector of the names of the functions used to transform the data. R's recycling rules apply, so a single function can be given to be used on all parameters. |
transformationId |
The identifier for the object. |
transformsObject of class "list", where each
list item is of class transformMap.
transformationIdObject of class "character",
the identifier for the object.
Objects can be created by calls of the form new("transformList",
...), by calling the transform method with key-value pair
arguments of the form key equals character and value equals
function, or by using the constructor transformList. See below for
details
signature(x = "transformList"): This returns
the names of the parameters that are to be transformed.
signature(x = "transformList"): Concatenate
transformLists or regular lists and transformLists.
signature(e1 = "transformList", e2 =
"flowFrame"): Perform a transformation using the
transformList on a flowFrame or
flowSet.
B. Ellis, F. Hahne
tl <- transformList(c("FSC-H", "SSC-H"), list(log, asinh)) colnames(tl) c(tl, transformList("FL1-H", "linearTransform")) data(GvHD) transform(GvHD[[1]], tl)tl <- transformList(c("FSC-H", "SSC-H"), list(log, asinh)) colnames(tl) c(tl, transformList("FL1-H", "linearTransform")) data(GvHD) transform(GvHD[[1]], tl)
This class provides a mapping between parameters and transformed parameters via a function.
outputName of the transformed parameter.
inputName of the parameter to transform.
fFunction used to accomplish the transform.
Objects of this type are not usually created by the user, except perhaps in
special circumstances. They are generally automatically created by the
inline transform process during the
creation of a transformFilter, or by a call to the
transformList constructor.
signature(object = "transformList"): Print details
about the object.
B. Ellis, F. Hahne
new("transformMap", input="FSC-H", output="FSC-H", f=log)new("transformMap", input="FSC-H", output="FSC-H", f=log)
Class allowing for reference of transforms, for instance as parameters.
.DataThe list of references.
searchEnvThe environment into which the reference points.
transformationIdThe name of the transformation.
Objects will be created internally whenever necessary and this should not be of any concern to the user.
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
N. Gopalakrishnan
Create the definition of the truncate Transformation that will be applied on
some parameter via the transform method. The definition of this
function is currently x[x<a] <- a. Hence, all values less than a are
replaced by a. The typical use would be to replace all values less than 1 by
1.
truncateTransform(transformationId="defaultTruncateTransform", a=1)truncateTransform(transformationId="defaultTruncateTransform", a=1)
transformationId |
character string to identify the transformation |
a |
double that corresponds to the value at which to truncate |
Returns an object of class transform.
P. Haaland
Other Transform functions:
arcsinhTransform(),
biexponentialTransform(),
inverseLogicleTransform(),
linearTransform(),
lnTransform(),
logTransform(),
logicleTransform(),
quadraticTransform(),
scaleTransform(),
splitScaleTransform()
samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) truncateTrans <- truncateTransform(transformationId="Truncate-transformation", a=5) dataTransform <- transform(samp,transformList('FSC-H', truncateTrans))samp <- read.FCS(system.file("extdata", "0877408774.B08", package="flowCore")) truncateTrans <- truncateTransform(transformationId="Truncate-transformation", a=5) dataTransform <- transform(samp,transformList('FSC-H', truncateTrans))
This class represents the union of two filters, which is itself a filter
that can be incorporated in to further set operations. unionFilters
are constructed using the binary set operator "|" with operands
consisting of a single filter or list of filters.
filtersObject of class "list", containing the component filters.
filterIdObject of class "character"
referencing the filter applied.
Class "filter", directly.
B. Ellis
Other setOperationFilter classes:
complementFilter-class,
intersectFilter-class,
setOperationFilter-class,
subsetFilter-class
Unity transform class transforms parameters names provided as characters into unity transform objects which can be evaluated to retrieve the corresponding columns from the data frame
.DataObject of class "function".
parametersObject of class "character" – the flow
parameters to be transformed.
transformationIdObject of class "character" – a unique Id to
reference the transformation.
Objects can be created by calls to the
constructor unitytransform(parameters,transformationId).
Class "transform", directly.
Class "transformation", by class "transform", distance 2.
Class "characterOrTransformation", by class "transform", distance 3.
Gopalakrishnan N, F.Hahne
dg1polynomial, ratio
Other mathematical transform classes:
EHtrans-class,
asinht-class,
asinhtGml2-class,
dg1polynomial-class,
exponential-class,
hyperlog-class,
hyperlogtGml2-class,
invsplitscale-class,
lintGml2-class,
logarithm-class,
logicletGml2-class,
logtGml2-class,
quadratic-class,
ratio-class,
ratiotGml2-class,
sinht-class,
splitscale-class,
squareroot-class
dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) un1<-unitytransform(c("FSC-H","SSC-H"),transformationId="un1") transOut<-eval(un1)(exprs(dat))dat <- read.FCS(system.file("extdata","0877408774.B08", package="flowCore")) un1<-unitytransform(c("FSC-H","SSC-H"),transformationId="un1") transOut<-eval(un1)(exprs(dat))
modify description to reflect the transformation Involve inserting/updating 'transformation' and flowCore_$PnRmax keywords
updateTransformKeywords(fr)updateTransformKeywords(fr)
fr |
flowFrame |
updated description slot
Check if all filters in a filters matches same paramters
validFilters(flist)validFilters(flist)
flist |
a filters object |
TRUE or FALSE
Write FCS file from a flowFrame
write.FCS(x, filename, what="numeric", delimiter = "|", endian="big")write.FCS(x, filename, what="numeric", delimiter = "|", endian="big")
x |
A |
filename |
A character scalar giving the output file name. |
what |
A character scalar defining the output data type. One in
|
delimiter |
a single character to separate the FCS keyword/value pairs. Default is : "|" |
endian |
a character, either "little" or "big" (default), specifying the most significant or least significant byte is stored first in a 32 bit word. |
The function write.FCS creates FCS 3.0 standard file from an object
of class flowFrame.
For specifications of FCS 3.0 see http://www.isac-net.org and the file
../doc/fcs3.html in the doc directory of the package.
A character vector of the file name.
F. Hahne
link[flowCore]{write.flowSet}
## a sample file inFile <- system.file("extdata", "0877408774.B08", package="flowCore") foo <- read.FCS(inFile, transform=FALSE) outFile <- file.path(tempdir(), "foo.fcs") ## now write out into a file write.FCS(foo, outFile) bar <- read.FCS(outFile, transform=FALSE) all(exprs(foo) == exprs(bar))## a sample file inFile <- system.file("extdata", "0877408774.B08", package="flowCore") foo <- read.FCS(inFile, transform=FALSE) outFile <- file.path(tempdir(), "foo.fcs") ## now write out into a file write.FCS(foo, outFile) bar <- read.FCS(outFile, transform=FALSE) all(exprs(foo) == exprs(bar))
Write FCS file for each flowFrame in a flowSet
write.flowSet(x, outdir=identifier(x), filename, ...)write.flowSet(x, outdir=identifier(x), filename, ...)
x |
A |
outdir |
A character scalar giving the output directory. As the
default, the output of |
filename |
A character scalar or vector giving the output file names.
By default, the function will use the identifiers of the individual
|
... |
Further arguments that are passed on to
|
The function write.flowSet creates FCS 3.0 standard file for all
flowFrames in an object of class flowSet. In addition, it will
write the content of the phenoData slot in the ASCII file
"annotation.txt". This file can subsequently be used to reconstruct
the whole flowSet using the read.flowSet
function, e.g.:
read.flowSet(path=outdir, phenoData="annotation.txt"
The function uses write.FCS for the actual writing
of the FCS files.
A character vector of the output directory.
F. Hahne
link[flowCore]{write.FCS}
## sample data data(GvHD) foo <- GvHD[1:5] outDir <- file.path(tempdir(), "foo") ## now write out into files write.flowSet(foo, outDir) dir(outDir) ## and read back in bar <- read.flowSet(path=outDir, phenoData="annotation.txt")## sample data data(GvHD) foo <- GvHD[1:5] outDir <- file.path(tempdir(), "foo") ## now write out into files write.flowSet(foo, outDir) dir(outDir) ## and read back in bar <- read.flowSet(path=outDir, phenoData="annotation.txt")