
Build the POLIS virus (positives) dataset from cleaned cases and ES
Source:R/clean_virus.R
clean_virus.RdConstructs the combined positives/virus analytic table from the outputs of
clean_afp() and clean_es() – it does not read a raw POLIS viruses table.
Every poliovirus-positive record (classification matching WPV/VDPV –
i.e. WPV, cVDPV, aVDPV, iVDPV or untyped VDPV) becomes one row,
harmonised to a shared schema and tagged by source:
surveillance_type("human"/"environmental") and the finersource(the casesurveillance_type_name– AFP / Community / Contact – or"Environmental");measurementandclassification_all: the analytic virus label in the sharedWPV/cVDPV/aVDPV/iVDPVvocabulary both cleaners emit;the case/sample geography (
country_iso3code,adm0/adm1/adm2+ GUIDs),latitude/longitude, the eventvirus_date(paralysis onset for cases, collection for ES) withyear_onset/month_onset, andnotification_date;report_date: the VDPV classification-change date for VDPV records, the notification date for WPV records;emergence_group,nt_changes,virus_cluster,virus_is_orphan(the orphan-isolate flag,NAfor ES rows since POLIS carries it only on cases), and – when anopv_emergencereference is supplied – the novel-OPV2 flagnopv2.
Usage
clean_virus(
cases = NULL,
es = NULL,
cfg = polis_active_config(),
nopv_emergence = NULL,
separate_rows = FALSE,
verbose = TRUE
)Arguments
- cases
Optional cleaned AFP table (from
clean_afp()). Its poliovirus-positive rows become the human positives.- es
Optional cleaned ES table (from
clean_es()). Its poliovirus-positive rows become the environmental positives.- cfg
A
polis_config()object. Defaults topolis_active_config()– the config most recently built bypolis_config()this session – so a no-cfgcall inherits the active session settings rather than fresh defaults.- nopv_emergence
Optional reference of novel-OPV2 (nOPV2) emergence-group names: a character vector, or a data frame with an
emergence_groupcolumn. When supplied, records whoseemergence_groupmatches are flaggednopv2. DefaultNULL(no nOPV2 flag).- separate_rows
If
TRUE, co-detection records (a fused label such asWPV1andcVDPV 2orVDPV12and3) are split into one row per detected serotype, withmeasurement/classification_allset to the component label. DefaultFALSE(one row per positive record, co-detections kept as the fused label).- verbose
Emit cli progress messages. Default
TRUE.
Value
A tibble of poliovirus positives, one row per positive case/sample, columns ordered id -> location -> time -> classification -> dates -> other. When neither input has any positives, returns a 0-row, 0-column tibble.
Examples
cases <- clean_afp(data.frame(
Id = 1, Epid = "A-1", `Last Update Date` = "2024-03-01",
`Paralysis Onset Date` = "2024-01-02", `Notification Date` = "2024-01-09",
`Polio Virus Types` = "WILD1", Classification = "Confirmed (wild)",
`Admin0 Name` = "NIGERIA", check.names = FALSE
), verbose = FALSE)
clean_virus(cases = cases, verbose = FALSE)
#> # A tibble: 1 × 11
#> epid month_onset year_onset notification_date vtype classification_all
#> <chr> <dbl> <dbl> <date> <chr> <chr>
#> 1 A-1 1 2024 2024-01-09 WPV 1 WPV 1
#> # ℹ 5 more variables: virus_date <date>, report_date <date>,
#> # surveillance_type <chr>, measurement <chr>, source <chr>