Package 'densnv'

Title: Exploratory Analysis of the SINAVE Vector-Borne Diseases Datasets
Description: The package reads the SINAVE Vector-Borne Diseases dataset, creates graphs, maps and tables with the aim of contributing to the making of rational and timely decisions in the Cenaprece national VBD program.
Authors: Felipe Antonio Dzul Manzanilla [aut, cre] (ORCID: <https://orcid.org/0000-0002-2085-9141>), Fabián Correa-Morales [aut] (ORCID: <https://orcid.org/0000-0002-6193-1242>), Emmanuel Morales García [aut] (ORCID: <https://orcid.org/0000-0002-6837-9227>), Cecilia Cruz López [aut] (ORCID: <https://orcid.org/0000-0002-9156-5669>), Héctor Gómez-Dantés [aut] (ORCID: <https://orcid.org/0000-0002-2025-3641>)
Maintainer: Felipe Antonio Dzul Manzanilla <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-11-23 13:24:24 UTC
Source: https://github.com/fdzul/densnv

Help Index


This function counts VBD cases per agem.

Description

This function counts VBD cases per agem.

Usage

cases_by_agem(path_vbd, vbd, status_case, country, cve_edo = NULL)

Arguments

path_vbd

Is the directory where the file is located.

vbd

Is the parameter for define the vector-borne diseases

status_case

It is a numerical value to select the Status of the case. There are three options, 1 for the probable cases database, 2 for the confirmed cases database, and 3 for the discarded cases dataset.

country

It is a logical value to define if the result is by state (set TRUE) or by country (set FALSE)

cve_edo

Is a string of the state id-

Value

a sf object

Examples

1+1

Arbovirus cases by locality

Description

Reads a SINAVE vector-borne disease dataset (dengue, Zika or chikungunya), counts probable and confirmed cases by locality of report, and joins them to the INEGI 2020 locality catalogue (ITER 2020) to return one point per locality with cases.

Usage

cases_by_loc(
  path,
  snv_dataset = c("DENV", "ZIKV", "CHIKV"),
  year = NULL,
  week = NULL
)

Arguments

path

path to the SINAVE txt file (e.g. '"DENGUE2_.txt"', '"ZIKA2_.txt"' or '"CHIKUNGUNYA2_.txt"').

snv_dataset

arbovirus of the dataset: '"DENV"' (dengue), '"ZIKV"' (Zika) or '"CHIKV"' (chikungunya).

year

year to keep (ANO column). If NULL (default), the most recent year in the dataset is used.

week

epidemiological weeks to keep (SEM column), e.g. '1:10' or 'c(5, 6, 7)'. If NULL (default), all weeks are used.

Details

Only probable and confirmed cases are kept ('ESTATUS_CASO' 1 and 2); discarded cases are excluded. The locality key 'cvegeo' (9 digits) is built from the state, municipality and locality of report ('CVE_EDO_REP' + 'CVE_MPO_REP' + 'CVE_LOC_REP'). Records with missing codes ('"00"', '"000"', '"0000"') and localities not found in ITER 2020 are dropped.

Columns returned for every arbovirus:

cvegeo

INEGI locality key (state + municipality + locality).

nom_ent, nom_mun, nom_loc

names of the state, municipality and locality (ITER 2020).

probable

number of notified cases (probable + confirmed).

confirmado

number of confirmed cases.

altitud

altitude of the locality (m).

pobtot

total population of the locality (Census 2020).

geometry

point of the locality (EPSG:4326).

Additional columns for DENV:

DNG, DCSA, DG

cases by final diagnosis: non-severe dengue, dengue with warning signs and severe dengue.

DENV1, DENV2, DENV3, DENV4

cases by serotype (RT-PCR triplex).

Value

an sf object of points (EPSG:4326), one row per locality with cases.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

[rgeomex::iter_2020_loc]

Examples

## Not run: 
den  <- cases_by_loc(path = "DENGUE2_.txt",      snv_dataset = "DENV")
zik  <- cases_by_loc(path = "ZIKA2_.txt",        snv_dataset = "ZIKV")
chik <- cases_by_loc(path = "CHIKUNGUNYA2_.txt", snv_dataset = "CHIKV")

# a specific year
den25 <- cases_by_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                      year = 2025)

# epidemiological weeks 1 to 10
den_w <- cases_by_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                      week = 1:10)

mapview::mapview(den, zcol = "confirmado", cex = "probable")

## End(Not run)

Cases of dengue per week.

Description

Cases of dengue per week.

Usage

cases_week(path, mpo, year)

Arguments

path

is the path of the sinave files

mpo

is the name of municipality

year

is the year the dataset

Value

a ggplot2 object

Examples

1+1

data_geocode

Description

this function creates an address vector.

Usage

data_geocode(infile, data)

Arguments

infile

is the name of file create with subset_den.

data

is a string for define the addreses or data. if data TRUE, is return the dataset.

Value

a vector.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

Estimated cases of dengue and eggs

Description

Estimated cases of dengue and eggs

Usage

estimated_eggs(
  path_dengue,
  localidad,
  year,
  fac_axes,
  municipio,
  path_ovitraps
)

Arguments

path_dengue

It is the path of the dataset of the sinave

localidad

Its the locality target

year

is the year

fac_axes

is the factor for the dual axis

municipio

is the municipality

path_ovitraps

It is the path of the dataset of ovitrap

Value

ggplot object

Examples

1+1

geocode

Description

this function geocodes the addresses of the sinave database using Geocoding API.

Usage

geocode(infile, address)

Arguments

infile

is the name of the location that is being geocoded and is used to be saved in a file with extension rds.

address

is vector addresses.

Details

The function use the geocode of ggmap.

Value

a file with extension rds.

Note

The code for geocoding was taken from the personal page of Shane Lynn https://www.shanelynn.ie/massive-geocoding-with-r-and-google-maps/ and adapted to work with the sinave http://www.sinave.gob.mx/ database.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

