fit_loess: Fit RT Projection Model With LOESS

Description Usage Arguments Value See Also Examples

View source: R/fit_model.R

Description

Fits a local regression smoothing spline through a set of ordered pair retention times. modeling one set of retention times (rty) as a function on the other set (rtx). Filtering iterations of high residual points are performed first. Multiple acceptable values of span can be used, with one value selected through 10-fold cross validation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fit_loess(
  object,
  useID = FALSE,
  spans = seq(0.2, 0.3, by = 0.02),
  iterFilter = 2,
  ratio = 2,
  frac = 0.5,
  iterLoess = 10,
  weights = 1
)

Arguments

object

metabCombiner object.

useID

logical. Option to use matched IDs to inform fit

spans

numeric span values (between 0 & 1) used for loess fits

iterFilter

integer number of residual filtering iterations to perform

ratio

numeric. A point is an outlier if the ratio of residual to mean residual of a fit exceeds this value. Must be greater than 1.

frac

numeric. A point is excluded if deemed a residual in more than this fraction value times the number of fits. Must be between 0 & 1.

iterLoess

integer. Number of robustness iterations to perform in loess().See ?loess.control for more details.

weights

Optional user supplied weights for each ordered pair. Must be of length equal to number of anchors (n) or a divisor of (n + 2).

Value

metabCombiner object with model slot updated to contain the fitted loess model

See Also

selectAnchors,fit_gam

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data(plasma30)
data(plasma20)

p30 <- metabData(plasma30, samples = "CHEAR")
p20 <- metabData(plasma20, samples = "Red", rtmax = 17.25)
p.comb = metabCombiner(xdata = p30, ydata = p20, binGap = 0.0075)
p.comb = selectAnchors(p.comb, tolmz = 0.003, tolQ = 0.3, windy = 0.02)

#version 1
p.comb = fit_loess(p.comb, spans = seq(0.2,0.3,0.02), iterFilter = 1)

#version 2 (using weights)
anchors = getAnchors(p.comb)
weights = c(2, rep(1, nrow(anchors)), 2)  #weight = 2 to boundary points
p.comb = fit_loess(p.comb, spans = seq(0.2,0.3,0.02), weights = weights)

#version 3 (using identities)
p.comb = selectAnchors(p.comb, useID = TRUE, tolmz = 0.003)
p.comb = fit_loess(p.comb, spans = seq(0.2,0.3,0.02), useID = TRUE)

#to preview result of fit_loess
plot(p.comb, fit = "loess", xlab = "CHEAR Plasma (30 min)",
     ylab = "Red-Cross Plasma (20 min)", pch = 19,
     main = "Example fit_loess Result Fit")

metabCombiner documentation built on Dec. 10, 2020, 2 a.m.