Description Usage Arguments Value Author(s) Examples
This function provides a statistical test of rhythmicity for temporal accumulations of mRNA, proteins and other biological signals.
1 | f24_R2_cycling(x, t = 2 * (0:(length(x) - 1)), period = 24, offset = 0)
|
x |
numerical data of temporal accumulation |
t |
time points |
period |
period of rhythmicity |
offset |
offset ususally is 0 |
nb.timepoints |
number of time points |
mean |
average |
amp |
amplitude |
relamp |
relative amplitude |
phase |
phase |
pval |
P values |
Jingkui Wang and Felix Naef
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | ## t = c(0:48)
## x = 10 + cos(2*pi/24*(t-12))
## f24_R2_cycling(x,t)
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, t = 2 * (0:(length(x) - 1)), period = 24, offset = 0)
{
kk = which(!is.na(x) == TRUE)
x = x[kk]
t = t[kk]
n = length(x)
nb.timepoints = length(x)
if (n < 4) {
if (n == 0)
c(nb.timepoints = nb.timepoints, mean = NA, amp = NA,
relamp = NA, phase = NA, pval = NA)
else {
c(nb.timepoints = nb.timepoints, mean = mean(x),
amp = NA, relamp = NA, phase = NA, pval = NA)
}
}
else {
sig2 = var(x)
c = cos(2 * pi * t/period)
s = sin(2 * pi * t/period)
A = mean(x * c) - mean(x) * mean(c)
B = mean(x * s) - mean(x) * mean(s)
c1 = mean(c^2) - mean(c)^2
c2 = mean(c * s) - mean(c) * mean(s)
c3 = mean(s^2) - mean(s)^2
b = (A * c2 - B * c1)/(c2^2 - c1 * c3)
a = (A - b * c2)/c1
mu = mean(x) - a * mean(c) - b * mean(s)
x.hat = mu + a * c + b * s
sig2.1 = var(x - x.hat)
if (is.na(a) || is.na(b)) {
c(lu = lu, mean = mean(x), amp = NA, relamp = NA,
phase = NA, pval = NA)
}
else {
p = 3
R2 = 0
if (sig2 > 0)
R2 = 1 - sig2.1/sig2
amp = max(x) - min(x)
phase = period/(2 * pi) * atan2(b, a)
if (phase < 0)
phase = phase + period
if (phase > period)
phase = phase - period
phase = (phase + offset)%%period
pval = pbeta(R2, (p - 1)/2, (n - p)/2, lower.tail = FALSE,
log.p = FALSE)
c(nb.timepoints = nb.timepoints, mean = mean(x),
amp = 2 * sqrt(a^2 + b^2), relamp = sqrt(a^2 +
b^2)/(mu), phase = phase, pval = pval)
}
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.