Title: | Alignment of LC-MS Profiles by Neighbor-wise Compound-specific Graphical Time Warping with Misalignment Detection |
---|---|
Description: | The purpose of ncGTW is to help XCMS for LC-MS data alignment. Currently, ncGTW can detect the misaligned feature groups by XCMS, and the user can choose to realign these feature groups by ncGTW or not. |
Authors: | Chiung-Ting Wu <[email protected]> |
Maintainer: | Chiung-Ting Wu <[email protected]> |
License: | GPL-2 |
Version: | 1.21.0 |
Built: | 2024-10-31 03:37:59 UTC |
Source: | https://github.com/bioc/ncGTW |
The purpose of ncGTW is to help XCMS for LC-MS data alignment. Currently, ncGTW can detect the misaligned feature groups by XCMS, and the user can choose to realign these feature groups by ncGTW or not.
Wu, Chiung-Ting, et al. Alignment of LC-MS Profiles by Neighbor-wise Compound-specific Graphical Time Warping with Misalignment Detection. bioRxiv, 2019, 715334.
This function produces the new warping functions (RT lists) with the realignment result.
adjustRT(xcmsLargeWin, ncGTWinput, ncGTWoutput, ppm)
adjustRT(xcmsLargeWin, ncGTWinput, ncGTWoutput, ppm)
xcmsLargeWin |
A |
ncGTWinput |
A |
ncGTWoutput |
A |
ppm |
Should be set as same as the one when performing the peak
detection function in |
This function produces the new warping functions (RT lists) with the realignment result.
A ncGTWwarp
object.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- new("ncGTWparam") # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) # adjust RT with the realignment results from ncGTW ncGTWres <- xcmsLargeWin ncGTWRt <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)){ adjustRes <- adjustRT(ncGTWres, ncGTWinputs[[n]], ncGTWoutputs[[n]], ppm) xcms::peaks(ncGTWres) <- ncGTWpeaks(adjustRes) ncGTWRt[[n]] <- rtncGTW(adjustRes) } # apply the adjusted RT to a xcmsSet object xcms::groups(ncGTWres) <- excluGroups[ , 2:9] xcms::groupidx(ncGTWres) <- xcms::groupidx(xcmsLargeWin)[excluGroups[ , 1]] rtCor <- vector('list', length(xcms::filepaths(ncGTWres))) for (n in seq_along(file)){ rtCor[[n]] <- vector('list', dim(excluGroups)[1]) for (m in seq_len(dim(excluGroups)[1])) rtCor[[n]][[m]] <- ncGTWRt[[m]][[n]] } slot(ncGTWres, 'rt')$corrected <- rtCor ## End(Not run)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- new("ncGTWparam") # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) # adjust RT with the realignment results from ncGTW ncGTWres <- xcmsLargeWin ncGTWRt <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)){ adjustRes <- adjustRT(ncGTWres, ncGTWinputs[[n]], ncGTWoutputs[[n]], ppm) xcms::peaks(ncGTWres) <- ncGTWpeaks(adjustRes) ncGTWRt[[n]] <- rtncGTW(adjustRes) } # apply the adjusted RT to a xcmsSet object xcms::groups(ncGTWres) <- excluGroups[ , 2:9] xcms::groupidx(ncGTWres) <- xcms::groupidx(xcmsLargeWin)[excluGroups[ , 1]] rtCor <- vector('list', length(xcms::filepaths(ncGTWres))) for (n in seq_along(file)){ rtCor[[n]] <- vector('list', dim(excluGroups)[1]) for (m in seq_len(dim(excluGroups)[1])) rtCor[[n]][[m]] <- ncGTWRt[[m]][[n]] } slot(ncGTWres, 'rt')$corrected <- rtCor ## End(Not run)
Accessors to the alignment information and result by ncGTW.
## S4 method for signature 'ncGTWoutput' alignData(object)
## S4 method for signature 'ncGTWoutput' alignData(object)
object |
a |
alignData
returns a matrix in which each row is a sample
profile after downsampling.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- initncGTWparam() # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) data <- alignData(ncGTWoutputs[[1]]) rt <- scanRange(ncGTWoutputs[[1]]) paths <- ncGTWpath(ncGTWoutputs[[1]]) downSam <- downSample(ncGTWoutputs[[1]]) ## End(Not run)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- initncGTWparam() # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) data <- alignData(ncGTWoutputs[[1]]) rt <- scanRange(ncGTWoutputs[[1]]) paths <- ncGTWpath(ncGTWoutputs[[1]]) downSam <- downSample(ncGTWoutputs[[1]]) ## End(Not run)
This function calculates the coefficient of variation of each feature.
compCV(XCMSresFilled, na.rm = FALSE)
compCV(XCMSresFilled, na.rm = FALSE)
XCMSresFilled |
A |
na.rm |
Omit the samples in which the feature is not detected, and the default is FALSE. |
This function calculates the coefficient of variation of each feature across all the samples. If a sample is detected with more than one peaks in the feature, the function will pick the one with the highest intensity value.
A vector of the same length as the row number of the group
slot in XCMSresFilled
, in which each element is the CV.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin cv <- compCV(xcmsLargeWin)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin cv <- compCV(xcmsLargeWin)
This function is edited from fillPeaksChromPar
in
fillPeaks.chrom-methods
to accept feature-wise warping
functions.
fillPeaksChromPar(arg)
fillPeaksChromPar(arg)
arg |
A list sent from |
This function is for parallelly filling missing peaks with
feature-wise warping functions. The original function in
fillPeaks.chrom-methods
can only handle sample-wise
warping functions.
A list of sameple index vector and filled peak matrix.
This function is edited from getPeaks-methods
to accept
feature-wise warping functions.
getPeaksncGTW(object, peakrange, step = 0.1, naidx)
getPeaksncGTW(object, peakrange, step = 0.1, naidx)
object |
An |
peakrange |
|
step |
|
naidx |
A vector contains the sample indexes need to be filled. |
This function is for parallelly filling missing peaks with
feature-wise warping functions. The original code function in
getPeaks-methods
can only handle sample-wise warping
functions.
A list of sameple index vector and filled peak matrix.
Accessors to the feature and profiles loaded by loadProfile
.
## S4 method for signature 'ncGTWinput' groupInfo(object) ## S4 method for signature 'ncGTWinput' profiles(object) ## S4 method for signature 'ncGTWinput' rtRaw(object) ## S4 method for signature 'ncGTWoutput' scanRange(object) ## S4 method for signature 'ncGTWoutput' ncGTWpath(object) ## S4 method for signature 'ncGTWoutput' downSample(object)
## S4 method for signature 'ncGTWinput' groupInfo(object) ## S4 method for signature 'ncGTWinput' profiles(object) ## S4 method for signature 'ncGTWinput' rtRaw(object) ## S4 method for signature 'ncGTWoutput' scanRange(object) ## S4 method for signature 'ncGTWoutput' ncGTWpath(object) ## S4 method for signature 'ncGTWoutput' downSample(object)
object |
a |
groupInfo
returns a vector of the information of the loaded
feature.
profiles
returns a raw data matrix in which each row is a
sample profile.
rtRaw
returns a raw RT matrix in which each row is the
corresponding sample RT.
scanRange
returns a downsampled RT matrix in which each row is
the corresponding sample RT in data
.
ncGTWpath
returns a list of the same length as the sample
number, in which each element is a matrix of the alignment result of the
corresponding sample.
downSample
returns the factor of downsampling when perform
ncGTW alignment.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) gInfo <- groupInfo(ncGTWinputs[[1]]) prof <- profiles(ncGTWinputs[[1]]) rtR <- rtRaw(ncGTWinputs[[1]]) ## End(Not run)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) gInfo <- groupInfo(ncGTWinputs[[1]]) prof <- profiles(ncGTWinputs[[1]]) rtR <- rtRaw(ncGTWinputs[[1]]) ## End(Not run)
This function loads each raw sample profiles from the file with certain m/z and RT range.
loadProfile(filePaths, excluGroups, mzAdd = 0.005, rtAdd = 10, profstep = 0, BPPARAM = BiocParallel::SnowParam(workers = 1))
loadProfile(filePaths, excluGroups, mzAdd = 0.005, rtAdd = 10, profstep = 0, BPPARAM = BiocParallel::SnowParam(workers = 1))
filePaths |
The character vector of the loading file paths. |
excluGroups |
The output matrix of |
mzAdd |
The extra m/z range for loading (both sides), and the default is 0.005. |
rtAdd |
The extra RT range for loading (both sides), and the default is 10 (seconds). |
profstep |
The size of each m/z bin for peak integration, and the default is 0. |
BPPARAM |
A object of BiocParallel to control parallel processing,
and can be created by
|
This function obtains the extracted ion chromatogram for each sample
at the givin m/z and RT range with a certain m/z bin size for integration.
Considering there may be missing peak by peak detection, mzAdd
and
rtAdd
are to increase the integration range.
A list of the same length as the row number of excluGroups
, in
which each element is a ncGTWinput
object.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups)
This function computes average pairwise correlation and overlapping area of each sample pair.
meanCorOl(ncGTWinput, sampleRt)
meanCorOl(ncGTWinput, sampleRt)
ncGTWinput |
A list in which each element is a |
sampleRt |
A list of the same length as the sample number in which each element is a vector corresponding to the sample raw/adjusted RT. |
This function computes the pairwise correlation and overlapping area of each sample pair from the input feature, and then takes average.
A list in which the first element is average pairwise correlation, and the second one is average overlapping area.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) XCMSCor <- matrix(0, length(ncGTWinputs), 1) XCMSOl <- matrix(0, length(ncGTWinputs), 1) for (n in seq_along(ncGTWinputs)){ XCMSmean <- meanCorOl(ncGTWinputs[[n]], slot(xcmsLargeWin, 'rt')$corrected) XCMSCor[n] <- XCMSmean$cor XCMSOl[n] <- XCMSmean$ol }
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) XCMSCor <- matrix(0, length(ncGTWinputs), 1) XCMSOl <- matrix(0, length(ncGTWinputs), 1) for (n in seq_along(ncGTWinputs)){ XCMSmean <- meanCorOl(ncGTWinputs[[n]], slot(xcmsLargeWin, 'rt')$corrected) XCMSCor[n] <- XCMSmean$cor XCMSOl[n] <- XCMSmean$ol }
This function detects the misaligned peak groups with two
xcmsSet-class
object with two different values of
bw
parameter in group
.
misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm, qThre = 0.05, overlapRate = 0, maxRtWin = 50)
misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm, qThre = 0.05, overlapRate = 0, maxRtWin = 50)
xcmsLargeWin |
A |
xcmsSmallWin |
A |
ppm |
Should be set as same as the one when performing the peak
detection function in |
qThre |
The threshould of the p-value after multiple test correction. The default is 0.05. |
overlapRate |
The threshould of the overlapping rate of sample index. The default is 0. |
maxRtWin |
The threshould of the maximum retension time range. This is for filtering out some bad groups. The default is 50 (seconds). |
This function includes two major steps to determine a peak group is
misaligned or not. The first step calculates the p-value of each peak group
in xcmsSmallWin, and find the corresponding peak group in xcmsLargeWin. The
second step is to find the exclusive peak groups (the groups with no
overlapping samples) with adjsted p-values smaller than qThre
.
A matrix with all detected misaligned peak groups. The column names
are the same as group
slot in xcmsSet-class
, but
the first column is the group index.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm)
This function applies ncGTW alignment to the input feature.
ncGTWalign(ncGTWinput, xcmsLargeWin, parSamp = 10, k1Num = 3, k2Num = 1, bpParam = BiocParallel::SnowParam(workers = 1), ncGTWparam = NULL)
ncGTWalign(ncGTWinput, xcmsLargeWin, parSamp = 10, k1Num = 3, k2Num = 1, bpParam = BiocParallel::SnowParam(workers = 1), ncGTWparam = NULL)
ncGTWinput |
A |
xcmsLargeWin |
A |
parSamp |
Decide how many samples are in each group when considering parallel computing, and the default is 10. |
k1Num |
Decide how many different k1 will be tested in stage 1. The default is 3. |
k2Num |
Decide how many different k2 will be tested in stage 2. The default is 1. |
bpParam |
A object of BiocParallel to control parallel processing,
and can be created by
|
ncGTWparam |
A |
This function realign the input feature with ncGTW alignment function with given m/z and RT range.
A ncGTWoutput
object.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- new("ncGTWparam") # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) ## End(Not run)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- new("ncGTWparam") # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) for (n in seq_along(ncGTWinputs)) ncGTWoutputs[[n]] <- ncGTWalign(ncGTWinputs[[n]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) ## End(Not run)
An S4 class for storing the inputs of ncGTW alignment.
groupInfo
A vector of the information of the feature.
profiles
A raw data matrix in which each row is a sample profile.
rtRaw
A raw RT matrix in which each row is the corresponding
sample RT in profiles
.
An S4 class for storing the outputs of ncGTW alignment.
alignData
A matrix in which each row is a sample profile after downsampling.
scanRange
A downsampled RT matrix in which each row is the
corresponding sample RT in alignData
.
path
A list of the same length as the sample number, in which each element is a matrix of the alignment result of the corresponding sample.
downSample
The factor of downsampling when perform ncGTW alignment.
An S4 class for storing the needed paramters of ncGTW alignment.
This function initializes the needed paramters of ncGTW alignment
with defaults, so this function could be called without any input. The
alignment should be fine with all default parameters. If the computing time
is an issue, the user could consider increase downSample
and/or
decrease stpRat
for a faster speed. If the alignment result is not
good enough, one can consider increase strNum
and/or diaNum
to integrate more neighboring information to increase the quality of
alignment, but the speed may drop.
downSample
A factor of downsampling. The larger, the faster speed of alignment, but the accuracy may decrease. The default is 2.
stpRat
A factor to control the maximum RT shift of a point in
alignment, and the maximum shift is determined by stpRat
* "The RT
range of the feature". If maxStp
is set, then stpRat
would be
neglected. The default is 0.6.
maxStp
A value determines the maximum RT shift of a point in ncGTW alignment. If the user wants to decide the maximum shif by the RT range of the feature, this argument should be NaN. The default is NaN.
strNum
A value controls how many neighboring warping functions are
connected to each warping function in ncGTW graph. There are two samples
corresponding to a warping function, and at least one sample should be the
same in another warping function to be considered as a neighbor controlled
by strNum
.
diaNum
A value controls how many neighboring warping functions are
connected to each warping function in ncGTW graph. There are two samples
corresponding to a warping function, and the two samples could also be
different to another warping function to be considered as a neighbor
controlled by diaNum
.
nor
A value controls p-norm to compute the distance between the points on the profiles, and the default is 1 (Manhattan norm).
An S4 class for storing the realigned RT and the peaks with adjusted RT of ncGTW alignment.
rtncGTW
A list of the same length as the sample number, in which each element is a vector of the realigned RT of the corresponding sample.
ncGTWpeaks
A matrix containing peak data with adjusted RT.
This function plots sample profiles with loaded information.
plotGroup(ncGTWinput, sampleRt, sampleInd = seq_len(dim(ncGTWinput@rtRaw)[1]), ind = NULL, savePath = NULL, show = TRUE, sub = TRUE, filter = FALSE)
plotGroup(ncGTWinput, sampleRt, sampleInd = seq_len(dim(ncGTWinput@rtRaw)[1]), ind = NULL, savePath = NULL, show = TRUE, sub = TRUE, filter = FALSE)
ncGTWinput |
An object return by |
sampleRt |
A list of the same length as the sample number in which each element is a vector corresponding to the sample raw/adjusted RT for plotting. |
sampleInd |
Indicate which samples should be plotted, and the default is
|
ind |
A user defined index, and the default is |
savePath |
The path to save the plots, and the default is |
show |
Show the plot in R or not, and the default is |
sub |
Show more information on the plot or not, and the default is
|
filter |
Apply a Gaussian filter for demonstration or not, and the
default is |
This function plots the extracted ion chromatogram obtained by
loadProfile
. The user can decide to save the figure, show the
figure, or apply a Gaussian filter on the data by parameter setting.
A plot to the current device.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # plot all loaded features for (n in seq_along(ncGTWinputs)) plotGroup(ncGTWinputs[[n]], slot(xcmsLargeWin, 'rt')$corrected)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # plot all loaded features for (n in seq_along(ncGTWinputs)) plotGroup(ncGTWinputs[[n]], slot(xcmsLargeWin, 'rt')$corrected)
Accessors to the realigned RT and the peaks with adjusted RT of ncGTW alignment.
## S4 method for signature 'ncGTWwarp' rtncGTW(object) ## S4 method for signature 'ncGTWwarp' ncGTWpeaks(object)
## S4 method for signature 'ncGTWwarp' rtncGTW(object) ## S4 method for signature 'ncGTWwarp' ncGTWpeaks(object)
object |
a |
rtncGTW
returns a list of the same length as the sample
number, in which each element is a vector of the realigned RT of the
corresponding sample.
rtncGTW
returns a matrix containing peak data with adjusted
RT.
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- initncGTWparam() # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) ncGTWoutputs[[1]] <- ncGTWalign(ncGTWinputs[[1]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) # adjust RT with the realignment results from ncGTW ncGTWres <- xcmsLargeWin adjustRes <- adjustRT(ncGTWres, ncGTWinputs[[1]], ncGTWoutputs[[1]], ppm) rt <- rtncGTW(adjustRes) peaks <- ncGTWpeaks(adjustRes) ## End(Not run)
# obtain data data('xcmsExamples') xcmsLargeWin <- xcmsExamples$xcmsLargeWin xcmsSmallWin <- xcmsExamples$xcmsSmallWin ppm <- xcmsExamples$ppm # detect misaligned features excluGroups <- misalignDetect(xcmsLargeWin, xcmsSmallWin, ppm) # obtain the paths of the sample files filepath <- system.file("extdata", package = "ncGTW") file <- list.files(filepath, pattern="mzxml", full.names=TRUE) tempInd <- matrix(0, length(file), 1) for (n in seq_along(file)){ tempCha <- file[n] tempLen <- nchar(tempCha) tempInd[n] <- as.numeric(substr(tempCha, regexpr("example", tempCha) + 7, tempLen - 6)) } # sort the paths by data acquisition order file <- file[sort.int(tempInd, index.return = TRUE)$ix] ## Not run: # load the sample profiles ncGTWinputs <- loadProfile(file, excluGroups) # initialize the parameters of ncGTW alignment with default ncGTWparam <- initncGTWparam() # run ncGTW alignment ncGTWoutputs <- vector('list', length(ncGTWinputs)) ncGTWoutputs[[1]] <- ncGTWalign(ncGTWinputs[[1]], xcmsLargeWin, 5, ncGTWparam = ncGTWparam) # adjust RT with the realignment results from ncGTW ncGTWres <- xcmsLargeWin adjustRes <- adjustRT(ncGTWres, ncGTWinputs[[1]], ncGTWoutputs[[1]], ppm) rt <- rtncGTW(adjustRes) peaks <- ncGTWpeaks(adjustRes) ## End(Not run)
These two xcmsSet-class
objects are created from the
example dataset attached in this package (in extdata folder) with XCMS
package. They are examples for inputs of misalignDetect
.
data(xcmsExamples)
data(xcmsExamples)
A list with two xcmsSet-class
objects and one
ppm
parameter.
The example dataset contains 20 samples picked from an in-house LC-MS
dataset. The user can replicate the two xcmsSet-class
objects with xcmsSet
, retcor-methods
,
and group-methods
. For details, please refer to the user
manual.