Compute differential rhythm statistics from fitted models
Source:R/get_stats.R
getDiffRhythmStats.RdThis function computes differences in rhythmicity between fitted curves for a given pair of conditions.
Arguments
- fit
A
limorhyde2object containing data from multiple conditions.- rhyStats
A
data.tableof rhythmic statistics, as returned bygetRhythmStats(), for fitted models infit.- conds
A character vector indicating the conditions to compare pairwise, by default all conditions in
fit.- 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.
Value
A data.table containing the following differential rhythm
statistics:
mean_mesormean_peak_trough_ampmean_rms_amp(only calculated ifrmstogetRhythmStats()wasTRUE)diff_mesordiff_peak_trough_ampdiff_rms_amp(only calculated ifrmstogetRhythmStats()wasTRUE)diff_peak_phase: circular difference between-fit$period/2andfit$period/2diff_trough_phase: circular difference between-fit$period/2andfit$period/2diff_rhy_dist: Euclidean distance between polar coordinates (peak_trough_amp,peak_phase)rms_diff_rhy: root mean square difference in mean-centered fitted curves (only calculated ifrmstogetRhythmStats()wasTRUE)
The stats will be based on the value for cond2 minus the value for cond1.
The rows of the data.table depend on the 'fitType' attribute of rhyStats:
'fitType' is 'posterior_mean' or 'raw': one row per feature per pair of conditions.
'fitType' is 'posterior_samples': one row per feature per posterior sample per pair of conditions.
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)