Title: | Tau-Independent Phase Analysis for Circadian Time-Course Data |
---|---|
Description: | Accurately estimates phase shifts by accounting for period changes and for the point in the circadian cycle at which the stimulus occurs. See Tackenberg et al. (2018) <doi:10.1177/0748730418768116>. |
Authors: | Jake Hughey [aut, cre] |
Maintainer: | Jake Hughey <[email protected]> |
License: | GPL-2 |
Version: | 1.0.8 |
Built: | 2025-02-09 05:00:04 UTC |
Source: | https://github.com/hugheylab/tipa |
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()
.
tipaCosinor( time, y, stimOnset, stimDuration = 0, periodGuess = 24, trend = TRUE, shortcut = TRUE )
tipaCosinor( time, y, stimOnset, stimDuration = 0, periodGuess = 24, trend = TRUE, shortcut = TRUE )
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. |
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 |
# 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)
# 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)
Calculate the phase shift based on the times of a phase reference point
(e.g., onset of activity), accounting for possible period changes and for the
point in the circadian cycle at which the stimulus occurred. If the rhythms
of the measurement are approximately sinusoidal, it is recommended to instead
use tipaCosinor()
.
tipaPhaseRef(phaseRefTimes, stimOnset, stimDuration = 0, period = NULL)
tipaPhaseRef(phaseRefTimes, stimOnset, stimDuration = 0, period = NULL)
phaseRefTimes |
Vector of times of the chosen phase reference point. |
stimOnset |
Time at which the stimulus started. |
stimDuration |
Duration of the stimulus and any transients. Data between
|
period |
Optional list with elements "pre" and "post" corresponding to the period of the oscillations prior to and subsequent to the stimulus. If not supplied, the periods for pre- and post-stimulus are calculated as the mean time between occurrences of the phase reference point within the respective epoch. Using this argument is not recommended. |
A list.
phaseShift |
Estimated phase shift in circadian hours. Negative values indicate a delay, positive values an advance. |
epochInfo |
|
# Peak times of bioluminescence (in hours) phaseRefTimes = c(-75.5, -51.5, -27.4, -3.8, 20.5, 42.4, 65.5, 88.0) result = tipaPhaseRef(phaseRefTimes, stimOnset = 0) # Data from multiple (simulated) experiments getExtrFile = function() { system.file('extdata', 'phaseRefTimes.csv', package = 'tipa')} getStimFile = function() { system.file('extdata', 'stimOnsets.csv', package = 'tipa')} extrDf = read.csv(getExtrFile(), stringsAsFactors = FALSE) stimDf = read.csv(getStimFile(), stringsAsFactors = FALSE) resultList = lapply(stimDf$expId, function(ii) { phaseRefTimes = extrDf$phaseRefTime[extrDf$expId == ii] stimOnset = stimDf$stimOnset[stimDf$expId == ii] tipaPhaseRef(phaseRefTimes, stimOnset)}) phaseShifts = sapply(resultList, function(r) r$phaseShift)
# Peak times of bioluminescence (in hours) phaseRefTimes = c(-75.5, -51.5, -27.4, -3.8, 20.5, 42.4, 65.5, 88.0) result = tipaPhaseRef(phaseRefTimes, stimOnset = 0) # Data from multiple (simulated) experiments getExtrFile = function() { system.file('extdata', 'phaseRefTimes.csv', package = 'tipa')} getStimFile = function() { system.file('extdata', 'stimOnsets.csv', package = 'tipa')} extrDf = read.csv(getExtrFile(), stringsAsFactors = FALSE) stimDf = read.csv(getStimFile(), stringsAsFactors = FALSE) resultList = lapply(stimDf$expId, function(ii) { phaseRefTimes = extrDf$phaseRefTime[extrDf$expId == ii] stimOnset = stimDf$stimOnset[stimDf$expId == ii] tipaPhaseRef(phaseRefTimes, stimOnset)}) phaseShifts = sapply(resultList, function(r) r$phaseShift)