| flowFrame-class | R Documentation |
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
flowSet, read.FCS
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.