correct_rel_bias | R Documentation |
Identifies systematic deviations in metabolic data using a spline fit. Timepoints that have a median relative deviation above a min.deviation value are assumed to be influenced by a measurement or methodological bias as compared to the overall trends metabolite concentrations.
correct_rel_bias(
time,
concentration,
compound,
min.deviation = NULL,
degree = 3,
knots = c(0.5)
)
time |
A vector of times or sample numbers for metabolite time-courses.
Note, there should be a time value for every |
concentration |
A vector of metabolite concentrations. |
compound |
A vector of metabolite names that correspond to |
min.deviation |
Smallest median relative deviation to identify as a bias. |
degree |
degree of the B-spline |
knots |
position of the knots of the B-spline as a fraction. e.g. knots <- c(0.25, 0.5, 0.75) |
A dataframe with the fit.
# Using previously simulated data 40 metabolic trends with 10 time points
data(timecourse)
# Adding an error of 5% at sample 4
logic <- timecourse$sample == 4
timecourse$concentration[logic] <- timecourse$concentration[logic] * 1.05
# Correcting
output <- correct_rel_bias(timecourse$time,
timecourse$concentration,
timecourse$metabolite,
degree = 2)
timecourse$corrected <- output$fit
# Plotting -- the original value of the corrected point is marked in red
par(mfrow = c(8, 5), oma = c(5, 4, 1, 1) + 0.1, mar = c(1, 1, 1, 1) + 0.1)
for (metabolite in unique(timecourse$metabolite)) {
logic <- timecourse$metabolite == metabolite
d <- timecourse[logic, ]
logic2 <- d$concentration != d$corrected
plot(d$time, d$corrected, pch = 16, xlab = '', ylab = '',
ylim = c(min(d$concentration), max(d$concentration)))
points(d$time[logic2], d$concentration[logic2], pch = 16, col = 'red')
}
title(xlab = 'Time post inoculation (hours)',
ylab = 'Concentration (mM)', outer = TRUE, line = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.