Chromatograms-class {MSnbase}R Documentation

Container for multiple Chromatogram objects

Description

The Chromatograms class allows to store Chromatogram objects in a matrix-like two-dimensional structure.

Chromatograms: create an instance of class Chromatograms.

Chromatograms objects can, just like a matrix, be subsetted using the [ method. Single elements, rows or columns can be replaced using e.g. x[1, 1] <- value where value has to be a Chromatogram object or a list of such objects.

plot: plots a Chromatograms object. For each row in the object one plot is created, i.e. all Chromatogram objects in the same row are added to the same plot.

phenoData: accesses the phenotypical desccription of the samples. Returns an NAnnotatedDataFrame object.

pData: accesses the phenotypical description of the samples. Returns a data.frame.

pData<-: replace the phenotype data.

$ and $<-: get or replace individual columns of the object's pheno data.

colnames<-: replace or set the column names of the Chromatograms object. Does also set the rownames of the phenoData.

sampleNames: get the sample names.

sampleNames<-: replace or set the sample names of the Chromatograms object (i.e. the rownames of the pheno data and colnames of the data matrix.

isEmpty: returns TRUE if the Chromatograms object or all of its Chromatogram objects is/are empty or contain only NA intensities.

featureNames: returns the feature names of the Chromatograms object.

featureNames<-: set the feature names.

featureData: return the feature data.

featureData<-: replace the object's feature data.

fData: return the feature data as a data.frame.

fData<-: replace the object's feature data by passing a data.frame

fvarLabels: return the feature data variable names (i.e. column names).

rownames<-: replace the rownames (and featureNames) of the object.

precursorMz: return the precursor m/z from the chromatograms. The method returns a matrix with 2 columns ("mzmin" and "mzmax") and as many rows as there are rows in the Chromatograms object. Each row contains the precursor m/z of the chromatograms in that row. An error is thrown if the chromatograms within one row have different precursor m/z values.

productMz: return the product m/z from the chromatograms. The method returns a matrix with 2 columns ("mzmin" and "mzmax") and as many rows as there are rows in the Chromatograms object. Each row contains the product m/z of the chromatograms in that row. An error is thrown if the chromatograms within one row have different product m/z values.

mz: returns the m/z for each row of the Chromatograms object as a two-column matrix (with columns "mzmin" and "mzmax").

polarity: returns the polarity of the scans/chromatograms: '1', '0' or '-1' for positive, negative or unknown polarity.

Usage

Chromatograms(data, phenoData, featureData, ...)

## S4 method for signature 'Chromatograms'
show(object)

## S4 method for signature 'Chromatograms,ANY,ANY,ANY'
x[i, j, drop = FALSE]

## S4 replacement method for signature 'Chromatograms'
x[i, j] <- value

## S4 method for signature 'Chromatograms,ANY'
plot(x, col = "#00000060", lty = 1,
  type = "l", xlab = "retention time", ylab = "intensity", main = NULL,
  ...)

## S4 method for signature 'Chromatograms'
phenoData(object)

## S4 method for signature 'Chromatograms'
pData(object)

## S4 replacement method for signature 'Chromatograms,data.frame'
pData(object) <- value

## S4 method for signature 'Chromatograms'
x$name

## S4 replacement method for signature 'Chromatograms'
x$name <- value

## S4 replacement method for signature 'Chromatograms'
colnames(x) <- value

## S4 method for signature 'Chromatograms'
sampleNames(object)

## S4 replacement method for signature 'Chromatograms,ANY'
sampleNames(object) <- value

## S4 method for signature 'Chromatograms'
isEmpty(x)

## S4 method for signature 'Chromatograms'
featureNames(object)

## S4 replacement method for signature 'Chromatograms'
featureNames(object) <- value

## S4 method for signature 'Chromatograms'
featureData(object)

## S4 replacement method for signature 'Chromatograms,ANY'
featureData(object) <- value

## S4 method for signature 'Chromatograms'
fData(object)

## S4 replacement method for signature 'Chromatograms,ANY'
fData(object) <- value

## S4 method for signature 'Chromatograms'
fvarLabels(object)

## S4 replacement method for signature 'Chromatograms'
rownames(x) <- value

## S4 method for signature 'Chromatograms'
precursorMz(object)

## S4 method for signature 'Chromatograms'
productMz(object)

## S4 method for signature 'Chromatograms'
mz(object)

## S4 method for signature 'Chromatograms'
polarity(object)

Arguments

data

A list of Chromatogram objects.

phenoData

either a data.frame, AnnotatedDataFrame or NAnnotatedDataFrame describing the phenotypical information of the samples.

featureData

either a data.frame or AnnotatedDataFrame with additional information for each row of chromatograms.

...

Additional parameters to be passed to the matrix constructor, such as nrow, ncol and byrow.

object

a Chromatograms object.

x

For all methods: a Chromatograms object.

i

For [: numeric, logical or character defining which row(s) to extract.

j

For [: numeric, logical or character defining which columns(s) to extract.

drop

For [: logical(1) whether to drop the dimensionality of the returned object (if possible). The default is drop = FALSE, i.e. each subsetting returns a Chromatograms object (or a Chromatogram object if a single element is extracted).

value

For [<-: the replacement object(s). Can be a list of Chromatogram objects or, if length of i and j are 1, a single Chromatogram object.

For pData<-: a data.frame with the number of rows matching the number of columns of object.

For colnames: a character with the new column names.

col

For plot: the color to be used for plotting. Either a vector of length 1 or equal to ncol(x).

lty

For plot: the line type (see plot for more details. Can be either a vector of length 1 or of length equal to ncol(x).

type

For plot: the type of plot (see plot for more details. Can be either a vector of length 1 or of length equal to ncol(x).

xlab

For plot: the x-axis label.

ylab

For plot: the y-axis label.

main

For plot: the plot title. If not provided the mz range will be used as plot title.

name

For $, the name of the pheno data column.

Details

The Chromatograms class extends the base matrix class and hence allows to store Chromatogram objects in a two-dimensional array. Each row is supposed to contain Chromatogram objects for one MS data slice with a common m/z and rt range. Columns contain Chromatogram objects from the same sample.

plot: if nrow(x) > 1 the plot area is split into nrow(x) sub-plots and the chromatograms of one row are plotted in each.

Value

For [: the subset of the Chromatograms object. If a single element is extracted (e.g. if i and j are of length 1) a Chromatogram object is returned. Otherwise (if drop = FALSE, the default, is specified) a Chromatograms object is returned. If drop = TRUE is specified, the method returns a list of Chromatogram objects.

For phenoData: an NAnnotatedDataFrame representing the pheno data of the object.

For pData: a data.frame representing the pheno data of the object.

For $: the value of the corresponding column in the pheno data table of the object.

Note

Subsetting with [ will always return a Chromatograms object (with the exception of extracting a single element) unless drop = TRUE is specified. This is different from the default subsetting behaviour of matrix-like objects.

Author(s)

Johannes Rainer

See Also

Chromatogram for the class representing chromatogram data. chromatogram for the method to extract a Chromatograms object from a MSnExp or OnDiskMSnExp object. readSRMData for the function to read chromatographic data of an SRM/MRM experiment.

Examples

## Creating some chromatogram objects to put them into a Chromatograms object
ints <- abs(rnorm(25, sd = 200))
ch1 <- Chromatogram(rtime = 1:length(ints), ints)
ints <- abs(rnorm(32, sd = 90))
ch2 <- Chromatogram(rtime = 1:length(ints), ints)
ints <- abs(rnorm(19, sd = 120))
ch3 <- Chromatogram(rtime = 1:length(ints), ints)
ints <- abs(rnorm(21, sd = 40))
ch4 <- Chromatogram(rtime = 1:length(ints), ints)

## Create a Chromatograms object with 2 rows and 2 columns
chrs <- Chromatograms(list(ch1, ch2, ch3, ch4), nrow = 2)
chrs

## Extract the first element from the second column. Extracting a single
## element always returns a Chromatogram object.
chrs[1, 2]

## Extract the second row. Extracting a row or column (i.e. multiple elements
## returns by default a list of Chromatogram objects.
chrs[2, ]

## Extract the second row with drop = FALSE, i.e. return a Chromatograms
## object.
chrs[2, , drop = FALSE]

## Replace the first element.
chrs[1, 1] <- ch3
chrs

## Add a pheno data.
pd <- data.frame(name = c("first sample", "second sample"),
    idx = 1:2)
pData(chrs) <- pd

## Column names correspond to the row names of the pheno data
chrs

## Access a column within the pheno data
chrs$name

## Access the m/z ratio for each row; this will be NA for the present
## object
mz(chrs)

## Create some random Chromatogram objects
ints <- abs(rnorm(123, mean = 200, sd = 32))
ch1 <- Chromatogram(rtime = seq_along(ints), intensity = ints, mz = 231)
ints <- abs(rnorm(122, mean = 250, sd = 43))
ch2 <- Chromatogram(rtime = seq_along(ints), intensity = ints, mz = 231)
ints <- abs(rnorm(125, mean = 590, sd = 120))
ch3 <- Chromatogram(rtime = seq_along(ints), intensity = ints, mz = 542)
ints <- abs(rnorm(124, mean = 1200, sd = 509))
ch4 <- Chromatogram(rtime = seq_along(ints), intensity = ints, mz = 542)

## Combine into a 2x2 Chromatograms object
chrs <- Chromatograms(list(ch1, ch2, ch3, ch4), byrow = TRUE, ncol = 2)

## Plot the second row
plot(chrs[2, , drop = FALSE])

## Plot all chromatograms
plot(chrs, col = c("#ff000080", "#00ff0080"))

[Package MSnbase version 2.6.4 Index]