flowSet-class: 'flowSet': a class for storing flow cytometry raw data from...

flowSet-classR Documentation

'flowSet': a class for storing flow cytometry raw data from quantitative cell-based assays

Description

This class is a container for a set of flowFrame objects

Slots

frames

An environment containing one or more flowFrame objects.

phenoData

An 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.

Creating Objects

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.

Methods

[, [[

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"

colnames, colnames<-

Extract or replace the colnames slot.

Usage:

colnames(flowSet)

colnames(flowSet) <- value

identifier, identifier<-

Extract or replace the name item from the environment.

Usage:

identifier(flowSet)

identifier(flowSet) <- value

phenoData, phenoData<-

Extract or replace the AnnotatedDataFrame from the phenoData slot.

Usage:

phenoData(flowSet)

phenoData(flowSet) <- value

pData, pData<-

Extract or replace the data frame (or columns thereof) containing actual phenotypic information from the phenoData slot.

Usage:

pData(flowSet)

pData(flowSet)$someColumn <- value

varLabels, varLabels<-

Extract and set varLabels in the AnnotatedDataFrame of the phenoData slot.

Usage:

varLabels(flowSet)

varLabels(flowSet) <- value

sampleNames

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

keyword

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")

length

number of flowFrame objects in the set.

Usage:

length(flowSet)

show

display object summary.

summary

Return descriptive statistical summary (min, max, mean and quantile) for each channel of each flowFrame

Usage:

summary(flowSet)

fsApply

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, ...)

compensate

Apply a compensation matrix on all frames in a flowSet object. See separate documentation for details.

Usage:

compensate(flowSet, matrix)

transform

Apply a transformation function on all frames of a flowSet object. See separate documentation for details.

Usage:

transform(flowSet, ...)

filter

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

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)

Subset

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))

rbind2

Combine two flowSet objects, or one flowSet and one flowFrame object.

Usage:

rbind2(flowSet, flowSet)

rbind2(flowSet, flowFrame)

spillover

Compute spillover matrix from a compensation set. See separate documentation for details.

Important note on storage and performance

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)]

Author(s)

F. Hahne, B. Ellis, P. Haaland and N. Le Meur

See Also

flowFrame, read.flowSet

Examples


## 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])



RGLab/flowCore documentation built on Aug. 26, 2024, 8:52 a.m.