waveclock {waveclock} | R Documentation |
This function can be used to reconstruct the modal frequencies in a time series such as cycling cell luminescence data. First the continuous wavelet transform is calculated using the (complex-valued) Morlet wavelet. Next, the modal frequencies are identified from the time-frequency decomposition using the "crazy climbers" algorithm from package Rwave.
waveclock( x, period = c( 6, 48 ), time.limits = NULL, extend = "reflect", noctave = NULL, nvoice = 96, mask.coi = TRUE, crc.args = list( seed = 0, nbclimb = 50 ), cfamily.args = list( ptile = 0.005, bstep = 5, nbchain = 400 ), crcrec.args = list( compr = 3, epsilon = 0, para = 3, plot = FALSE ), xlab = "Time (h)", ylab = "Period (h)", png = NULL, color.palette = heat.colors, mode.col = "green", mode.lty = "solid", mode.lwd = 2, ... )
x |
Numeric or complex vector or time series. Input signal (possibly complex-valued). |
period |
Numeric vector. Range defining lower and upper period limits. The default values may be useful for detecting circadian rhythmicity in data with time units measured in hours |
time.limits |
Numeric vector. Time range for truncation of series |
extend |
NULL or character string. Ameliorate edge effects by reflecting data series at time limits or repeating the time series. Must be NULL or an abbreviation of "reflect" or "repeat". |
mask.coi |
Logical. Is the "cone of influence" masked from the output? |
noctave |
Numeric. Number of powers of 2 for the scale variable in the wavelet decomposition. Defaults to the maximum number possible |
nvoice |
Numeric. Number of scales in each octave (i.e., between two consecutive powers of 2) |
crc.args |
List. Arguments provided to "crazy climbers" function crc
|
cfamily.args |
List. Arguments provided to chaining function cfamily
|
crcrec.args |
List. Arguments provided to modal frequency reconstruction function crcrec
|
xlab |
Character string. x axis label for plot of continuous wavelet transform scalogram |
ylab |
Character string. y axis label for plot of continuous wavelet transform scalogram |
png |
NULL (default) or character string. Name of png filename for plot output. The default value plots to the default device |
color.palette |
Color palette function used in scalogram plot |
mode.col |
Color of line marking modal frequency |
mode.lty |
Type of line marking modal frequency |
mode.lwd |
Width of line marking modal frequency |
... |
Additional parameters passed to filled.contour plot function
|
T.S.Price
"Practical Time-Frequency Analysis: Gabor and Wavelet Transforms with an Implementation in S", by Rene Carmona, Wen L. Hwang and Bruno Torresani, Academic Press, 1998. http://sgdp.iop.kcl.ac.uk/tprice/software.html
See cwt
for the continuous wavelet transform,
crc
and cfamily
for the estimation of modal
frequencies from the continuous wavelet transform,
crcrec
for the reconstruction of the modal frequencies, and
waveclock.auto
to run waveclock
in another
instance of R.
set.seed( 1 ) freq <- 6 # data point every 10 minutes T <- 24 * 5 * freq t <- ( 0:T ) / freq # models an initial 'spike' and slow background trend spike <- 0.5 * dgamma( t / 24, 2, 10 ) trend <- rowSums( poly( t, 2 ) %*% rnorm( 2 ) ) background <- spike + trend # exponentially damped circadian signal with random phase amplitude <- sqrt( 2 ) * exp( -t / ( 24 * 2 ) ) period <- 24 phase <- runif( 1 ) * 2 * pi signal <- amplitude * sin( t / period * 2 * pi + phase ) # Gaussian noise noise <- 0.15 * rnorm( T + 1 ) # simulated luminescence trace luminescence.trace <- ts( signal + background + noise, start = 0, freq = freq ) plot( luminescence.trace ) # wavelet analysis result <- waveclock( luminescence.trace ) result$modes reconstructed.trace <- ts( rowSums( result$rec, na.rm = TRUE ), start = 0, freq = freq ) # plot reconstructed wave # code not run ##plot( luminescence.trace ) ##lines( reconstructed.trace, col = 2 ) ##abline( h = 0, lty = 2, col = 2 )