geocode

Examples

1+1

mp_active_foci

Description

Identifies the active dengue transmission foci of a locality and the blocks (manzanas) to control, using a space-time window: cases within the flight range of *Aedes aegypti* ('spatial_scale') and within the intrinsic + extrinsic incubation periods ('temporal_scale').

Usage

mp_active_foci(
  geocoded_dataset,
  cve_edo,
  locality,
  status_caso = c(1, 2),
  spatial_scale = 400,
  temporal_scale = 21,
  min_cases = 3,
  buffer_m = 200,
  ref_date = NULL,
  method = c("window", "st-dbscan"),
  n_sim = 999,
  perm_days = 365,
  alpha = 0.05,
  seed = NULL,
  place = c("REP", "RES"),
  mean_si = 21,
  std_si = 6.1,
  capacity_cases = NULL,
  coverage_min = NULL,
  foci_min = 0.9,
  print_map = TRUE,
  save = FALSE,
  dir = "./"
)

Arguments

geocoded_dataset

data.table or data.frame with the geocoded cases. It must have the columns 'long', 'lat' (EPSG:4326), 'ESTATUS_CASO' and 'FEC_INI_SIGNOS_SINT' (date of onset of symptoms).

cve_edo

INEGI state code of the locality (e.g. '"31"').

locality

name of the locality, as used by [rgeomex::extract_locality()] (e.g. '"Merida"').

status_caso

case status to use: 1 probable, 2 confirmed (default 'c(1, 2)').

spatial_scale

spatial window in metres: flight range of *Aedes aegypti* (default 400).

temporal_scale

temporal window in days: intrinsic + extrinsic incubation periods (default 21).

min_cases

minimum number of cases within the space-time window to define a focus (default 3).

buffer_m

buffer for control around the transmission zone, in metres (default 200; about 100 m is one block).

ref_date

reference date ('Date' or '"YYYY-MM-DD"'). The cases with onset in the 'temporal_scale' days up to this date are used. If NULL (default), the latest date of onset in the locality is used.

method

how the foci are identified:

'"window"'

(default) fixed window: only the cases of the last 'temporal_scale' days are used, and DBSCAN is applied with neighbours within 'spatial_scale' metres. Answers "where are the foci today?".

'"st-dbscan"'

space-time DBSCAN: all the cases up to 'ref_date' are used, and two cases are neighbours if they are within 'spatial_scale' metres AND within 'temporal_scale' days. It rebuilds the transmission chains, so a focus can last several weeks. Active foci are those with at least one case in the last 'temporal_scale' days; they are classified as new (started in the window) or persistent (started before).

n_sim

number of permutations of the Knox test (default 999; 0 skips the test).

perm_days

period, in days up to 'ref_date', of the cases used by the Knox test (their dates are permuted; default 365). It is also the period used by 'method = "st-dbscan"'. Must be >= 'temporal_scale'.

alpha

significance level of the Knox test by focus, compared with the Holm-adjusted p-value (default 0.05).

seed

seed of the permutations, to reproduce the p-values (default NULL).

place

place used to select the cases of the locality for Rt with [rt_dengue()]: '"REP"' place of report (default; the cases are geocoded with it) or '"RES"' place of residence.

mean_si, std_si

mean and standard deviation (days) of the serial interval of dengue, gamma distribution, used to estimate Rt with [rt_dengue()] (default 21 and 6.1).

capacity_cases

operational capacity: number of cases per week that the brigades can work (the house of the case and the houses around it). It is local information given by the expert (default NULL, not evaluated). Used in the diagnosis to tell whether the outbreak exceeds the operational capacity (barrido vs operativo integral).

coverage_min

minimum proportion (0-1) of the locality covered by the recent cases (circles of 'spatial_scale' metres) to consider the cases dispersed over the locality. NULL (default) depends on 'temporal_scale': 0.40 with 21 days or less, 0.50 with 28 days or more, and linear in between (calibrated with 71 localities, 2026; the coverage grows with the window).

foci_min

proportion (0-1) of the recent cases in foci from which the cases are also considered dispersed over the locality, whatever the coverage (default 0.9; safeguard for large cities, where the coverage is low even when the transmission covers the whole urban area).

print_map

logical. If TRUE (default) the map is printed; FALSE is useful in loops over several localities or dates (the map is still returned in 'map').

save

logical. If TRUE the selected blocks are saved as a GeoPackage in 'dir' (default FALSE).

dir

directory where the blocks are saved (with "/" at the end).

Details

The foci are identified with the DBSCAN criterion:

  1. Temporal window: the window is the 'temporal_scale' days up to 'ref_date' (both included). With 'method = "window"' only these cases are used; with 'method = "st-dbscan"' all the cases up to 'ref_date' are used and the time difference is part of the neighbourhood.

  2. Spatial window: a case is a *core* case if there are at least 'min_cases' neighbours (itself included) within 'spatial_scale' metres (and within 'temporal_scale' days with ST-DBSCAN). Neighbouring core cases belong to the same focus, and non-core neighbours of a core case join that focus.

  3. Transmission zone: union of circles of 'spatial_scale' metres around the cases of each focus in the window.

  4. Control zone: transmission zone plus 'buffer_m' metres. The blocks that intersect the control zone are selected.

Knox test (space-time interaction; Knox 1964): the Knox statistic is the number of pairs of cases of the last 'perm_days' days that are within 'spatial_scale' metres and within 'temporal_scale' days of each other, the same space-time window that defines the foci (and the same statistic as 'denhotspots::knox_test()'). Its null distribution is obtained by permutation: the locations stay fixed (so the spatial distribution of the population is respected) and the dates of onset are permuted at random (so the epidemic curve is respected). p-value = (1 + permutations with as many pairs or more) / ('n_sim' + 1); RR = observed pairs / mean of the permuted pairs.

  1. Global test: all the pairs of the period. It answers whether the cases of the locality are closer in space and time than expected by chance. It is a formal test.

  2. Test by focus: only the pairs with both cases inside the transmission zone of the focus, with the dates permuted among all the cases of the period; p-values adjusted with Holm ('p_holm'). The foci were selected because their cases are close in space and time, so these p-values are optimistic: use them to rank and prioritise the foci, not as a formal test.

