| lfq_data | R Documentation |
Validates, structures, and annotates lineage count data for downstream modeling and analysis. This is the entry point for all lineagefreq workflows.
lfq_data(
data,
lineage,
date,
count,
total = NULL,
location = NULL,
min_total = 10L
)
data |
A data frame containing at minimum columns for lineage identity, date, and count. |
lineage |
< |
date |
< |
count |
< |
total |
< |
location |
< |
min_total |
Minimum total count per time point. Time points below this are flagged as unreliable. Default 10. |
Performs the following validation and processing:
Checks that all required columns exist and have correct types.
Coerces character dates to Date via ISO 8601 parsing.
Ensures counts are non-negative integers.
Replaces NA counts with 0 (with warning).
Aggregates duplicate lineage-date rows by summing (with warning).
Computes per-time-point totals and frequencies.
Flags time points below min_total as unreliable.
Sorts by date ascending, then lineage alphabetically.
An lfq_data object (a tibble subclass) with standardized
columns:
.lineageLineage identifier (character).
.dateCollection date (Date).
.countSequence count (integer).
.totalTotal sequences at this time point (integer).
.freqObserved frequency (numeric).
.reliableLogical; TRUE if .total >= min_total.
.locationLocation, if provided (character).
All original columns are preserved.
d <- data.frame(
date = rep(seq(as.Date("2024-01-01"), by = "week",
length.out = 8), each = 3),
lineage = rep(c("JN.1", "KP.3", "Other"), 8),
n = c(5, 2, 93, 12, 5, 83, 28, 11, 61, 50, 20, 30,
68, 18, 14, 80, 12, 8, 88, 8, 4, 92, 5, 3)
)
x <- lfq_data(d, lineage = lineage, date = date, count = n)
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.