Decompose a periodic time variable into multiple components based on either the first harmonic of a Fourier series or on a periodic smoothing spline.
limorhyde( time, colnamePrefix = NULL, period = 24, sinusoid = TRUE, nKnots = 3, intercept = FALSE )
Numeric vector of times, e.g., at which samples were acquired.
Character string with which to prefix the column names of the basis.
Number corresponding to the period to use for the
decomposition (in the same units as
Number of internal knots for the periodic spline. Only used if
A matrix with a row for each sample and a column for each component of the time decomposition.
# create an example data frame nSamples = 12 d = data.frame( sample = paste0('sample_', 1:nSamples), genotype = factor(rep(c('WT', 'KO'), each = nSamples / 2), levels = c('WT', 'KO')), zt = rep(seq(0, 24 - 24 / nSamples * 2, 24 / nSamples * 2), times = 2), stringsAsFactors = FALSE) # call limorhyde limo = limorhyde(d$zt, 'zt_') d = cbind(d, limo) # create a design matrix that could be used with methods such as limma design = model.matrix(~ genotype * (zt_cos + zt_sin), data = d)