Unlike the size of the largest focus, the number of pairs does not percolate: in a dense city the permuted dates do not join more cases into the same pairs.

Diagnosis of the epidemiological scenario ('diagnostico'). Following dengue outbreak experts, transmission becomes generalised with:

  1. A sustained and significant increase of the outbreak: the cases of the current window are significantly above the mean per window of 'temporal_scale' days of the period (Poisson test, p < 'alpha'), the previous window is also above that mean and the effective reproductive number of the current window is above 1 (Rt with [rt_dengue()]: all the cases reported in the locality, 'place', geocoded or not; parametric serial interval with 'mean_si' and 'std_si'; Cori et al. 2013). Rt is ignored if it cannot be estimated.

  2. Cases that exceed the operational capacity: the cases per week of the current window (all the cases, probable and confirmed) are more than 'capacity_cases'.

  3. Cases dispersed over the locality: the area within 'spatial_scale' metres of the recent cases covers 'coverage_min' or more of the locality, or 'foci_min' or more of the recent cases are in foci.

The phase of the outbreak is given by the 95% credible interval of Rt: "En ascenso" (lower limit > 1), "En descenso" (upper limit < 1) or "Estable".

Scenarios (rules of thumb calibrated with 71 localities, 2026):

  1. Insufficient cases: fewer than 50 cases in the period.

  2. Generalised transmission: criterion 1 and (2 or 3). Strategy: barrido; operativo integral (megaoperativo) if the blocks exceed the operational capacity.

  3. No active foci. Strategy: entomological surveillance and control around the cases.

  4. Focalised transmission: 50% or more of the recent cases in foci. Strategy: focalised control, prioritising the significant foci.

  5. Focalised transmission with dispersed cases: fewer than 50% of the recent cases in foci. Strategy: focalised control and control around the isolated cases.

With criterion 1 and Rt in ascent ("En ascenso") but without generalised transmission, the action starts with an early warning (alerta temprana). The space-time interaction (Knox) is reported as "Sí" (p < 'alpha'), "No concluyente" (RR > 1.05) or "No". The strategies summarise the "Resumen de Estrategias Operativas" (focalizado, barrido, operativo integral). Areas are clipped to the locality.

DBSCAN is run with the dbscan package (Hahsler, Piekenbrock and Doran 2019): [dbscan::frNN()] finds the neighbours within 'spatial_scale' metres and, with ST-DBSCAN, the neighbours further than 'temporal_scale' days are removed before [dbscan::dbscan()] is applied with 'minPts = min_cases'. Distances are computed in metres (EPSG:6372, Mexico ITRF2008 / LCC). Blocks come from 'rgeomex::blocks_ine20_mx_*' (INE 2020). The map opens with the Positron style (OpenFreeMap); a collapsible layers control turns on and off the basemaps (Esri Dark Gray, Esri Light Gray, OpenStreetMap, World Imagery, OpenTopoMap) and the zones, blocks and cases. The transmission zone of each focus is coloured by its Knox test: red, significant (Holm p-value < 'alpha'); yellow, excess of pairs not significant (RR > 1); grey, no excess (RR <= 1). With 'n_sim = 0' all the zones are red.

Value

a list (invisibly) with:

map

interactive map (mapgl), also printed.

foci

sf with one row per active focus: type (new/persistent), cases, recent cases (in the window), confirmed cases, Knox pairs, expected pairs and RR, p-value, Holm p-value and significance, first and last onset, duration (days), transmission and control areas (km2) and number of blocks; geometry = control zone.

transmission

sf with the transmission zone of each focus.

blocks

sf with the blocks to control and their focus.

cases

sf with the cases of the window (and, with ST-DBSCAN, the previous cases of the active foci), their focus (NA if isolated) and group.

knox

global Knox test: list with the number of permutations ('n_sim'), the period ('periodo'), the number of cases ('n_casos'), the pairs within 'spatial_scale' ('pares_espacio'), the Knox statistic ('knox'), the expected pairs ('esperados'), 'rr', 'p_value' and the Knox statistic of each permutation ('sim'); NULL if 'n_sim = 0'.

diagnostico

diagnosis of the epidemiological scenario: one-row summary ('tabla', to bind several localities), scenario ('escenario'), operational strategy ('accion'), detail of the criteria ('detalle', also printed), Rt by weekly sliding windows ('rt', object of [EpiEstim::estimate_R()]) and its plot ('rt_plot'), cases by window of 'temporal_scale' days ('casos_ventana', the first is the current window), cases by month ('casos_mes'), proportion of the pairs of cases within 'temporal_scale' days ('pct_pares_tiempo'), coverage of the locality by the recent cases ('cobertura_casos'), recent cases in foci ('pct_casos_en_focos') and area of the transmission zones ('pct_area_transmision').

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

References

Cori A, Ferguson NM, Fraser C, Cauchemez S (2013). A new framework and software to estimate time-varying reproduction numbers during epidemics. *American Journal of Epidemiology*, 178(9), 1505-1512.

Knox EG (1964). The detection of space-time interactions. *Journal of the Royal Statistical Society, Series C*, 13(1), 25-30.

Kulldorff M, Hjalmars U (1999). The Knox method and other tests for space-time interaction. *Biometrics*, 55(2), 544-552.

Hahsler M, Piekenbrock M, Doran D (2019). dbscan: Fast Density-Based Clustering with R. *Journal of Statistical Software*, 91(1), 1-30. doi:10.18637/jss.v091.i01

