Description Usage Arguments Value Examples
Wraps GAM smoothing function for use in bias correction algorithm.
1 | met_smooth_gam(time, concentration, new.time = NULL, warn = FALSE, ...)
|
time |
Time or sample number for metabolite time-course. |
concentration |
Metabolite concentration. |
new.time |
Optional vector for new independent variables. |
warn |
The |
... |
Arguments to be passed into the s() smoothing function, such as k – the dimension of the basis used to represent the smooth term. If no additional arguments are provided, a reasonable default for k (5) is assumed. |
A vector of smoothed concentrations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Simulating concave curve with 10 points
par <- c(3.5, 4.5, 2.5, 3.5, 0.0, 0.2, 0.8, 0.9)
concentration <- as.numeric(simulate_concave(1, 10, par))
# Adding noise and changing scale
concentration <- concentration * 18 + 2
abs.sd <- mean(concentration) * 0.1
concentration <- concentration + rnorm(10, 0, abs.sd)
concentration[concentration < 0] <- 0
# Original sampling time
time <- seq(0, 9, length.out=10) * 24
# New time for smoothing
new.time <- seq(0, 9, length.out=100) * 24
# Smoothing
corrected <- met_smooth_gam(time, concentration, new.time = new.time, k = 5)
# Plotting
plot(time, concentration, type='p',
xlab='Time post inoculation (hours)', ylab='Concentration (mM)')
lines(new.time, corrected, type='l')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.