tsLib-class {TargetSearch} | R Documentation

## Class for representing a reference library

### Description

This is a class representation of a reference library.

### Objects from the Class

Objects can be created by the function `ImportLibrary`.

### Slots

`Name`:

  `"character"`, the metabolite or analyte names.

`RI`:

  `"numeric"`, the expected retention time indices (RI) of the metabolites/analytes.

`medRI`:

  `"numeric"`, the median RI calculated from the samples.

`RIdev`:

  `"matrix"`, the RI deviation windows, k = 1,2,3. A three column matrix

`selMass`:

  `"list"`, every component is a numeric vector containing the selective masses.

`topMass`:

  `"list"`, every component is a numeric vector containing the top masses.

`quantMass`:

  `"numeric"`, the mass used for quantification.

`libData`:

  `"data.frame"`, additional library information.

`spectra`:

  `"list"`, the metabolite spectra. Each component is a two column matrix: m/z and intensity.

### Methods

`[`

  `signature(x = "tsLib")`: Selects a subset of metabolites from the library.

`$name`

  `signature(x = "tsLib")`: Access column `name` of `libData` slot.

`libId`

  `signature(obj = "tsLib")`: Returns a vector of indices.

`length`

  `signature(x = "tsLib")`: returns the length of the library. i.e., number of metabolites.

`libData`

  `signature(obj = "tsLib")`: gets/sets the `libData` slot.

`libName`

  `signature(obj = "tsLib")`: gets the `Name` slot.

`libRI`

  `signature(obj = "tsLib")`: gets the `RI` slot.

`medRI`

  `signature(obj = "tsLib")`: gets the `medRI` slot.

`refLib`

  `signature(obj = "tsLib")`: Low level method to create a matrix representation of the library.

`RIdev`

  `signature(obj = "tsLib")`: gets the RI deviations.

`RIdev<-`

  `signature(obj = "tsLib")`: sets the RI deviations.

`quantMass`

  `signature(obj = "tsLib")`: gets the quantification mass.

`quantMass<-`

  `signature(obj = "tsLib")`: sets the quantification mass.

`selMass`

  `signature(obj = "tsLib")`: gets the selective masses.

`show`

  `signature(object = "tsLib")`: show method.

`spectra`

  `signature(obj = "tsLib")`: gets the spectra.

`topMass`

  `signature(obj = "tsLib")`: gets the top masses.

### Note

Some care is needed when using the methods `quantMass<-`, `selMass<-`, `topMass<-`. In order to be consistent, the first m/z value of the slot `topMass` and `selMass` are equal to `quantMass`, and the values of `selMass` are equal to the first couple of values of `topMass`. In other words, the following constrain is applied.

        quantMass : x[0]
        selMass   : x[0], x[1], ..., x[k]
        topMass   : x[0], x[1], ..., x[k], x[k+1], ..., x[n]

where `1 <= k <= n` and `x[i]` is a m/z value. Thus, using one these methods will change the values of the other slots. In the future, these methods will be deprecated, so it is better to not rely on them.

See the last example on how this can lead to unexpected results.

### Author(s)

Alvaro Cuadros-Inostroza, Matthew Hannah, Henning Redestig

### See Also

`ImportLibrary`

### Examples

    showClass("tsLib")

    # define some metabolite names
    libNames   <- c("Metab1", "Metab2", "Metab3")
    # the expected retention index
    RI         <- c(100,200,300)
    # selective masses to search for. A list of vectors.
    selMasses  <- list(c(95,204,361), c(87,116,190), c(158,201,219))
    # define the retention time windows to look for the given selective masses.
    RIdev      <- matrix(rep(c(10,5,2), length(libNames)), ncol = 3, byrow = TRUE)
    # Set the mass spectra. A list object of two-column matrices, or set to
    # NULL if the spectra is not available
    spectra    <- NULL
    # some extra information about the library
    libData    <- data.frame(Name = libNames, Lib_RI = RI)
    # create a reference library object
    refLibrary <- new("tsLib", Name = libNames, RI = RI, medRI = RI, RIdev = RIdev,
                      selMass = selMasses, topMass = selMasses, spectra = spectra, libData = libData)

    # get the metabolite names
    libName(refLibrary)
    # set new names
    libName(refLibrary) <- c("Metab01", "Metab02", "Metab03")

    # get the expected retention times
    libRI(refLibrary)
    # set the retention time index for metabolite 3 to 310 seconds
    libRI(refLibrary)[3] <- 310
    # change the seleccion and top masses of metabolite 3
    selMass(refLibrary)[[3]] <- c(158,201,219,220,323)
    topMass(refLibrary)[[3]] <- c(158,201,219,220,323)
    # change the retention time deviations
    RIdev(refLibrary)[3,] <- c(8,4,1)

    #####################################################################
    #####################################################################
    # These examples show how changing a quantitaive or selective mass
    # could lead to unexpected results.

    # show quantMasses
    quantMass(refLibrary)

    # suposse that we want to change the quant mass of metabolite 1 to 96 due
    # to a typo in the library. We could do just
    quantMass(refLibrary)[1] <- 96

    # however, we still see the mass 95 in the selective and top masses.
    selMass(refLibrary)[[1]]
    topMass(refLibrary)[[1]]

    # to remove the mass 95, set the topMass and selMass explicitely, noting that
    # the first masses coincides with 96 (the quantMass)
    selMass(refLibrary)[[1]] <- c(96, 204, 361)
    topMass(refLibrary)[[1]] <- c(96, 204, 361)

[Package TargetSearch version 1.40.3 Index]