See Also

[rt_dengue()], [mp_heatmap_gl()], [dbscan::dbscan()]

Examples

## Not run: 
res <- mp_active_foci(geocoded_dataset = z,
                      cve_edo = "31",
                      locality = "Merida",
                      status_caso = c(1, 2),
                      spatial_scale = 400,
                      temporal_scale = 21,
                      min_cases = 3,
                      buffer_m = 200,
                      ref_date = NULL,
                      method = "window",
                      n_sim = 999,
                      perm_days = 365,
                      alpha = 0.05,
                      seed = 123,
                      place = "REP",
                      mean_si = 21,
                      std_si = 6.1,
                      capacity_cases = NULL,
                      coverage_min = NULL,
                      foci_min = 0.9,
                      print_map = TRUE,
                      save = FALSE,
                      dir = "./")
res$foci      # summary of the foci
res$blocks    # blocks to control
res$knox      # global Knox test
hist(res$knox$sim)                      # null distribution of the pairs
abline(v = res$knox$knox, col = "red")  # observed pairs
res$diagnostico$tabla       # scenario, criteria and action
res$diagnostico$casos_mes   # cases by month of the period

# space-time DBSCAN: transmission chains, new and persistent foci
res_st <- mp_active_foci(geocoded_dataset = z,
                         cve_edo = "31",
                         locality = "Merida",
                         status_caso = c(1, 2),
                         spatial_scale = 400,
                         temporal_scale = 21,
                         min_cases = 3,
                         buffer_m = 200,
                         ref_date = NULL,
                         method = "st-dbscan",
                         n_sim = 999,
                         perm_days = 365,
                         alpha = 0.05,
                         seed = 123,
                         place = "REP",
                         mean_si = 21,
                         std_si = 6.1,
                         capacity_cases = NULL,
                         coverage_min = NULL,
                         foci_min = 0.9,
                         print_map = TRUE,
                         save = FALSE,
                         dir = "./")

## End(Not run)

mp_animated_loc

Description

Animated map of arbovirus cases by locality and epidemiological week.

Usage

mp_animated_loc(
  path,
  snv_dataset = c("DENV", "ZIKV", "CHIKV"),
  year = NULL,
  week = NULL,
  var = "probable",
  multi = c("sum", "facet"),
  ncol = NA,
  country = TRUE,
  cve_edo = NULL,
  breaks = NULL,
  pal = "-viridis",
  text_size = 0.4,
  fps = 2,
  save = FALSE,
  name = NULL,
  dir = "./",
  width = NULL,
  height = NULL,
  size_range = c(2.5, 14),
  strip_size = 18,
  curve = TRUE,
  map_legend = TRUE,
  legend_title = "Casos por localidad"
)

Arguments

path

path to the SINAVE txt file (e.g. '"DENGUE2_.txt"', '"ZIKA2_.txt"' or '"CHIKUNGUNYA2_.txt"').

snv_dataset

arbovirus of the dataset: '"DENV"' (dengue), '"ZIKV"' (Zika) or '"CHIKV"' (chikungunya).

year

year of the dataset (ANO column). If NULL (default), the most recent year in the dataset is used.

week

epidemiological weeks to animate (SEM column), e.g. '1:52'. If NULL (default), all weeks are used.

var

one or more types of cases to map: '"probable"' (probable + confirmed, default), '"confirmado"' (confirmed). Only for 'snv_dataset = "DENV"': '"DNG"' (non-severe dengue), '"DCSA"' (dengue with warning signs), '"DG"' (severe dengue), '"DENV1"', '"DENV2"', '"DENV3"' or '"DENV4"' (serotype, RT-PCR triplex). With more than one value, 'multi' defines how they are combined.

multi

how to combine several values of 'var': '"sum"' (default) counts together the cases of any of them in one map (e.g. 'var = c("DCSA", "DG")'); '"facet"' draws one panel per value in every frame (e.g. 'var = c("DENV1", "DENV2", "DENV3", "DENV4")').

ncol

number of columns of panels when 'multi = "facet"' (default NA, automatic).

country

logical. TRUE (default) = whole country with state boundaries; FALSE = the state given in 'cve_edo' with municipal boundaries.

cve_edo

INEGI state code ("20" or 20). Required if 'country = FALSE'.

breaks

numeric, step between the breaks of the legend and of the colour and size scales (e.g. 'breaks = 5' gives 1, 6, 11, ...). If NULL (default), 5 integer breaks from 1 to the maximum number of cases are used (e.g. 1, 6, 12, 18, 23). With '"quantile"', the quartiles of the cases by locality and week are used (minimum, Q1, median, Q3 and maximum); repeated values are dropped, so there may be fewer than 5 breaks when most localities have 1 or 2 cases.

pal

colour palette of the bubbles (default '"-viridis"'; the minus sign reverses it so that more cases are darker).

text_size

size of the number of cases inside the bubbles (default 0.4; use 0 to hide it).

fps

frames (weeks) per second (default 2).

save

logical. If TRUE the gif is saved in 'dir'; if FALSE (default) the animation is only shown.

name

name of the gif file (without extension); '"_loc_animated_map.gif"' is added at the end.

dir

directory where the gif is saved (with "/" at the end).

width, height

size of the gif in pixels. 'height' defaults to 2000 (1600 without the curve); 'width' is computed from the number of panels, 'ncol' and the shape of the map, so the curve has the same width as the maps.

size_range

minimum and maximum size of the bubbles (default 'c(2.5, 14)').

strip_size

text size of the panel titles (default 18). Each title shows the category and its cases of the week.

curve

logical. Add below the maps a line chart of the weekly cases of each category, with the current week marked (default TRUE).

map_legend

logical. Show the legend of the bubbles (size and colour by number of cases) below the maps (default TRUE).

legend_title

title of the bubble legend (default '"Casos por localidad"').

Details

