| Title: | Beta Regression Cosinor Models for Circadian Methylation Analysis |
|---|---|
| Description: | Fits cosinor-based beta regression models for detecting circadian rhythmicity in DNA methylation array data using Template Model Builder (TMB) for efficient likelihood optimization. Supports fixed-effects (cross-sectional) and mixed-effects (repeated measures) designs with configurable period and adjustment covariates. Implements empirical Bayes shrinkage of the beta distribution precision parameter across CpG sites, analogous to limma's moderated variance, to improve genome-wide inference. Provides amplitude, phase, and MESOR estimation on both logit-link and response scales. |
| Authors: | Yixiang Hong [aut, cre] |
| Maintainer: | Yixiang Hong <[email protected]> |
| License: | GPL (>= 3) + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-09-21 06:53:30 UTC |
| Source: | https://github.com/BiocStaging/RhyME |
Fits a RhyME to each CpG site in a methylation array dataset. Supports both fixed-effects (cross-sectional) and mixed-effects (repeated measures with random intercepts) designs, and optionally applies empirical Bayes shrinkage to the precision parameter (phi).
fitCosinor( se, time_col = "time", subject_col = NULL, assay_name = NULL, period = 24, prior = c("auto", "none"), test = c("Wald", "LRT"), BPPARAM = BiocParallel::MulticoreParam(), verbose = TRUE, covariates = NULL )fitCosinor( se, time_col = "time", subject_col = NULL, assay_name = NULL, period = 24, prior = c("auto", "none"), test = c("Wald", "LRT"), BPPARAM = BiocParallel::MulticoreParam(), verbose = TRUE, covariates = NULL )
se |
A SummarizedExperiment::SummarizedExperiment object. The specified assay should contain methylation beta values in [0, 1]. Values exactly at the boundaries are moved slightly inward for beta regression. |
time_col |
Character, column name in |
subject_col |
Character or NULL. Column name in |
covariates |
Character vector or NULL. Optional |
assay_name |
Character or NULL, name of the assay to use. The default
NULL uses the first assay in |
period |
Numeric, the oscillation period in hours (default 24 for circadian rhythms). Can be set to other values for ultradian or infradian rhythms. |
prior |
Character, either |
test |
Rhythmicity test: a covariance-aware joint Wald test of the sine
and cosine coefficients ( |
BPPARAM |
A BiocParallel::BiocParallelParam object for execution.
Defaults to |
verbose |
Logical, print messages and show supported progress bars. |
When covariates are supplied, their centered design columns are
included in both the full and null models. Consequently, the reported
p-value still tests only the joint sine/cosine rhythmicity effect, while
response-scale summaries describe the mean covariate profile.
The input SummarizedExperiment with per-CpG results appended to
rowData(se) and design info, EB prior, test settings, and fit summary
stored in metadata(se)$RhyME.
ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) head(SummarizedExperiment::rowData(fit))ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) head(SummarizedExperiment::rowData(fit))
Overlays the fitted cosinor curve on raw beta values for a set of CpGs.
plotCosinorFit( se, cpgs = NULL, assay_name = NULL, time_col = NULL, ncol = 3, n_grid = 200 )plotCosinorFit( se, cpgs = NULL, assay_name = NULL, time_col = NULL, ncol = 3, n_grid = 200 )
se |
A SummarizedExperiment::SummarizedExperiment object
returned by |
cpgs |
Character vector of CpG identifiers to plot. If NULL, the top 6 CpGs by p-value are plotted. |
assay_name |
Character or NULL. By default, use the assay recorded by
|
time_col |
Character or NULL. By default, use the time column recorded
by |
ncol |
Integer, number of columns in facet layout (default 3). |
n_grid |
Integer, resolution of fitted curve grid (default 200). |
A ggplot2 object.
ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) plotCosinorFit(fit, cpgs = rownames(fit)[1], ncol = 1)ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) plotCosinorFit(fit, cpgs = rownames(fit)[1], ncol = 1)
Filters to converged CpGs, selects key columns, and returns the top
n sorted by sort_by.
topCpGs(se, n = 10, sort_by = "pvalue")topCpGs(se, n = 10, sort_by = "pvalue")
se |
A SummarizedExperiment::SummarizedExperiment object
returned by |
n |
Integer, number of top CpGs to return (default 10). |
sort_by |
Character, column to sort by (default |
A S4Vectors::DataFrame with the top CpGs.
ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) topCpGs(fit, n = 3)ex <- readRDS(system.file("extdata", "example_data.rds", package = "RhyME")) se <- ex$se[seq_len(5), ] fit <- fitCosinor(se, time_col = "time", subject_col = "subject", prior = "none", verbose = FALSE) topCpGs(fit, n = 3)