tipaCosinor {tipa} | R Documentation |
Use cosinor regression to estimate the phase shift induced by a stimulus during a circadian time-course.
Description
Calculate the phase shift based on fitting sine curves to waveform data
before and after the stimulus, accounting for possible period changes and for
the point in the circadian cycle at which the stimulus occurred. This
function will work best for measurements whose rhythms are approximately
sinusoidal, or at least smoothly increasing and decreasing. If your data are
not sinusoidal, you can first define the phase reference points and then use
tipaPhaseRef()
.
Usage
tipaCosinor(
time,
y,
stimOnset,
stimDuration = 0,
periodGuess = 24,
trend = TRUE,
shortcut = TRUE
)
Arguments
time |
Vector of time values for the full time-course. |
y |
Vector of measurements (e.g., bioluminescence) for the full time-course. |
stimOnset |
Time at which the stimulus started. |
stimDuration |
Duration of the stimulus and any transients. Data between
|
periodGuess |
Approximate period of the oscillations (in the same units
used in |
trend |
Model a long-term trend in the cosinor fit for each epoch. Uses
a natural cubic spline with 4 degrees of freedom. It is strongly
recommended to keep as |
shortcut |
Calculate phase shift using the standard TIPA procedure or using a shortcut based on the phases of the sine curve fits. The two methods give exactly the same result. |
Value
A list.
phaseShift |
Estimated phase shift in circadian hours. Negative values correspond to a delay, positive values an advance. |
epochInfo |
Dataframe containing information about the sine curve fits
for each epoch: period (in the same units used in |
See Also
Examples
# Time-course data from multiple (simulated) experiments
getTimecourseFile = function() {
system.file('extdata', 'timecourses.csv', package = 'tipa')}
df = read.csv(getTimecourseFile(), stringsAsFactors = FALSE)
resultList = lapply(sort(unique(df$expId)), function(ii) {
time = df$time[df$expId == ii]
y = df$intensity[df$expId == ii]
tipaCosinor(time, y, stimOnset = 0)})
phaseShifts = sapply(resultList, function(r) r$phaseShift)