Reads the SINAVE dataset (same processing as [cases_by_loc()]), counts the cases by locality and epidemiological week and builds an animated map (one frame per week) following the workflow of [mp_animated()]. For the whole country the state boundaries are drawn; for a state, its municipal boundaries.

Only probable and confirmed cases ('ESTATUS_CASO' 1 and 2) are used, counted by locality of report ('CVE_EDO_REP' + 'CVE_MPO_REP' + 'CVE_LOC_REP') and joined to the INEGI 2020 localities ('rgeomex::iter_2020_loc'). Colour and size scales are the same in every frame and in every panel, so they can be compared. With 'multi = "facet"', a case can appear in more than one panel (e.g. a confirmed DENV2 case in '"confirmado"' and in '"DENV2"'). Each frame is a ggplot2 figure (one panel per value of 'var' with 'multi = "facet"', or a single panel) with the week in the title, and the frames are joined with gifski; the gif is shown in the RStudio Viewer (and saved in 'dir' if 'save = TRUE'). Saving the gif needs the gifski package.

Value

a gif file of animation (with 'multi = "facet"', the path of the gif, invisibly).

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

[mp_animated()], [cases_by_loc()]

Examples

## Not run: 
# whole country, with state boundaries
mp_animated_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                year = 2026, week = 1:52,
                save = TRUE, name = "dengue_mexico_2026", dir = "./")

# Oaxaca, confirmed cases, with municipal boundaries
mp_animated_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                year = 2026, week = 1:52, var = "confirmado",
                country = FALSE, cve_edo = "20",
                save = TRUE, name = "dengue_oaxaca_2026", dir = "./")

# severe forms together (DCSA + DG) in one map
mp_animated_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                year = 2026, week = 1:52,
                var = c("DCSA", "DG"), multi = "sum",
                save = TRUE, name = "dcsa_dg_mexico_2026", dir = "./")

# one panel per serotype
mp_animated_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                year = 2026, week = 1:52,
                var = c("DENV1", "DENV2", "DENV3", "DENV4"),
                multi = "facet", ncol = 2,
                save = TRUE, name = "serotipos_mexico_2026", dir = "./")

## End(Not run)

mp_animated_mpo

Description

Animated map of confirmed dengue cases by municipality and epidemiological week, for the whole country or for one state.

Usage

mp_animated_mpo(
  data,
  year,
  name,
  dir,
  country,
  breaks = NULL,
  save,
  cve_edo = NULL,
  text_size,
  dot = NULL,
  pal = NULL
)

Arguments

data

SINAVE dengue dataset (e.g. read with 'data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)').

year

year to map (ANO column).

name

name of the gif file (without extension); '"_dot_animated_map.gif"' or '"_areal_animated_map.gif"' is added.

dir

directory where the animation is saved (with "/" at the end).

country

logical. TRUE = all the municipalities of Mexico; FALSE = the municipalities of the state given in 'cve_edo'.

breaks

numeric, step between the breaks of the legend (e.g. 5 gives 1, 6, 11, ...). If NULL, about 5 breaks are computed.

save

logical. If TRUE the gif is saved in 'dir'; if FALSE it is only shown.

cve_edo

INEGI state code ("20" or 20). Required if 'country = FALSE'. See INEGI.

text_size

size of the number of cases in each municipality.

dot

logical. TRUE = proportional bubbles; FALSE = areal (choropleth) map.

pal

palette function for the areal map (e.g. 'viridis::viridis').

Details

Confirmed cases ('ESTATUS_CASO' 2) with final diagnosis DNG, DCSA or DG are counted by municipality of residence and epidemiological week. The animation is built with [tmap::tm_animate()] and saved with [tmap::tmap_animation()] (needs the gifski package).

Value

a gif file of animation.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

[tmap::tmap_animation()], [mp_animated_loc()]

Examples

## Not run: 
dataset <- data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)

# Oaxaca, bubbles
mp_animated_mpo(data = dataset,
                year = 2026,
                name = "Oaxaca",
                dir = "6.Maps/",
                country = FALSE,
                breaks = 1,
                save = FALSE,
                cve_edo = "20",
                text_size = 0.3,
                dot = TRUE,
                pal = viridis::viridis)

## End(Not run)

Static Bump Map

Description

Creates a map with sigmoid curves linking each state (or municipality) to a side ranking of the number of dengue cases (DNG, DWS and SD).

Usage

mp_bumpmap(
  dataset,
  year,
  state = TRUE,
  pal_vir = "viridis",
  cve_edo = NULL,
  axis_start = NULL,
  country_text_x = NULL,
  country_text_y = NULL,
  size_text_value = 2,
  size_text_country = 2,
  line_size = 1,
  value_text = NULL,
  label_spacing = NULL,
  top_n = NULL,
  label_line = 1.6,
  label_width = 0.4,
  smooth = 10
)

Arguments

dataset

data.frame with the SINAVE dengue dataset.

year

year to plot (ANO column).

state

logical. TRUE = national map by state; FALSE = municipalities of the state given in 'cve_edo'.

pal_vir

viridis palette option ("viridis", "magma", "inferno", "plasma", "cividis", "turbo", ...).

cve_edo

two-digit INEGI state code (e.g. "14"). Only used when 'state = FALSE'.

axis_start

distance (in degrees) between the map edge and the end of the curves. Defaults to 5 with 'state = TRUE' and 0.5 with 'state = FALSE'.

country_text_x

leftward offset of the name. With 'state = FALSE' it is measured from the end of the straight segment (default 0.02).

country_text_y

vertical offset of the name. With 'state = FALSE' it is the height of the text above its line (default 0.005).

size_text_value

text size of the number of cases.

size_text_country

text size of the name.

line_size

width of the sigmoid curves.

value_text

with 'state = FALSE', gap (in degrees) between the end of the straight segment and the number of cases (default 0.05).

label_spacing

