pRAIN is a parallel-enabled fork of the RAIN R package (Thaben & Westermark, 2014) for detecting rhythmic signals in circadian and other periodic time-series data.
The original RAIN implements a non-parametric umbrella-alternatives test
(Mack & Wolfe, 1981) extended for cyclic data. pRAIN adds a single new
parameter (num.cores) that parallelises the two most expensive internal
steps without changing any outputs.
rain(..., num.cores=1L)The default (1L) reproduces original RAIN behaviour exactly. Any value
greater than 1 activates parallel execution across two independent layers:
Harding null-distribution precomputation — the dominant bottleneck for dense sampling (e.g. 1-hour intervals) or when the sampling duration is not a multiple of the period. All unique configurations are identified upfront; their exact null distributions are then computed simultaneously rather than sequentially.
Per-series evaluation loop — each time series (e.g. gene) is scored independently against the precomputed distributions and has its p-values adjusted. These are evaluated in parallel across all input columns.
| Platform | Precomputation | Evaluation loop |
|---|---|---|
| macOS / Linux | parallel::mclapply (fork-based) | parallel::mclapply |
| Windows | sequential | parallel::makeCluster + parLapply |
The parallel package ships with base R meaning no additional dependencies are
introduced.
Example: 48-hour time-series, 2-hour sampling interval, 5 replicates, 10000 genes.
num.cores | Time |
|---|---|
| 1 | ~403 s |
| 2 | ~224 s |
| 4 | ~136 s |
| 8 | ~130 s |
Speedup scales primarily with the number of unique null distributions that need to be computed, which grows with the number of replicates and (especially) when the sampling duration is not a multiple of the period.
# install.packages("pak")pak::pak("pascalnoser/prain")You will also need the Bioconductor dependencies:
if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install(c("multtest", "gmp"))library(prain)
# Simulate data: 24 time points, 3 replicates, 200 genes
set.seed(42)
mat<-matrix(rnorm(24*3*200), nrow=24*3)
# Sequential (original behaviour)results_seq<- rain(mat, deltat=1, period=24, nr.series=3,
method="independent")
# Parallel — use all available coresresults_par<- rain(mat, deltat=1, period=24, nr.series=3,
method="independent",
num.cores=parallel::detectCores())
# Results are identical
all.equal(results_seq, results_par) # TRUESee ?rain for the full parameter reference.
pRAIN is a thin wrapper around the original RAIN package. All statistical methodology and the core algorithm are the work of the original authors:
Paul F. Thaben and Pål O. Westermark
Detecting Rhythms in Time Series with RAIN.
Journal of Biological Rhythms, 29(6), 391–400 (2014).
doi: 10.1177/0748730414553029
If you use pRAIN in published work, please cite the paper above.
The original RAIN package is available on Bioconductor: https://www.bioconductor.org/packages/release/bioc/html/rain.html
GPL-2 (same as the original RAIN package).