fit_b_spline | R Documentation |
Wraps bSpline function for use in bias detection and correction algorithm.
fit_b_spline(x, concentration, ...)
concentration |
Metabolite concentration. |
... |
Arguments to be passed into the bSpline() function, such as knots – "The internal breakpoints that define the spline" and degree – "Non-negative integer degree of the piecewise polynomial". If no additional arguments are provided, a reasonable default for is assumed. |
time |
Time or sample number for metabolite time-course. |
A vector of fit concentrations.
# 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 sample time
time <- seq(0, 9, length.out=10) * 24
# Fitting
fit <- fit_b_spline(time, concentration,
knots = c(0.5), degree = 2)
# Plotting
plot(time, concentration, type='p',
xlab='Time post inoculation (hours)', ylab='Concentration (mM)')
lines(time, fit, type='l')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.