'state = FALSE' only: vertical spacing (in degrees) between ranking rows. If NULL, the rows are spread over the height of the state. Increase it (e.g. 0.04 - 0.08) if names overlap.

top_n

'state = FALSE' only: number of municipalities with the most cases to show in the ranking. NULL = all.

label_line

'state = FALSE' only: length (in degrees) of the straight segment that follows each curve; the municipality name is written on it. Increase it if long names extend past the segment (default 1.6).

label_width

'state = FALSE' only: space (in degrees) reserved to the right of the number of cases so it is not clipped.

smooth

smoothness of the sigmoid curves.

Value

a ggplot object.

Examples

## Not run: 
dataset <- data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)
static_bump_map(dataset = dataset, year = 2026, state = TRUE,
                size_text_value = 2, size_text_country = 2,
                country_text_x = 0.5, country_text_y = 0.8,
                line_size = 1.5, pal_vir = "viridis")
static_bump_map(dataset = dataset, year = 2026, state = FALSE,
                cve_edo = "14", label_spacing = 0.05,
                size_text_value = 2, size_text_country = 2,
                line_size = 0.6, pal_vir = "turbo")

## End(Not run)

Interactive map of cases by locality

Description

Leaflet map with proportional circles of arbovirus cases by locality, state and municipal boundaries, and a panel with the localities with the most cases. Clicking a row of the panel zooms the map to that locality.

Usage

mp_cases_loc(
  data,
  var = "probable",
  top_n = 10,
  title = "Casos Probables",
  palette = "D",
  r_min = 4,
  r_max = 20,
  cve_edo = NULL,
  mun_boundaries = TRUE,
  edo_boundaries = TRUE,
  table_position = "topright"
)

Arguments

data

sf object returned by [cases_by_loc()]. To map specific epidemiological weeks, filter them there with its 'week' argument (e.g. 'cases_by_loc(..., week = 1:10)').

var

name of the column to map (default '"probable"'; also '"confirmado"', '"DNG"', '"DCSA"', '"DG"', '"DENV1"', ...).

top_n

number of localities shown in the panel (default 10). With more than 20, the panel shows 20 rows and a scroll bar.

title

title of the legend and the panel (default '"Casos Probables"').

palette

viridis option for the circles (default '"D"').

r_min, r_max

minimum and maximum radius of the circles in pixels.

cve_edo

INEGI state code ("14" or 14). If NULL (default), the whole country is mapped.

mun_boundaries

logical. Draw the municipal boundaries ('rgeomex::AGEM_inegi19_mx'). Default TRUE.

edo_boundaries

logical. Draw the state boundaries ('rgeomex::AGEE_inegi19_mx'). Default TRUE.

table_position

position of the panel: '"topright"' (default), '"topleft"', '"bottomleft"' or '"bottomright"'.

Details

Boundaries are drawn below the circles and can be turned on and off from the layers control. Hovering over a municipality shows its name. The home button returns to the state (if 'cve_edo' is given) or to Mexico.

Value

a leaflet htmlwidget.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

## Not run: 
den <- cases_by_loc(path = "DENGUE2_.txt", snv_dataset = "DENV")
mp_cases_loc(den)

# Oaxaca, weeks 1 to 10, confirmed cases
den_w <- cases_by_loc(path = "DENGUE2_.txt", snv_dataset = "DENV",
                      week = 1:10)
mp_cases_loc(den_w, var = "confirmado", title = "Casos Confirmados",
             cve_edo = "20", top_n = 15)

## End(Not run)

The mp_heatmap function generates a heat map.

Description

The mp_heatmap function generates a heat map.

Usage

mp_heatmap(
  locality,
  cve_edo,
  geocoded_dataset,
  status_caso,
  week,
  kernel,
  alpha,
  zoom,
  map_type,
  static,
  palette = NULL,
  save
)

Arguments

locality

is the locality locality target.

cve_edo

is a string of the state id.

geocoded_dataset

is geocoded dataset.

status_caso

It is a numerical value to select the Status of the case. There are three options, 1 for the probable cases database, 2 for the confirmed cases database, and 3 for the discarded cases database.

week

It is epidemiological week.

kernel

It is kernel density for select the blocks.

alpha

is a numerical parameter that controls the transparency of the heatmap. Values range from 0 to 1, where 0 is completely transparent and 1 does not make the heat map transparent.

zoom

map zoom; an integer from 3 (continent) to 21 (building), default value 10 (city).

map_type

character string providing google map theme. options available are "terrain", "satellite", "roadmap", and "hybrid"

static

is a logical value, if static == TRUE the map is static, else (statis = FALSE) the maps is interactive.

palette

is the palette for kde. example palette = viridis::turbo.

save

is a logical value, if value == TRUE, the funcion save the blocks.

Value

ggplot object

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

The mp_heatmap_edo function generates a heatmap by state.

Description

The mp_heatmap_edo function generates a heatmap by state.

Usage

mp_heatmap_edo(cve_edo, geocoded_dataset, week, kernel, alpha, palette)

Arguments

cve_edo

is a string of the state id.

geocoded_dataset

is geocoded dataset.

week

It is epidemiological week.

kernel

It is kernel density for select the blocks.

alpha

is a numerical parameter that controls the transparency of the heatmap. Values range from 0 to 1, where 0 is completely transparent and 1 does not make the heat map transparent.

palette

is the palette for kde. example palette = viridis::turbo.

Value

ggplot object

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

This function creates maps of serotypes by municipality.

Description

This function creates maps of serotypes by municipality.

Usage

mp_serotype(path_sinave, cve_edo, palette)

Arguments

path_sinave

is the directory where the files are located.

cve_edo

is the id of state.

palette

is is the color palette.

Value

a mapview objetc

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

plt_heatmap

Description

Interactive heatmap (plotly) of the dengue cases by municipality and epidemiological week of a state.

Usage

