The function takes smoothed d0, d1, and d2 vectors and processes the chromatogram by baseline expansion of peaks detected in the second derivative. In short, the algorithm detects all peak apices in the chromatogram as negative minima craddled by inflection points in the second derivative of the chromatogram. Each peak apex detected is then subjected to a baseline expansion algorithm in order to determine the peak boundaries and baseline boundaries of the peaks.

It is not recommended to use this function directly unless you know what you are doing. Instead, use the supplied API functions defined.

process_chromatogram(
  d0,
  d2,
  st,
  apex_thresh = 0,
  w = 5L,
  p = -1L,
  liftoff = 0,
  touchdown = 0.5,
  output = 0L,
  fit_emg = 1L,
  fit_only_vip = 1L,
  fit_hess = 0L,
  fit_rel_lim = 0.05,
  pts_per_peak = 30L,
  min_shoulder_pts = 3L,
  min_rounded_pts = 3L,
  reltol = 1e-08,
  abstol = -1e+35,
  alpha = 1,
  gamma = 2.1,
  rho = 0.75,
  sigma = 0.75,
  maxit = 2000L,
  maxeval = 2000L
)

Arguments

d0

Numeric vector containing the smoothed XIC trace

d2

Numeric vector containing the second derivative of smoothed XIC

st

Numeric vector containing scan times

apex_thresh

Second derivative threshold value.

w

Apex detection window. Do not change unless you know what you are doing.

p

Apex location of a specific peak. Leave blank if you wish to process the entire chromatogram.

liftoff

Slope difference threshold (in percent) for the peak front.

touchdown

Slope difference threshold (in percent) for the peak tail.

output

integer value (0 = no output, 1 = verbose output).

fit_emg

Indicates if EMG deconvolution should be performed (0 = no EMG deconvolution, 1 = EMG deconvolution will be performed)

fit_only_vip

Indicates if EMG deconvolution should be performed on only the selected peak indicated by p (0 = no, 1 = yes)

fit_hess

Deprecated.

fit_rel_lim

Minimum relative peak height of neighboring peaks to the selected peak that will be deconvoluted.

pts_per_peak

Minimum number of points per peak

min_shoulder_pts

Minimum number of points between minima and maxima for at least one of the peaks in a shoulder pair

min_rounded_pts

Minimum number of points between minima and maxima for at least one of the peaks in a rounded peak pair

reltol

Relative tolerance of the Nelder-Mead minimizer for EMG deconvolution

abstol

Absolute tolerance of the Nelder-Mead minimizer for EMG deconvolution

alpha

Reflection coefficient of the Nelder-Mead minimizer for EMG deconvolution

gamma

Expansion coefficient of the Nelder-Mead minimizer for EMG deconvolution

rho

Contraction coefficient of the Nelder-Mead minimizer for EMG deconvolution

sigma

Shrink coefficient of the Nelder-Mead minimizer for EMG deconvolution

maxit

Maximum iterations for the Nelder-Mead minimizer for EMG deconvolution

maxeval

Maximum objective function calls for the Nelder-Mead minimizer for EMG deconvolution

Value

A list of peak characteristics.

Examples

require("signal")
x <- seq(1, 200, 1)
st <- seq_len(length(x))*0.05
vec <- 1e5*dnorm(x, 100, 5) # create a vector with a gaussian peak
noise <- rnorm(length(x), 0, 5) # generate a noise vector
nvec <- vec + noise # create a noisy `chromatogram`.
smvec <- signal::sgolayfilt(nvec, n = 5) # smooth the vector using Savitzky-Golay
ddsmvec <- signal::sgolayfilt(nvec, n = 5, m = 2) # get the second derivative of the smoothed vector
cpc::process_chromatogram(d0 = smvec, d2 = ddsmvec, st = st, apex_thresh = 10)
#> $current_peak
#> [1] -1
#> 
#> $d2_apex
#> [1] 99
#> 
#> $adj_apex
#> [1] 99
#> 
#> $front_inf
#> [1] 93.86427
#> 
#> $tail_inf
#> [1] 104.0671
#> 
#> $front_baseline_bound
#> [1] 70
#> 
#> $tail_baseline_bound
#> [1] 132
#> 
#> $front_peak_bound
#> [1] 77
#> 
#> $tail_peak_bound
#> [1] 119
#> 
#> $front_code
#> [1] 1
#> 
#> $tail_code
#> [1] 1
#> 
#> $area
#> [1] 99971.41
#> 
#> $inf_area
#> [1] 68096.87
#> 
#> $emg_mu
#> [1] 98.46778
#> 
#> $emg_sigma
#> [1] 4.978848
#> 
#> $emg_lambda
#> [1] 1.864577
#> 
#> $emg_area
#> [1] 100144.2
#> 
#> $emg_conv
#> [1] 1
#>