MSImageSet-class {Cardinal} | R Documentation

## MSImageSet: Class to contain mass spectrometry imaging experiment data

### Description

Container for mass spectrometry imaging experimental data and metadata. `MSImageSet` is derived from `iSet` through `SImageSet`. It extends these classes with information about the processing and analysis, requiring MIAPE-Imaging in its experimentData slot.

### Usage

    ## Instance creation
    MSImageSet(
        spectra = Hashmat(nrow=0, ncol=0),
        mz = seq_len(dim(spectra)[1]),
        coord = expand.grid(
            x = seq_len(prod(dim(spectra)[-1])),
            y = seq_len(ifelse(prod(dim(spectra)[-1]) > 0, 1, 0))),
        imageData = MSImageData(data=spectra, coord=coord),
        pixelData = IAnnotatedDataFrame(
            data=coord,
            varMetadata=data.frame(labelType=rep("dim", ncol(coord)))),
        featureData = AnnotatedDataFrame(
            data=data.frame(mz=mz)),
        processingData = new("MSImageProcess"),
        protocolData = AnnotatedDataFrame(
            data=data.frame(row.names=sampleNames(pixelData))),
        experimentData = new("MIAPE-Imaging"),
        ...)

    ## Additional methods documented below

### Arguments

`spectra` | A matrix-like object with number of rows equal to the number of features and number of columns equal to the number of non-missing pixels. Each column should be a mass spectrum. Alternatively, a multidimensional array that represents the datacube with the first dimension as the features (m/z values) can also be supplied. Additional dimensions could be the spatial dimensions of the image, for example.
`mz` | A numeric vector representing the mass-to-charge ratio features (m/z values) corresponding to the rows in the `spectra` matrix. Must be strictly increasing or decreasing.
`coord` | A `data.frame` with columns representing the spatial dimensions. Each row provides a spatial coordinate for the location of a mass spectrum corresponding to a column in `spectra`. This argument is ignored if `spectra` is a multidimensional array rather than a matrix.
`imageData` | An object of class `SImageData` that will contain the imaging mass spectra. Usually constructed through the `spectra` and `coord` arguments.
`pixelData` | An object of class `IAnnotatedDataFrame` giving the information about the pixels including coordinates of the data in `imageData`.
`featureData` | An object of class `AnnotatedDataFrame` giving information about the data features. Requires a column named "mz".
`processingData` | An object of class `MSImageProcess` giving information about the pre-processing steps applied to the spectra.
`protocolData` | An object of class `AnnotatedDataFrame` giving information about the samples. It must have one row for each of the `sampleNames` in `pixelData`.
`experimentData` | An object derived from class `MIAxE` giving information about the imaging experiment.
`...` | Additional arguments passed to the initializer.

### Slots

`imageData`:

  An instance of `SImageData`, which stores one or more matrices of equal number of dimensions as elements in an 'immutableEnvironment'. This slot preserves copy-on-write behavior when it is modified specifically, but is pass-by-reference otherwise, for memory efficiency.

`pixelData`:

  Contains pixel information in an `IAnnotatedDataFrame`. This includes both pixel coordinates and phenotypic and sample data. Its rows correspond to the columns in `imageData`.

`featureData`:

  Contains variables describing features. Its rows correspond to the rows in `imageData` in an `IAnnotatedDataFrame`.

`processingData`:

  Contains details about the pre-processing steps that have been applied to the spectra. An object of class `MSImageProcess`.

`experimentData`:

  Contains details of experimental methods. Must be `MIAPE-Imaging`.

`protocolData`:

  Contains variables describing the generation of the samples in `pixelData` in an `IAnnotatedDataFrame`.

`.__classVersion__`:

  A `Versions` object describing the version of the class used to created the instance. Intended for developer use.

### Extends

`SImageSet`, directly. `iSet`, by class "SImageSet", distance 1. `VersionedBiobase`, by class "iSet", distance 2. `Versioned`, by class "VersionedBiobase", distance 3.

### Creating Objects

`MSImageSet` instances can be created through `MSImageSet()`, but are more commonly created through reading of external data files.

### Methods

Class-specific methods:

`spectra(object), spectra(object) <- value`:

  Access and set the mass spectra in `imageData`. This is a matrix-like object with rows corresponding to features and columns corresponding to pixels, so that each column of the returned object is a mass spectrum.

`peaks(object), peaks(object) <- value`:

  Access and set the peaks in `imageData` if peak picking have been performed. This is a shortcut for `peakData(imageData(object))`. These are the unaligned peaks. Aligned peaks (if they exist) are accesed by spectra(object).

`mz(object), mz(object) <- value`:

  Returns and sets the common m/z values of the mass spectra in the dataset. This is a required column of `featureData`.

`features(object, ..., mz)`:

  Access the feature indices (rows in `featureData`) corresponding to variables in `featureData`. Bisection search is used for fuzzy matching of m/z values.

`pixels(object, ..., coord)`:

  Access the pixel indices (rows in `pixelData`) corresponding to variables in `pixelData`. If specified, `coord` should be a `data.frame` where each row corresponds to the coordinates of a desired pixel.

`centroided(object), centroided(object) <- value`:

  Access whether the dataset consists of profile or centroided mass spectra. This is a shortcut for `centroided(processingData(object))`. A setter is also provided, and is sometimes necessary for forcing some analysis methods to accept unprocessed spectra. (This is usually a bad idea.)

`processingData(object), processingData(object) <- value`:

  Access and set the `processingData` slot.

Standard generic methods:

`combine(x, y, ...)`:

  Combine two or more `MSImageSet` objects. Unique 'sample's in `pixelData` are treated as a dimension.

`MSImageSet[i, j, ..., drop]`:

  Subset an `SImageSet` based on the rows (featureData components) and the columns (pixelData components). The result is a new `MSImageSet`.

See `iSet` and `SImageSet` for additional methods.

### Author(s)

Kylie A. Bemis

### See Also

`iSet`, `SImageSet`

### Examples

    ## Create an MSImageSet object
    spectra <- matrix(1:27, nrow=3)
    mz <- 101:103
    coord <- expand.grid(x=1:3, y=1:3)
    msset <- MSImageSet(spectra=spectra, mz=mz, coord=coord)

    ## Access a single image corresponding to the first feature
    imageData(msset)[1,,]

    ## Reconstruct the datacube
    imageData(msset)[]

    ## Access the P x N matrix of column-wise mass spectra
    spectra(msset)

    ## Subset the MSImageSet to the first 2 m/z values and first 6 mass spectra
    msset2 <- msset[1:2, 1:6]
    imageData(msset2)[]
    msset2

[Package Cardinal version 2.2.6 Index]