plt_heatmap(dataset, state, year, status, hospitalizados)

Arguments

dataset

is the dataset of SINAVE.

state

is the name of state ('DES_EDO_REP', e.g. "GUERRERO").

year

is the year of dataset.

status

Represent the status case with three option: 1 = probable, 2 = confirmed, and 3 discarted.

hospitalizados

is logical value, if true the dengue cases is hospitalized else non-hospitalized

Value

a plotly heatmap: municipalities (rows) by epidemiological week (columns), coloured by the number of cases.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

## Not run: 
dataset <- data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)
plt_heatmap(dataset = dataset,
            state = "GUERRERO",
            year = 2026,
            status = 2,
            hospitalizados = FALSE)

## End(Not run)

Age-sex pyramid of confirmed dengue cases

Description

Builds a population pyramid of confirmed dengue cases from the SINAVE dataset, with males on the left, females on the right and the age groups in the centre. Each side is headed by a Font Awesome icon and the total number of cases by sex, which act as the legend.

Usage

plt_pyramid(
  data,
  col_male = "#0072B2",
  col_female = "#CC79A7",
  gap = 0.18,
  size_age = 3.5,
  size_count = 3,
  icon_male = "person",
  icon_female = "person-dress",
  show_zero = FALSE,
  title = NULL,
  subtitle = NULL,
  caption = "Fuente: SINAVE/DGE, Secretaría de Salud."
)

Arguments

data

data.frame with the SINAVE dengue dataset. It must contain the columns 'ESTATUS_CASO', 'IDE_SEX', 'IDE_EDA_ANO', 'CVE_EDO_REP' and 'CVE_MPO_REP' (names are standardised with [janitor::clean_names()]). Only confirmed cases ('ESTATUS_CASO == 2') are used.

col_male

colour for males (default '"#0072B2"', Okabe-Ito blue).

col_female

colour for females (default '"#CC79A7"', Okabe-Ito reddish purple).

gap

width of the central space for the age labels, as a proportion of the largest count (default 0.18). Increase it if the labels look crowded.

size_age

text size of the age-group labels (default 3.5).

size_count

text size of the number of cases (default 3).

icon_male, icon_female

names of free Font Awesome icons drawn above each side (default '"person"' and '"person-dress"'; other options are '"mars"'/'"venus"' or '"child"'/'"child-dress"'). See <https://fontawesome.com/search?ic=free>.

show_zero

logical. If TRUE, age groups without cases are labelled with 0 (default FALSE).

title, subtitle

plot title and subtitle (default NULL, none).

caption

plot caption (default cites SINAVE/DGE).

Details

Ages are grouped into 15 classes: '<1', '1-4', '5-9', ..., '60-64' and '65+' (intervals are closed on the left). Age groups without cases are kept with a count of 0, so the pyramid never has gaps. The number of cases is printed inside each bar when it fits and outside otherwise. The x axis shows absolute counts on both sides.

Icons are rendered from SVG with fontawesome and rsvg, so no system font is required and they are kept when saving with [ggplot2::ggsave()].

Value

a ggplot object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

[fontawesome::fa()]

Examples

## Not run: 
x <- data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)

plt_pyramid(data = x,
            title = "Casos confirmados de dengue por grupo de edad y sexo",
            subtitle = "Jalisco, 2026")

# other colours and icons
plt_pyramid(data = x,
            col_male = "#1B9E77", col_female = "#D95F02",
            icon_male = "mars", icon_female = "venus",
            show_zero = TRUE)

ggplot2::ggsave("pyramid.png", width = 8, height = 7, dpi = 300)

## End(Not run)

Plot the dengue cases by state/mpo and serotype

Description

Plot the dengue cases by state/mpo and serotype

Usage

plt_serotype(
  data,
  year,
  scale_serotype,
  x_serotype,
  y_serotype,
  cve_edo = NULL
)

Arguments

data

is the dataset of http://vectores.sinave.gob.mx/.

year

is the year of dataset.

scale_serotype

is the scale of the dengue serotype plot.

x_serotype

The x location of the dengue serotype plot. Sea also cowplot::draw_plot?.

y_serotype

The y location of the dengue serotype plot. Sea also cowplot::draw_plot?.

cve_edo

The id of state, values from 01 to 32.

Value

a plot of class ggplot.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

draw_plot and ggdraw.

Examples

1+1

Treemap of dengue cases

Description

Treemap of dengue cases

Usage

plt_treemap(snv_dataset, country, cve_edo = NULL, year)

Arguments

snv_dataset

is the sinave dataset

country

It is a logical value to indicate whether the data of the SINAVE is from the country (TRUE) or from a specific state (FALSE)

cve_edo

is the state id of INEGI.

year

is the year dataset.

Value

a ggplot objest

Examples

1+1

The read function reads the dataset of sinave vector-borne diseases.

Description

The read function reads the dataset of sinave vector-borne diseases.

Usage

read(path, vbd, complete)

Arguments

path

is the directory where the files are located.

vbd

is the parameter for define the vector-borne diseases.

complete

is a logical value for define the group of vector-borne diseases, if is TRUE, the define DENV, CHIKV & ZIKV, else for other etvs.

Value

a dataframe

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

read_dengue_dataset

Description

