This function uses stats::optim() to compute various properties of
fitted curves with respect to time, potentially in each condition and for
each posterior sample, and adjusting for any covariates.
Usage
getRhythmStats(
fit,
fitType = c("posterior_mean", "posterior_samples", "raw"),
features = NULL,
dopar = TRUE,
rms = FALSE
)Arguments
- fit
A
limorhyde2object.- fitType
String indicating which fitted models to use to compute the rhythmic statistics. A typical analysis using
limorhyde2will be based on 'posterior_mean', the default.- features
Vector of names, row numbers, or logical values for subsetting the features.
NULLindicates all features.- dopar
Logical indicating whether to run calculations in parallel if a parallel backend is already set up, e.g., using
doParallel::registerDoParallel(). Recommended to minimize runtime.- rms
Logical indicating whether to calculate
rms_amp.
Value
A data.table containing the following rhythm statistics:
peak_phase: time between 0 andfit$periodat which the peak or maximum value occurspeak_valuetrough_phase: time between 0 andfit$periodat which the trough or minimum value occurstrough_valuepeak_trough_amp:peak_value - trough_valuerms_amp: root mean square difference between fitted curve and mean value between time 0 andfit$period(only calculated ifrmsisTRUE)mesor: mean value between time 0 andfit$period
The rows of the data.table depend on the fit object and fitType:
fitcontains data from one condition andfitTypeis posterior_mean' or 'raw': one row per feature.fitcontains data from one condition andfitTypeis 'posterior_samples': one row per feature per posterior sample.fitcontains data from multiple conditions andfitTypeis 'posterior_mean' or 'raw': one row per feature per condition.fitcontains data from multiple conditions andfitTypeis 'posterior_samples': one row per feature per condition per posterior sample.
Examples
library('data.table')
# rhythmicity in one condition
y = GSE54650$y
metadata = GSE54650$metadata
fit = getModelFit(y, metadata)
fit = getPosteriorFit(fit)
rhyStats = getRhythmStats(fit, features = c('13170', '13869'))
# rhythmicity and differential rhythmicity in multiple conditions
y = GSE34018$y
metadata = GSE34018$metadata
fit = getModelFit(y, metadata, nKnots = 3L, condColname = 'cond')
fit = getPosteriorFit(fit)
rhyStats = getRhythmStats(fit, features = c('13170', '12686'))
diffRhyStats = getDiffRhythmStats(fit, rhyStats)