Skip to contents

cg_assemble() assembles a chronogram from 4 pieces of input data:

  • start date

  • end date

  • metadata

  • and an optional list of experiment data.

A verbose messsaging option (on by default) is provided to help troubleshoot input.

Extra experimental can be added later with cg_add_experiment().

For fine grain troubleshooting, run chronogram_skeleton() and chronogram() sequentially (these are called in turn by cg_assemble()). In all other circumstances, cg_assemble() is the encouraged method.

Usage

cg_assemble(
  start_date,
  end_date,
  calendar_date_col,
  metadata,
  metadata_ids_col,
  experiment_data_list = NULL,
  verbose = TRUE
)

Arguments

start_date

the start date, in a format recognised by lubridate::dmy()

end_date

the end date, in a format recognised by lubridate::dmy()

calendar_date_col

user-defined column name for dates (unquoted).

metadata

a tibble containing metadata

metadata_ids_col

the (unquoted) column name for participant IDs in metadata tibble. No default provided.

experiment_data_list

a list of tibbles of experiment data. See cg_add_experiment() for details. Ignored if not provided.

verbose

Default TRUE. Show progress messages?

Value

a chronogram (class cg_tbl)

Examples

## Example 1: A small study ##-------------------------------------
data(smallstudy)

## Setup ##
start <- "01012020"
end <- "10102021"
meta <- smallstudy$small_study_metadata ## age, sex, vaccine dates
ab <- smallstudy$small_study_Ab ## antibody response data

## Assembly ##
cg_small <- cg_assemble(

## start and end date ##
start_date = start,
end_date = end,

## metadata ##
metadata = meta,
metadata_ids_col = elig_study_id,

## experiment data ##
experiment_data_list = list(ab),

## set the date column name ##
calendar_date_col = calendar_date
)
#> Checking input parameters...
#> -- checking start date 01012020
#> -- checking end date 10102021
#> -- checking end date later than start date
#> -- checking metadata
#> -- checking experiment data list
#> --- checking experiment data list slot 1
#> Input checks completed
#> Chronogram assembling...
#> -- chrongram_skeleton built
#> -- chrongram built with metadata
#> -- adding experiment data
#> --- adding experiment data slot 1 cols... elig_study_id calendar_date serum_Ab_S ...

## Example 2: now with 2 types of experimental data ##-------------

## Setup as example 1, and second experimental dataset here: ##
infections_to_add <- tibble::tribble(
  ~calendar_date, ~elig_study_id, ~LFT, ~PCR, ~symptoms,
  "01102020", "1", "pos", NA, NA,
  "11102020", "1", "pos", NA, "severe"
)
## Make calendar_date a date ##
infections_to_add$calendar_date <- lubridate::dmy(
  infections_to_add$calendar_date
)

cg <- cg_assemble(
  start_date = "01012020",
  end_date = "10102021",
  metadata = smallstudy$small_study_metadata,
  metadata_ids_col = elig_study_id,
  calendar_date_col = calendar_date,
  experiment_data_list = list(ab, infections_to_add)
)
#> Checking input parameters...
#> -- checking start date 01012020
#> -- checking end date 10102021
#> -- checking end date later than start date
#> -- checking metadata
#> -- checking experiment data list
#> --- checking experiment data list slot 1
#> --- checking experiment data list slot 2
#> Input checks completed
#> Chronogram assembling...
#> -- chrongram_skeleton built
#> -- chrongram built with metadata
#> -- adding experiment data
#> --- adding experiment data slot 1 cols... elig_study_id calendar_date serum_Ab_S ...
#> --- adding experiment data slot 2 cols... calendar_date elig_study_id LFT ...
##------------------------------------------------------------------