Read the dengue dataset of [SINAVE](https://www.sinave.gob.mx/)

Usage

read_dengue_dataset(
  path,
  spatial_resolution,
  status_caso,
  des_edo_res = NULL,
  des_mpo_res = NULL
)

Arguments

path

is the path of dengue dataset.

spatial_resolution

is the spatial resolution or the administrative level. The values are country, state and municipality.

status_caso

1 probable, 2 confirmado, & 3 descartado.

des_edo_res

is a string for define the state in uppercase.

des_mpo_res

is a string for define the municipality in uppercase.

Value

a data.table object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

## Not run: 
read_dengue_dataset(path = "DENGUE2_.txt",
                    spatial_resolution = "state",
                    des_edo_res = "NUEVO LEON",
                    status_caso = c(1, 2))

## End(Not run)

rt_dengue

Description

Effective reproductive number (Rt) of dengue for the country, a state, a municipality or a locality, with the daily incidence of the SINAVE cases and a parametric serial interval ([EpiEstim::estimate_R()]).

Usage

rt_dengue(
  dataset,
  level = c("country", "state", "municipality", "locality"),
  place = c("REP", "RES"),
  cve_edo = NULL,
  cve_mpo = NULL,
  cve_loc = NULL,
  status_caso = c(1, 2),
  ref_date = NULL,
  period_days = 365,
  window_days = 21,
  mean_si = 21,
  std_si = 6.1,
  plot = TRUE
)

Arguments

dataset

SINAVE dengue dataset (data.table or data.frame, e.g. read with 'data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)'). It needs 'FEC_INI_SIGNOS_SINT', 'ESTATUS_CASO' and, depending on 'level' and 'place', 'CVE_EDO_*', 'CVE_MPO_*' and 'CVE_LOC_*' ('DES_*' give the name of the area).

level

level of analysis: '"country"', '"state"', '"municipality"' or '"locality"'.

place

place used to select the cases: '"REP"' place of report (default; the cases are geocoded with it) or '"RES"' place of residence.

cve_edo

INEGI state code (e.g. '"31"' or 31). Required for '"state"', '"municipality"' and '"locality"'.

cve_mpo

INEGI municipality code (e.g. '"050"' or 50). Required for '"municipality"' and '"locality"'.

cve_loc

INEGI locality code (e.g. '"0001"' or 1). Required for '"locality"'. 'cve_mpo' and 'cve_loc' can be vectors of the same length (pairs municipality-locality).

status_caso

case status: 1 probable, 2 confirmed (default 'c(1, 2)').

ref_date

reference date ('Date' or '"YYYY-MM-DD"'); NULL (default) uses the latest date of onset of the selected cases.

period_days

days, up to 'ref_date', of the daily incidence used to estimate Rt (default 365).

window_days

days, up to 'ref_date', of the window whose Rt gives the phase of the outbreak (default 21).

mean_si, std_si

mean and standard deviation (days) of the serial interval, gamma distribution (default 21 and 6.1).

plot

logical. If TRUE (default) the Rt curve is printed.

Details

By default the area is selected with the place of report of the case ('place = "REP"'), not the place of residence ('"RES"'): in non-endemic areas (e.g. Mexico City) the positive cases are reported in the place where they were exposed, so the place of report is the place of transmission. In endemic areas both give almost the same cases.

Rt is estimated with [EpiEstim::estimate_R()] (Cori et al. 2013), method '"parametric_si"', on weekly sliding windows with at least 10 cases (curve; with fewer cases the estimate reflects the prior) that start at least 'mean_si' + 2 'std_si' days after the first date of onset of the dataset or of the period, whichever is later (before it the infectiousness of the previous cases is unknown and Rt is overestimated), and on the window of 'window_days' days up to 'ref_date'. The phase of the outbreak is given by the 95% credible interval of the Rt of that window: "En ascenso" (lower limit > 1), "En descenso" (upper limit < 1) or "Estable". The last days are usually incomplete (delay of report), which lowers Rt at the end.

Value

a list (invisibly) with:

rt

object of [EpiEstim::estimate_R()], weekly sliding windows with at least 10 cases; NULL if it cannot be estimated.

rt_ventana

data.frame with the window ('inicio', 'fin'), Rt ('rt'), its 95% credible interval ('rt_inf', 'rt_sup') and the phase ('fase').

incidencia

data.frame with the daily incidence ('dates', 'I').

area

name of the area.

plot

ggplot of the Rt curve (NULL if Rt was not estimated).

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

References

Cori A, Ferguson NM, Fraser C, Cauchemez S (2013). A new framework and software to estimate time-varying reproduction numbers during epidemics. *American Journal of Epidemiology*, 178(9), 1505-1512.

See Also

[EpiEstim::estimate_R()], [mp_active_foci()]

Examples

## Not run: 
dataset <- data.table::fread("DENGUE2_.txt", quote = "", fill = TRUE)

# Mexico
rt_mx <- rt_dengue(dataset = dataset,
                   level = "country",
                   place = "REP",
                   cve_edo = NULL,
                   cve_mpo = NULL,
                   cve_loc = NULL,
                   status_caso = c(1, 2),
                   ref_date = NULL,
                   period_days = 365,
                   window_days = 21,
                   mean_si = 21,
                   std_si = 6.1,
                   plot = TRUE)
rt_mx$rt_ventana

# Acapulco de Juarez (Guerrero), locality 0001 of the municipality 001
rt_aca <- rt_dengue(dataset = dataset,
                    level = "locality",
                    place = "REP",
                    cve_edo = "12",
                    cve_mpo = "001",
                    cve_loc = "0001",
                    status_caso = c(1, 2),
                    ref_date = NULL,
                    period_days = 365,
                    window_days = 21,
                    mean_si = 21,
                    std_si = 6.1,
                    plot = TRUE)

## End(Not run)

save_geocode

Description

save_geocode

Usage

save_geocode(geocode, data, directory, infile)

Arguments

geocode

It is the geocoded dataset.

data

is the dataset

directory

This is the folder where the dataset will be saved.

infile

is the name of the dataset file

Value

a RData object

Examples

1+1

tb_conf

Description

Generates a table of the cases confirmed by institution or age groups

Usage

tb_conf(data, inst, year, state)

Arguments

data

is the sinave dataset.

inst

is the parameter for define the type of table. If the inst is TRUE the table is by institution, else by age group.

year

is the current year.

state

is the name state.

@author Felipe Antonio Dzul Manzanilla [email protected]

Value

a formattable object.

Examples

1+1