Abstract
The chi-square periodogram (CSP), developed over 40 years ago, continues to be one of the most popular methods to estimate the period of circadian (circa 24-h) rhythms. Previous work has indicated the CSP is sometimes less accurate than other methods, but understanding of why and under what conditions remains incomplete. Using simulated rhythmic time-courses, we found that the CSP is prone to underestimating the period in a manner that depends on the true period and the length of the time-course. This underestimation bias is most severe in short time-courses (e.g., 3 days), but is also visible in longer simulated time-courses (e.g., 12 days) and in experimental time-courses of mouse wheel-running and ex vivo bioluminescence. We traced the source of the bias to discontinuities in the periodogram that are related to the number of time-points the CSP uses to calculate the observed variance for a given test period. By revising the calculation to avoid discontinuities, we developed a new version, the greedy CSP, that shows reduced bias and improved accuracy. Nonetheless, even the greedy CSP tended to be less accurate on our simulated time-courses than an alternative method, namely the Lomb-Scargle periodogram. Thus, although our study describes a major improvement to a classic method, it also suggests that users should generally avoid the CSP when estimating the period of biological rhythms.
Author summary
The chi-square periodogram is a popular method for estimating period length, one of the most important properties of the daily biological rhythms found throughout nature. In this study, we identify a major source of inaccuracy in the chi-square periodogram, and quantify the inaccuracy using a broad array of simulated and experimentally observed biological rhythms. Although we revise the chi-square periodogram calculation to improve its accuracy, we also show that the revised version is still less accurate than an alternative method, the Lomb-Scargle periodogram. Our work thus provides evidence on how to obtain better estimates of the period of biological rhythms.
Introduction
Period estimation is critical to the study of circadian rhythms, the endogenous, near-24-h rhythms in physiology and behavior exhibited by organisms from bacteria to humans. For example, the influence of a gene on the circadian clock is assessed in part by estimating the period of rhythms when the gene is absent [1,2]. Effects on period have also been useful for elucidating the contributions of particular cell populations to the central circadian pacemaker in the mammalian brain [3–5] and exploring how the pacemaker reorganizes in response to environmental cues [6,7].
Given a time-course of potentially rhythmic measurements, a standard approach for estimating the underlying period is the chi-square periodogram (CSP) [8]. Previous studies have found that the CSP tends to be less accurate in certain scenarios (e.g., short time-courses) compared to other methods [9–11]. However, these studies did not examine the extent to which the accuracy of each method depends on the combination of time-course length and underlying period, and the reasons for the CSP’s lower accuracy remain unclear. Despite its limitations, the CSP remains widely used for estimating period in various types of rhythms across a variety of species [12–16].
Here we used simulated time-courses to uncover and characterize a major source of bias in the standard CSP. The bias results in an underestimation of the period, the degree of which depends on an interaction between the true period and the length of the time-course. Although the bias is most severe in short time-courses (e.g., 3 days), it is observable in simulated time-courses up to at least 12 days. We also see the signature of bias in experimental time-courses of mouse wheel-running and ex vivo bioluminescence. To mitigate the bias, we developed and validated two new versions of the CSP that eliminate the discontinuity from the periodogram and thus estimate period without a period-dependent bias. Although one of these revised versions had greater accuracy and lower variance than the standard CSP, it still tended to be less accurate than alternatives such as the Lomb-Scargle periodogram. Thus, the CSP (in any formulation) should likely not be the first choice for period estimation of biological rhythms.
Methods
Data availability
All period estimation methods used in this study are available in an open-source R package called spectr (https://spectr.hugheylab.org). For the Lomb-Scargle periodogram, spectr depends on the lsp function of the lomb R package [9]. For the fast Fourier Transform, spectr depends on the spec.pgram function of the stats package included in R.
Standard, conservative, and greedy chi-square periodograms
The standard CSP for a time-course of N time-points is based on calculating, for each test period P, the ratio of the variance of the means of a series of every Pth time-point (“observed”) to the variance of all K * P time-points (“expected”), where K is the number of time-points in each of the P sets of means [8]. This ratio, referred to as QP, is calculated as:
where Xi corresponds to the ith time-point, corresponds to the mean of all included time-points (explained below) and for a given value of P corresponds to the mean of every Pth time-point.
K is therefore equal to the highest integer quotient of N / P:
Defined this way, K is subject to change across different test periods and any time-points between K * P and N will be excluded from the calculation for that particular test-period.
In the conservative CSP, K is kept constant across the range of test periods Pmin to Pmax:
In this formulation, K remains constant but is completely dependent on Pmax and the number of omitted timepoints (those between K * P and N) is large.
In the greedy CSP, K is allowed to take non-integer values:
Here the number of time-points omitted remains zero throughout the range of test periods and the value of K is independent of the test period range. In both modified versions, the calculation of the ratio of variances proceeds similarly to the standard CSP. The p-value is based on the approximate chi-square statistic QP and the degrees of freedom P—1.
Lomb-Scargle periodogram and fast Fourier transform
We calculated the Lomb-Scargle periodogram using an oversampling factor of 100, and calculated the fast Fourier transform using a zero-padding factor of 100. These factors do not alter spectral resolution (i.e., the ability to distinguish two peaks in the periodogram), but do improve each method’s ability to estimate the location of a single peak. The CSP has no equivalent of oversampling or padding [17].
Simulations and analysis
To simulate time-courses of rhythmic measurements, we used the simphony R package [18]. The simulations varied in true period, amplitude, waveform shape, and time-course length as indicated in the text. Each simulation had a phase sampled uniformly between 0 and the true period.
To simulate non-sinusoidal rhythms, we used a smooth sawtooth wave and a smooth square wave. The smooth sawtooth wave corresponded to:
where n = 100 and β = 1.01495. The smooth square wave corresponded to:
where δ = 0.2.
Unless otherwise specified, simulations had a sampling interval of 0.1 h and i.i.d. Gaussian noise of mean 0 and standard deviation 1. Simulations with Poisson sampling followed x(t) = A·f(t)+A+1, where x(t) is both the expected value and its variance, A is the amplitude, and f(t) is the rhythmic function that goes between -1 and 1, i.e., sine, smooth sawtooth, or smooth square. Because a Poisson distribution can only take integer values ≥ 0 and has variance equal to its mean, it may better approximate activity counts.
For each version of the CSP, we defined the estimated period for a given simulation as the test period with the minimum p-value. For the LSP and FFT, we defined the estimated period as the test period with the maximum power. We limited test periods to between 18 and 30 h. We then calculated the error as the difference between the true period and the estimated period.
Results
The standard chi-square periodogram shows discontinuities, related to time-course length, that can result in underestimation of the true period
In testing methods of period estimation on simulated time-courses, we found that the chi-square periodogram (CSP) sometimes underestimated true period values > 24 h (Fig 1A), with estimates seemingly fixed near 24 h (Fig 1B). Furthermore, the periodograms showed a discontinuity coinciding with the incorrect period estimate, such that rhythmic power appeared to decrease sharply for candidate periods > 24 h (Fig 1C and 1D). The discontinuity was observable in multiple software implementations of the CSP (S1 Fig), indicating that it was not due to an error in our calculations. In contrast, the Lomb-Scargle periodogram (LSP) showed no such estimation bias (Fig 1A and 1B) or discontinuity (Fig 1E), indicating that the phenomenon was specific to the CSP.
To determine the source of the discontinuity and resulting bias in period estimation, we examined each quantity calculated as part of the CSP (Fig 2). The CSP for a dataset of N time-points (Fig 2A) defines a chi-square statistic (sometimes called QP) for each test period under consideration. The number of time-points in a test period (e.g., 240 for a test period of 24 with time-points every 0.1 h) is referred to as P. For each test period, the N time-points are arranged in row-major order into a grid with P columns and K complete rows (Fig 2B, filled squares). The remaining D time-points, where P * K + D = N, are omitted from the calculation for that test period (Fig 2B, open squares). The ratio of the variance of the column means of the grid and the variance of the non-omitted time-points gives rise to the chi-square statistic and corresponding p-value.
Each test period in the CSP therefore has associated values of K and D (Fig 2C). Although K decreases monotonically as P (again, the number of time-points comprising a test period) increases, the decrease is not continuous (Fig 2C, middle plot). In our initial simulations, the discontinuity in the periodograms occurred at a test period (24 h) where K decreased and D increased (Fig 2C).
Because K decreases at test periods of which the length of the time-course is a multiple, we simulated time-courses of different lengths to test whether the location of the discontinuity changed accordingly (Fig 3). We first simulated time-courses of 68, 72, and 76 h, in which the true period was 24 h. As expected, the largest discontinuity in the periodograms occurred at test periods of 22.6, 24, and 25.3 h, respectively, all coinciding with changes in K (Fig 3A). In the 76-h simulations, an additional discontinuity appeared that also coincided with a change in K. In the 68-h simulations, the discontinuity was sufficient to alter the apparent peak of the periodogram. Thus, in these simulations, changing the length of the time-course by 4 h—without changing the underlying waveform—could decrease the estimated period by 1.4 h.
We next simulated time-courses of 72, 144, and 288 h (all multiples of 24 h), again with a true period of 24 h. In each case, the largest discontinuity occurred at a test period of 24 h and all discontinuities coincided with changes in K (Fig 3B). Taken together, these results indicate that discontinuities are inherent to the calculation of the standard CSP and lead to the bias in period estimation.
To further characterize the bias, we applied the CSP to simulated time-courses that varied in length as well as in period and amplitude of the underlying rhythm. We found that as the length of the time-course increased, the magnitude of the bias decreased and the range of true periods affected by the bias narrowed (Fig 3C). For example, in 6-day time-courses the bias affected true periods between approximately 24 and 24.8 h, whereas in 9-day time-courses the bias affected true periods between approximately 24 and 24.4 h. In these ranges of true periods, the CSP’s discontinuity caused the peak of the periodogram to always occur at a test period of 24 h. At the right-most edge of each range, a small change in true period led to a large change in estimated period. In 12-day time-courses the bias affected two distinct ranges of true periods, each range corresponding to a discontinuity. Importantly however, both the magnitude of the bias and the ranges of affected true periods were independent of rhythm amplitude (S2 Fig). Thus, although the CSP bias diminishes with longer time-courses, it does not diminish with higher-amplitude rhythms.
Revising the calculation of the chi-square periodogram removes the discontinuity and reduces the bias
We next sought to modify the calculation of the CSP to avoid discontinuities and hopefully remove the estimation bias. We developed two new versions of the CSP: the conservative CSP and greedy CSP. In the conservative CSP, K is held constant across all test periods at a value equal to the maximum number of complete rows possible at the highest test period considered (i.e., K in the conservative CSP corresponds to the minimum K in the standard CSP; Fig 4A). In the greedy CSP, the columns of the P-by-K grid are allowed to have unequal numbers of rows, and K is set to the mean number of rows per column (which might not be an integer; Fig 4B). Compared to the standard CSP, the conservative version tends to discard more data, whereas the greedy version never discards any. In both cases, the calculation of variances proceeds similarly to the standard CSP and so the periodograms maintain their relationship to the chi-square distribution. The periodograms calculated using the new CSP versions show no discontinuities (Fig 4A and 4B).
To determine whether these modifications reduced the bias of the CSP, we tested each version on a comprehensive set of simulations (see Methods). As baseline methods for comparison, we used the LSP and a padded FFT. For each simulation and each method, we calculated the estimate error and the absolute estimate error. Compared to the distributions of estimate error from the standard CSP, those from the conservative and greedy CSPs were centered closer to zero and less dependent on the true period (Figs 5A and S3–S5), indicating that the new CSP versions do indeed have reduced bias. Compared to the conservative CSP, the greedy CSP tended to give distributions of estimate error with lower variance (S1 Table), consistent with the latter tending to omit fewer time-points from the calculation. The lower variance of the greedy CSP translated to a lower absolute estimate error, whereas the higher variance of the conservative CSP caused its absolute estimate error to often be higher than that of the standard CSP (Fig 5B and S2 and S3 Tables). For example, in 3-day simulations with a period of 23 h (where the discontinuity has little effect), the standard, conservative, and greedy CSPs had mean absolute errors of 0.295, 0.505, and 0.337 h, respectively. In 3-day simulations with a period of 25 h, however, where the discontinuity strongly affects the standard CSP, the mean absolute errors of the three methods were 1.042, 0.553, and 0.417 h, respectively. These trends were independent of the rhythm’s waveform and amplitude (S3 and S4 Figs and S2 and S3 Tables) and were also present in time-courses of lower temporal resolution (S5 Fig and S4 Table). These results suggest that of the three CSP versions, the greedy CSP strikes the best balance between bias and variance so as to achieve accurate period estimation.
However, even the greedy CSP tended to have higher variance in estimate error and higher absolute estimate error compared to the LSP and the padded FFT (Figs 5 and S3–S5 and S2–S4 Tables). These patterns persisted in simulations with Poisson noise rather than Gaussian noise (S6 and S7 Figs, S5 and S6 Tables). Thus, although our revisions to the CSP have improved its accuracy, they have not improved it to the level of alternative methods for estimating rhythmic period.
The bias of the standard chi-square periodogram is visible when applied to experimental data
To complement our analyses of simulated time-courses, we next estimated the free-running period in time-courses of mouse wheel-running activity [7]. We truncated the wheel-running data to six different lengths: 72, 120, and 168 h (3, 5, and 7 24-h days) and 69, 115, and 161 h (3, 5, and 7 23-h days). Because the true period in each truncated time-course is unknown, we compared the estimates of the standard CSP against those of the LSP (Fig 6A). Similarly to the standard CSP’s estimates on simulated time-courses, its estimates here tended to accumulate at values of which the time-course length is a multiple. This tendency became stronger in shorter time-courses. Furthermore, the periodograms for the standard CSP showed discontinuities at the expected locations based on time-course length (Fig 6B), whereas the periodograms for the LSP showed no discontinuities (Fig 6C). We observed similar trends when we analyzed time-courses of bioluminescence from ex vivo slices of mouse suprachiasmatic nuclei (SCN) expressing PER2::LUCIFERASE [7] (S8 Fig). These results suggest that the bias of the standard CSP is reproducible in experimental data.
Discussion
The chi-square periodogram remains widely used in studies of circadian rhythms despite a variety of alternatives [11,17]. Previous work on the CSP suggested that, for time-courses shorter than 5–10 days, the test statistics (QP) may not follow a chi-square distribution and thus the associated p-values may be misleading [8,19]. While these previous findings highlight the risk of overinterpreting a given test period's power, our current findings highlight a potentially more severe risk: systematically misestimating the test period with the highest power. Although the risk we identified lessens in longer time-courses, our simulations indicate that it is largely independent of the rhythm’s shape and amplitude. Thus, even a highly “statistically significant” rhythm in a moderate-length circadian time-course is vulnerable.
The advantage of simulated time-courses is that they allow precise quantification of how different properties of a rhythm affect the accuracy of each method. The disadvantage is that their similarity to experimental time-courses is only approximate. For example, each of our simulations had a single, stationary period. This simplification seems reasonable, however, because stationarity is a primary assumption of every method we evaluated. Furthermore, methods to detect changes in a circadian rhythm over time require longer time-courses than we considered (e.g., 20 days) [20]. Overall, the consistency between our analyses of simulated and experimental time-courses supports the robustness of our findings.
Three factors make typical circadian time-courses especially vulnerable to the bias of the standard CSP. First, circadian experiments tend to be time-, labor-, and cost-intensive, which creates pressure to use the shortest time-course possible. Second, circadian time-courses are often arbitrarily collected in multiples of 24 h. Third, free-running circadian periods tend to be near (but not exactly) 24 h. Thus, based on our findings, the standard CSP will sometimes misestimate the period as exactly 24 h, particularly if the true period is slightly longer than 24 h.
The scale of such misestimations is not trivial. We observed period estimation errors of up to 0.5 h, 0.4 h, and 0.3 h in 6-day, 9-day, and 12-day simulated time-courses, respectively. For comparison, the standard deviation of the free-running period of wild-type C57 mice is only 0.06 h [21], and well-known clock gene mutations can alter period by 0.5–1.5 h [1]. Moreover, because the magnitude of the error depends on the true period, the standard CSP could also misestimate the difference in period between conditions. For instance, in 6-day time-courses in which one condition has a true period of 23.9 h and another condition 24.4 h, using the standard CSP could lead to an estimated period difference of only 0.1 h. Conversely, if the two conditions have true periods of 24.4 and 24.6 h, the estimated period difference could be 0.6 h. Importantly, these errors in estimated period and period difference do not diminish with larger sample sizes.
To minimize such errors, we developed two alternative approaches to calculate the chi-square periodogram. The first approach, which we call the conservative CSP, was useful to confirm the discontinuity as the source of bias but is impractical for two reasons. First, the large amount of omitted data produces period estimates with a large variance, and second, the chi-square statistic for each test period depends on the largest test period under consideration. The second approach, the greedy CSP, shows greatly reduced bias while maintaining low variance compared to the standard CSP. Nonetheless, the greedy CSP tends to be less accurate than the Lomb-Scargle periodogram (which can also accommodate unevenly spaced time-points) and the padded fast Fourier transform. Based on previous work [11], these two methods are likely not alone in outperforming the greedy CSP. The standard and modified versions of the CSP, as well as the LSP and padded FFT, are included in a new R package called spectr.
In conclusion, the risks of using the chi-square periodogram seem to outweigh any benefits. Overall, our findings support the following, in decreasing order of preference: (1) using alternative methods instead of any version of the CSP, (2) using the greedy CSP instead of the standard CSP, and (3) inspecting the periodograms of the standard CSP for discontinuities. In this way, our findings could strengthen the contribution of accurate period estimation to the study of biological rhythms.
Supporting information
Acknowledgments
We thank Allison Leich-Hilbun for input on the revised calculations for the chi-square periodogram. We thank Josh Schoenbachler for helping to develop unit tests for the spectr package. We thank Jeff Jones and Doug McMahon for helpful comments on the manuscript.
Data Availability
All data, code, and results for this study are available on Figshare (https://doi.org/10.6084/m9.figshare.12805082).
Funding Statement
This work was supported by the U.S. National Institutes of Health R35GM124685 to JJH. The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.
References
- 1.Vitaterna MH, King DP, Chang AM, Kornhauser JM, Lowrey PL, McDonald JD, et al. Mutagenesis and mapping of a mouse gene, Clock, essential for circadian behavior. Science. 1994;264: 719–725. 10.1126/science.8171325 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2.Meng Q-J, Logunova L, Maywood ES, Gallego M, Lebiecki J, Brown TM, et al. Setting clock speed in mammals: the CK1 epsilon tau mutation in mice accelerates circadian pacemakers by selectively destabilizing PERIOD proteins. Neuron. 2008;58: 78–88. 10.1016/j.neuron.2008.01.019 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Smyllie NJ, Chesham JE, Hamnett R, Maywood ES, Hastings MH. Temporally chimeric mice reveal flexibility of circadian period-setting in the suprachiasmatic nucleus. Proc Natl Acad Sci U S A. 2016;113: 3657–3662. 10.1073/pnas.1511351113 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Tso CF, Simon T, Greenlaw AC, Puri T, Mieda M, Herzog ED. Astrocytes Regulate Daily Rhythms in the Suprachiasmatic Nucleus and Behavior. Curr Biol. 2017;27: 1055–1061. 10.1016/j.cub.2017.02.037 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Brancaccio M, Edwards MD, Patton AP, Smyllie NJ, Chesham JE, Maywood ES, et al. Cell-autonomous clock of astrocytes drives circadian behavior in mammals. Science. 2019;363: 187–192. 10.1126/science.aat4104 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Buijink MR, Almog A, Wit CB, Roethler O, Olde Engberink AHO, Meijer JH, et al. Evidence for Weakened Intercellular Coupling in the Mammalian Circadian Clock under Long Photoperiod. PLoS One. 2016;11: e0168954 10.1371/journal.pone.0168954 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7.Tackenberg MC, Hughey JJ, McMahon DG. Distinct Components of Photoperiodic Light Are Differentially Encoded by the Mammalian Circadian Clock. J Biol Rhythms. 2020; 748730420929217. 10.1177/0748730420929217 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Sokolove PG, Bushell WN. The chi square periodogram: its utility for analysis of circadian rhythms. J Theor Biol. 1978;72: 131–160. 10.1016/0022-5193(78)90022-x [DOI] [PubMed] [Google Scholar]
- 9.Ruf T. The Lomb-Scargle Periodogram in Biological Rhythm Research: Analysis of Incomplete and Unequally Spaced Time-Series. Biol Rhythm Res. 1999;30: 178–201. [Google Scholar]
- 10.Refinetti R, Lissen GC, Halberg F. Procedures for numerical analysis of circadian rhythms. Biol Rhythm Res. 2007;38: 275–325. 10.1080/09291010600903692 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Zielinski T, Moore AM, Troup E, Halliday KJ, Millar AJ. Strengths and limitations of period estimation methods for circadian data. PLoS One. 2014;9: e96462 10.1371/journal.pone.0096462 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Moore D, Watts JC, Herrig A, Jones TC. Exceptionally short-period circadian clock in Cyclosa turbinata: regulation of locomotor and web-building behavior in an orb-weaving spider. J Arachnol. 2016;44: 388–396. [Google Scholar]
- 13.Brown LA, Fisk AS, Pothecary CA, Peirson SN. Telling the Time with a Broken Clock: Quantifying Circadian Disruption in Animal Models. Biology. 2019;8 10.3390/biology8010018 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14.Ono D, Honma K-I, Yanagawa Y, Yamanaka A, Honma S. GABA in the suprachiasmatic nucleus refines circadian output rhythms in mice. Commun Biol. 2019;2: 232 10.1038/s42003-019-0483-6 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 15.Akashi M, Matsumura R, Matsuo T, Kubo Y, Komoda H, Node K. Hypercholesterolemia Causes Circadian Dysfunction: A Potential Risk Factor for Cardiovascular Disease. EBioMedicine. 2017;20: 127–136. 10.1016/j.ebiom.2017.04.034 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16.Wehr TA. Bipolar mood cycles associated with lunar entrainment of a circadian rhythm. Transl Psychiatry. 2018;8: 151 10.1038/s41398-018-0203-x [DOI] [PMC free article] [PubMed] [Google Scholar]
- 17.Refinetti R. Laboratory instrumentation and computing: comparison of six methods for the determination of the period of circadian rhythms. Physiol Behav. 1993;54: 869–875. 10.1016/0031-9384(93)90294-p [DOI] [PubMed] [Google Scholar]
- 18.Singer JM, Fu DY, Hughey JJ. Simphony: simulating large-scale, rhythmic data. PeerJ. 2019;7: e6985 10.7717/peerj.6985 [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Refinetti R. Analysis of the circadian rhythm of body temperature. Behav Res Methods Instrum Comput. 1992;24: 28–36. [Google Scholar]
- 20.Leise TL. Analysis of Nonstationary Time Series for Biological Rhythms Research. J Biol Rhythms. 2017;32: 187–194. 10.1177/0748730417709105 [DOI] [PubMed] [Google Scholar]
- 21.Schwartz WJ, Zimmerman P. Circadian timekeeping in BALB/c and C57BL/6 inbred mouse strains. J Neurosci. 1990;10: 3685–3694. 10.1523/JNEUROSCI.10-11-03685.1990 [DOI] [PMC free article] [PubMed] [Google Scholar]