adjustRT {ncGTW} | R Documentation

## Adjust retention time

### Description

This function produces the new warping functions (RT lists) with the realignment result.

### Usage

    adjustRT(xcmsLargeWin, ncGTWinput, ncGTWoutput, ppm)

### Arguments

`xcmsLargeWin` | A `xcmsSet-class` object.
`ncGTWinput` | A `ncGTWinput` object.
`ncGTWoutput` | A `ncGTWoutput` object.
`ppm` | Should be set as same as the one when performing the peak detection function in `xcms`.

### Details

This function produces the new warping functions (RT lists) with the realignment result.

### Value

A `ncGTWwarp` object.

### Examples

    # 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)

[Package ncGTW version 1.6.0 Index]