| Title: | Calendar-Aware Temporal Metadata for Longitudinal Omics |
|---|---|
| Description: | Longitudinal and circadian omics experiments encode sample time as elapsed experiment time, civil timestamps, or light-cycle coordinates. OmicsChrono validates and standardizes temporal sample metadata in SummarizedExperiment and derived Bioconductor containers while preserving assays and feature metadata. It supports elapsed-time annotation, sampling-window alignment, time-zone and daylight-saving diagnostics, Zeitgeber-time annotation, and temporal coverage summaries as reproducible preprocessing for downstream time-course analyses. |
| Authors: | Mateo Pedersen [aut, cre] |
| Maintainer: | Mateo Pedersen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-10-07 08:25:31 UTC |
| Source: | https://github.com/BiocStaging/OmicsChrono |
Compute time since an explicitly specified local lights-on time and classify each sample as light or dark under the supplied controlled photoperiod.
addZeitgeberTime( x, timestamp, lights_on, timezone, photoperiod = 12, ambiguous = "error", overwrite = FALSE )addZeitgeberTime( x, timestamp, lights_on, timezone, photoperiod = 12, ambiguous = "error", overwrite = FALSE )
x |
A 'SummarizedExperiment' or derived object. |
timestamp |
Name of a civil-time column in 'colData(x)'. |
lights_on |
Local clock time in 'HH:MM' or 'HH:MM:SS' format. |
timezone |
One IANA time zone or one zone per sample. |
photoperiod |
Number of hours per cycle in the light phase; must be between zero and 24. |
ambiguous |
DST fall-back policy as in [annotateSampleTime()]. |
overwrite |
Replace existing 'chrono_zeitgeber_hours', 'chrono_light_phase', and 'chrono_hours_until_phase_change' columns. |
ZT0 is defined by the provided local lights-on clock time. The calculation uses local clock coordinates modulo 24 hours and the supplied light duration; it does not infer biological phase or query external data. Studies with non-24-hour cycles should use a separately specified experimental schedule.
An object of the same class with three Zeitgeber fields in 'colData'.
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:2, nrow = 1)), colData = S4Vectors::DataFrame(collection = c("2024-06-01 07:00:00", "2024-06-01 19:00:00")) ) out <- addZeitgeberTime(se, "collection", lights_on = "07:00", timezone = "Europe/Oslo", photoperiod = 12) SummarizedExperiment::colData(out)$chrono_zeitgeber_hoursse <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:2, nrow = 1)), colData = S4Vectors::DataFrame(collection = c("2024-06-01 07:00:00", "2024-06-01 19:00:00")) ) out <- addZeitgeberTime(se, "collection", lights_on = "07:00", timezone = "Europe/Oslo", photoperiod = 12) SummarizedExperiment::colData(out)$chrono_zeitgeber_hours
Match samples to expected time points using a deterministic one-to-one nearest-offset assignment. Samples and expected times use the same numeric unit. Ties are resolved by input sample order and then expected-time order.
alignSampleTimes(observed, expected, tolerance, subject = NULL, sample = NULL)alignSampleTimes(observed, expected, tolerance, subject = NULL, sample = NULL)
observed |
Numeric vector of observed times. |
expected |
Numeric vector of expected times. |
tolerance |
Maximum absolute difference for a match, in the same unit as 'observed' and 'expected'. |
subject |
Optional subject identifier per observation. |
sample |
Optional sample identifier per observation. |
An 'S4Vectors::DataFrame' with one row per expected slot and one row per unmatched observed sample. 'status' is 'matched', 'missing', or 'unexpected'.
alignSampleTimes(c(0.1, 5.8, 12.3), c(0, 6, 12), tolerance = 0.5, subject = c("a", "a", "a"))alignSampleTimes(c(0.1, 5.8, 12.3), c(0, 6, 12), tolerance = 0.5, subject = c("a", "a", "a"))
Add normalized time fields to 'colData(x)', leaving assay values, feature metadata, sample order, and the input class intact. Character civil timestamps require 'timezone'; DST-ambiguous times error by default and may be explicitly resolved with 'ambiguous = "earliest"' or '"latest"'.
annotateSampleTime( x, time, subject = NULL, time_unit = NULL, timezone = NULL, ambiguous = "error", baseline = "first", overwrite = FALSE )annotateSampleTime( x, time, subject = NULL, time_unit = NULL, timezone = NULL, ambiguous = "error", baseline = "first", overwrite = FALSE )
x |
A 'SummarizedExperiment' or derived object. |
time |
Name of a 'colData(x)' column containing sample times. |
subject |
Optional subject column name or one subject identifier per sample. If omitted, all samples are treated as one subject. |
time_unit |
Unit for bare numeric values or 'T' tokens: '"minutes"', '"hours"', or '"days"'. |
timezone |
One IANA time zone or one zone per sample for civil times. Supply 'NULL' for elapsed-time data or absolute 'POSIXct' instants. |
ambiguous |
How an ambiguous local civil timestamp is treated for diagnostics. The default '"error"' requires explicit disambiguation; '"earliest"' and '"latest"' select one occurrence and report a warning. |
baseline |
Baseline rule. The default '"first"' sets elapsed time zero at the first valid sample for each subject, in the supplied sample order. |
overwrite |
Replace derived columns with the same names. Defaults to 'FALSE' so existing metadata is never silently overwritten. |
Elapsed-time inputs are converted to hours. Civil timestamps are parsed as local wall times in the supplied time zone(s), then differenced as absolute instants in UTC. Derived columns are 'chrono_timestamp_utc', 'chrono_timestamp_local', 'chrono_elapsed_hours', 'chrono_study_day', 'chrono_day_index', 'chrono_clock_hour', 'chrono_day_of_week', 'chrono_is_dst', and 'chrono_sampling_interval_hours'. Non-monotonic input order is preserved and can be inspected with [validateSampleTime()].
An object of the same class as 'x', with temporal fields appended to 'colData(x)'.
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:6, nrow = 2)), colData = S4Vectors::DataFrame(subject = c("a", "a", "b"), minute = c(0, 15, 0)) ) out <- annotateSampleTime(se, "minute", subject = "subject", time_unit = "minutes") SummarizedExperiment::colData(out)$chrono_elapsed_hoursse <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:6, nrow = 2)), colData = S4Vectors::DataFrame(subject = c("a", "a", "b"), minute = c(0, 15, 0)) ) out <- annotateSampleTime(se, "minute", subject = "subject", time_unit = "minutes") SummarizedExperiment::colData(out)$chrono_elapsed_hours
Report sample counts, temporal ranges, intervals, and interval variability by subject and optional condition from the sample metadata in a 'SummarizedExperiment'.
temporalCoverage(x, time, subject = NULL, condition = NULL)temporalCoverage(x, time, subject = NULL, condition = NULL)
x |
A 'SummarizedExperiment' or derived object. |
time |
Name of a numeric 'colData(x)' time column. |
subject |
Optional subject column name or one subject identifier per sample. |
condition |
Optional condition column. |
An 'S4Vectors::DataFrame' with one row per subject/condition group.
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:8, nrow = 2)), colData = S4Vectors::DataFrame(subject = rep(c("a", "b"), each = 2), hour = c(0, 6, 0, 12)) ) temporalCoverage(se, "hour", subject = "subject")se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:8, nrow = 2)), colData = S4Vectors::DataFrame(subject = rep(c("a", "b"), each = 2), hour = c(0, 6, 0, 12)) ) temporalCoverage(se, "hour", subject = "subject")
Copy selected sample-level time, subject, and condition fields into a 'DataFrame', optionally adding sine and cosine terms for a user-specified cycle length. No model is fitted and phase is not inferred.
temporalDesignData( x, time, subject = NULL, condition = NULL, cycle_length = NULL )temporalDesignData( x, time, subject = NULL, condition = NULL, cycle_length = NULL )
x |
A 'SummarizedExperiment' or derived object. |
time |
Name of a numeric time column, normally '"chrono_elapsed_hours"'. |
subject |
Optional subject column name or one subject identifier per sample. |
condition |
Optional condition column name. |
cycle_length |
Optional positive numeric cycle length in the same unit as 'time'. When supplied, include cyclical sine/cosine covariates. |
An 'S4Vectors::DataFrame' in original sample order.
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:4, nrow = 1)), colData = S4Vectors::DataFrame(hour = c(0, 6, 12, 18), subject = rep("mouse1", 4)) ) temporalDesignData(se, "hour", subject = "subject", cycle_length = 24)se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:4, nrow = 1)), colData = S4Vectors::DataFrame(hour = c(0, 6, 12, 18), subject = rep("mouse1", 4)) ) temporalDesignData(se, "hour", subject = "subject", cycle_length = 24)
Inspect a sample-time column for missing or malformed values, ambiguous civil times, duplicate subject-time combinations, negative elapsed values, and non-monotonic sample order. Civil timestamps must be ISO local times and need an explicit IANA time zone. Numeric elapsed times need 'time_unit'; tokens such as '"15 min"', '"day3"', '"T4"', and '"baseline"' are also supported.
validateSampleTime( x, time, subject = NULL, time_unit = NULL, timezone = NULL, ambiguous = "error" )validateSampleTime( x, time, subject = NULL, time_unit = NULL, timezone = NULL, ambiguous = "error" )
x |
A 'SummarizedExperiment' or derived object. |
time |
Name of a 'colData(x)' column containing sample times. |
subject |
Optional subject column name or one subject identifier per sample. If omitted, all samples are treated as one subject. |
time_unit |
Unit for bare numeric values or 'T' tokens: '"minutes"', '"hours"', or '"days"'. |
timezone |
One IANA time zone or one zone per sample for civil times. Supply 'NULL' for elapsed-time data or absolute 'POSIXct' instants. |
ambiguous |
How an ambiguous local civil timestamp is treated for diagnostics. The default '"error"' requires explicit disambiguation; '"earliest"' and '"latest"' select one occurrence and report a warning. |
This function reports metadata problems without changing 'x'. Civil times use ' Numeric and unit-bearing elapsed-time tokens are normalized to hours only for validation. No assay data are read or modified.
An 'S4Vectors::DataFrame' with one row per diagnostic and columns 'sample', 'subject', 'code', 'severity', 'message', and 'value'. A report with zero rows means no issues were detected.
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:6, nrow = 2)), colData = S4Vectors::DataFrame(subject = c("a", "a", "b"), sample_time = c("0 min", "15 min", "baseline")) ) validateSampleTime(se, "sample_time", subject = "subject")se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(1:6, nrow = 2)), colData = S4Vectors::DataFrame(subject = c("a", "a", "b"), sample_time = c("0 min", "15 min", "baseline")) ) validateSampleTime(se, "sample_time", subject = "subject")