cytoset: 'cytoset': a reference class for efficiently managing the...

View source: R/cytoset.R

cytosetR Documentation

cytoset: a reference class for efficiently managing the data representation of a flowSet


This class is a container for a set of cytoframe objects, analagous to a flowSet.


Similar to the distinction between the cytoframe and flowFrame classes, the primary difference between the cytoset and flowSet classes is in the underlying representation of the data. Because cytoset is a reference class, copying or subsetting a cytoset object will return a cytoset pointing to the same underlying data. A deep copy of the data can be obtained via the realize_view method.

There is one notable exception to the typical behavior of most methods returning a cytoframe. The standard extraction operator ([[]]) will by default perform a deep copy of the subset being extracted and return a flowFrame. This is for the sake of compatibility with existing user scripts.

Creating Objects

Objects can be created using cytoset() and then adding samples by providing a cytoframe and sample name to cs_add_cytoframe:

cs <- cytoset()
cs_add_cytoframe(cs, "Sample Name", cytoframe)

The safest and easiest way to create cytosets directly from FCS files is via the load_cytoset_from_fcs 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 cytoset 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 cytoset for which the parameters of each cytoframe have been subset according to j, x[[i,j]] returns the subset of a single flowFrame for all parameters in j.

The reason for the default behavior of the extraction operator [[]] returning a flowFrame rather than cytoframe is for backwards compatibility with existing user scripts. This behavior can be overridden to instead return a cytoframe with the additional returnType argument.





cytoset[[i, returnType = "cytoframe"]]


Extract a cytoframe from a cytoset by supplying either a sample name or index and optionally supplying a subset of columns.

The cytoframe to be extracted (i argument) can be specified using its sample name (character) or index in the cytoset (int/numeric). Columns (j argument) can be specified using channel name (character), index (int/numeric), or logical vector. If this argument is missing, all columns will be selected.


(Assuming cs is a cytoset and cf is the extracted cytoframe) cf <- get_cytoframe_from_cs(cs, i, j) cf <- get_cytoframe_from_cs(cs, i)


Subsetting by frame name. This will return a single cytoframe object. Note that names may have to be quoted if they are not valid R symbols (e.g. cytoset$"sample 1").

colnames, colnames<-

Extract or replace the character object with the (common) column names of all the data matrices in the cytoframes.



colnames(cytoset) <- value

identifier, identifier<-

Extract or replace the name item from the environment.



identifier(cytoset) <- value

phenoData, phenoData<-

Extract or replace the AnnotatedDataFrame containing the phenotypic data for the whole data set. Each row corresponds to one of the cytoframes. The sampleNames of phenoData (see below) must match the names of the cytoframes in the frames environment.



phenoData(cytoset) <- value

pData, pData<-

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



pData(cytoset)$someColumn <- value

varLabels, varLabels<-

Not yet implemented.
Extract and set varLabels in the AnnotatedDataFrame of the phenoData of the underyling data.



varLabels(cytoset) <- value


Extract and replace sample names from the phenoData. Sample names correspond to frame identifiers, and replacing them will also replace the GUID for each cytoframe. Note that each sample name needs to be unique.



sampleNames(cytoset) <- value


Extract or replace keywords specified in a character vector or a list from the description slot of each frame. See keyword for details.


keyword(cytoset, list(keywords))

keyword(cytoset, keywords)

keyword(cytoset) <- list(foo="bar")


The number of cytoframe objects in the set.




display object summary.


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




Apply a function on all frames in a cytoset object. Similar to sapply, but with additional parameters. See fsApply for details.


fsApply(cytoset, function, ...)

fsApply(cytoset, function, use.exprs=TRUE, ...)


Apply a compensation matrix on all frames in a cytoset object. See compensate for details.


compensate(cytoset, matrix)


Apply a transformation function on all frames of a cytoset object. See transform for details.


transform(cytoset, ...)


Apply a filter on a cytoset object. There are methods for filter objects, and lists of filter objects. The latter has to be a named list, where names of the list items are matching the sampleNames of the cytoset. See filter for details.


filter(cytoset, filter)

filter(cytoset, list(filters))


Split all cytoframe 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 cytoset. This returns a list of cytoframes or an object of class cytoset if the flowSet argument is set to TRUE. Alternatively, a cytoset can be split into separate subsets according to a factor (or any vector that can be coerced into a factor), similar to the behaviour of split for lists. This will return a list of cytosets. See split for details.


split(cytoset, filter)

split(cytoset, filterResult)

split(cytoset, list(filters))

split(cytoset, factor)


Returns a cytoset of cytoframes that have been subset according to a filter or filterResult, or according to a list of such items of equal length as the cytoset. See Subset for details.


Subset(cytoset, filter)

Subset(cytoset, filterResult)

Subset(cytoset, list(filters))


Not yet implemented.
Combine two cytoset objects, or one cytoset and one cytoframe object.


rbind2(cytoset, cytoset)

rbind2(cytoset, cytoframe)


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


Returns a new cytoset with its own copy of the underlying data (a deep copy). The optional filepath argument accepts a string to specify a full directory name for storing the new copies of the data from the FCS files in h5 format.


realize_view(cytoset, filepath)


Adds a cytoframe to the cytoset with sample name given by a string.


cs_add_cytoframe(cytoset, "SampleName", cytoframe)

RGLab/flowWorkspace documentation built on March 17, 2024, 2:24 p.m.