inst/doc/real-data-analysis.R

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 4
)

## ----load---------------------------------------------------------------------
library(lineagefreq)

data(cdc_sarscov2_jn1)
str(cdc_sarscov2_jn1)

## ----lfq-data-----------------------------------------------------------------
vd <- lfq_data(cdc_sarscov2_jn1,
               lineage = lineage, date = date, count = count)
vd

## ----collapse-----------------------------------------------------------------
vd_clean <- collapse_lineages(vd, min_freq = 0.05)
attr(vd_clean, "lineages")

## ----fit----------------------------------------------------------------------
fit <- fit_model(vd_clean, engine = "mlr")
fit

## ----ga-----------------------------------------------------------------------
ga <- growth_advantage(fit, type = "relative_Rt",
                       generation_time = 5)
ga

## ----plot-advantage-----------------------------------------------------------
autoplot(fit, type = "advantage", generation_time = 5)

## ----plot-trajectory----------------------------------------------------------
autoplot(fit, type = "trajectory")

## ----forecast-----------------------------------------------------------------
fc <- forecast(fit, horizon = 28)
autoplot(fc)

## ----emergence----------------------------------------------------------------
summarize_emerging(vd_clean)

## ----power--------------------------------------------------------------------
sequencing_power(
  target_precision = 0.05,
  current_freq = c(0.01, 0.02, 0.05)
)

## ----session-info-------------------------------------------------------------
sessionInfo()

Try the lineagefreq package in your browser

Any scripts or data that you put into this service are public.

lineagefreq documentation built on April 3, 2026, 9:09 a.m.