tsLib-class | R Documentation |
This is a class representation of a reference GC library.
Objects of this class are normally created by the function ImportLibrary
, which
is the recommended method, though they can be created manually as shown in the examples.
Use one of the methods described below to set or get the information of various slots. Most of them are self-evident, but we describe some methods in the following paragraphs.
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.
The c
method requires that the combination of all objects have unique identifiers (names),
or in other words, the objects cannot share identifiers. Duplicated identifiers are not
allowed and an error will be thrown. Since TargetSearch
2.8.0
, different
column names of the libData
slot (see method libData
) are allowed, as long as
the data types are characters, numeric, or logical. More complex type may or not may work.
Use the libUID
method to set or get the library unique identifiers (also referred as libID
).
This is a short string used for internal object data checking. It is sometimes useful if these identifiers
refer to identifiers of external databases, for example, KEGG identifiers.
These identifiers are normally supplied via the libID
column in the function ImportLibrary
.
Note that the method libId
is deprecated and may be removed in a future version of
TargetSearch
. Use the equivalent makeIndex
instead.
This method has nothing to do with unique identifiers like libUID
.
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.
[
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")
: Deprecated. Use makeIndex
instead.
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.
libUID
signature(obj = "tsLib")
: gets the library unique identifiers, also know as libID
.
libUID<-
signature(obj = "tsLib")
: sets the library unique identifiers, also know as libID
.
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.
c
Combine two or more tsLib
objects.
Accessing the object slots directly via the @
operator is not supported,
in particular, using it to set slot values, because it could result in invalid objects.
Always use the accessor methods to retrieve the information.
Alvaro Cuadros-Inostroza, Matthew Hannah, Henning Redestig
ImportLibrary
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 selection 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)
# get and change the library identifiers
(gcID <- libUID(refLibrary))
libUID(refLibrary) <- c('GC_1', 'GC_2', 'GC_3')
#####################################################################
# objects can be subset and combined with the `[` and `c` operators
lib1 <- refLibrary[1:2]
lib2 <- refLibrary[3]
lib <- c(lib1, lib2) # this restores the object refLibrary
#####################################################################
# These examples show how changing a quantitative or selective mass
# could lead to unexpected results.
# show quantMasses
quantMass(refLibrary)
# suppose 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 explicitly, noting that
# the first masses coincides with 96 (the quantMass)
selMass(refLibrary)[[1]] <- c(96, 204, 361)
topMass(refLibrary)[[1]] <- c(96, 204, 361)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.