Skip to content

Reference

Read the SINAVE datasets of a vector-borne disease.

Parameters:

Name Type Description Default
path str or Path

Folder with the SINAVE txt files.

required
vbd str

Text that identifies the files of the disease, e.g. "DENGUE".

required
complete bool

True keeps all the columns; False keeps the columns of the arboviruses (see ARBO_COLUMNS).

True

Returns:

Type Description
DataFrame

Read one SINAVE txt file.

Parameters:

Name Type Description Default
path str or Path

The SINAVE txt file (e.g. "DENGUE2_.txt").

required
columns list of str

Columns to keep. All the columns by default.

None
encoding str

Encoding of the file; SINAVE files are Latin-1.

'latin-1'

Returns:

Type Description
DataFrame

One row per case. The geographic keys (CVE_EDO_*, CVE_MPO_*, CVE_LOC_*) are zero-padded text; ESTATUS_CASO, ANO, SEM, MANEJO and DENGUE_SER_TRIPLEX are integers; the dates are datetimes.

Read the dengue dataset of SINAVE for the country, a state or a municipality.

Parameters:

Name Type Description Default
path str or Path

The dengue txt file ("DENGUE2_.txt").

required
spatial_resolution ('country', 'state', 'municipality')
"country"
status_caso int or list of int

1 probable, 2 confirmed, 3 discarded.

(1, 2)
des_edo_res str or list of str

State(s) of residence in uppercase, as in SINAVE ("NUEVO LEON").

None
des_mpo_res str or list of str

Municipality(ies) of residence in uppercase.

None

Returns:

Type Description
DataFrame

The cases of residence in Mexico (foreign residences removed).

Cases by municipality (AGEM) of report.

Parameters:

Name Type Description Default
path_vbd str or Path

Folder with the SINAVE txt files.

required
vbd str

Text that identifies the files of the disease, e.g. "DENGUE".

required
status_case int or list of int

1 probable, 2 confirmed, 3 discarded.

(1, 2)
country bool

True returns all the municipalities of Mexico; False only those of cve_edo.

True
cve_edo str or list of str

INEGI state key(s), used when country=False.

None

Returns:

Type Description
GeoDataFrame

The municipalities (INEGI 2019) with the number of cases n (0 where there are no cases).

Arbovirus cases by locality of report.

Counts the probable and confirmed cases by locality of report and joins them to the INEGI 2020 locality catalogue (ITER 2020): one point per locality with cases.

Parameters:

Name Type Description Default
path str or Path

The SINAVE txt file ("DENGUE2_.txt", "ZIKA2_.txt" or "CHIKUNGUNYA2_.txt").

required
snv_dataset ('DENV', 'ZIKV', 'CHIKV')
"DENV"
year int or list of int

Year(s) to keep (ANO). The most recent year by default.

None
week int or list of int

Epidemiological weeks to keep (SEM). All by default.

None

Returns:

Type Description
GeoDataFrame

Points (EPSG:4326) with cvegeo, nom_ent, nom_mun, nom_loc, probable (probable + confirmed), confirmado, altitud and pobtot; for DENV also DNG, DCSA, DG and DENV1 to DENV4.

Dengue cases by epidemiological week in a municipality.

Parameters:

Name Type Description Default
path str or Path

Folder with the SINAVE txt files (the dengue file has "DEN" in its name).

required
mpo str or list of str

Municipality(ies) of report in uppercase, as in SINAVE (DES_MPO_REP).

required
year int

Year (ANO).

required
plot bool

Also draw the figure (matplotlib).

True

Returns:

Type Description
dict

"manejo": probable + confirmed cases by week and management (hospitalised / outpatient); "estatus": probable, confirmed and estimated cases by week (estimated = positivity × probable + confirmed); "figure": the matplotlib figure (None when plot=False).

Effective reproductive number (Rt) of dengue.

Rt for the country, a state, a municipality or a locality, from the daily incidence of the SINAVE cases and a parametric serial interval (Cori et al. 2013), as rt_dengue() of densnv in R.

Parameters:

Name Type Description Default
dataset DataFrame

SINAVE dengue dataset (e.g. densnv.read_sinave("DENGUE2_.txt")). It needs FEC_INI_SIGNOS_SINT, ESTATUS_CASO and, depending on level and place, CVE_EDO_*, CVE_MPO_* and CVE_LOC_*.

required
level ('country', 'state', 'municipality', 'locality')
"country"
place ('REP', 'RES')

Place used to select the cases: of report (default; the cases are geocoded with it) or of residence. In non-endemic areas the cases are reported where they were exposed, so the place of report is the place of transmission.

"REP"
cve_edo (str, int or list)

INEGI keys of the state, municipality and locality. cve_mpo and cve_loc can be lists of the same length (pairs).

None
cve_mpo (str, int or list)

INEGI keys of the state, municipality and locality. cve_mpo and cve_loc can be lists of the same length (pairs).

None
cve_loc (str, int or list)

INEGI keys of the state, municipality and locality. cve_mpo and cve_loc can be lists of the same length (pairs).

None
status_caso int or list of int

1 probable, 2 confirmed.

(1, 2)
ref_date str or date

Reference date; by default the latest date of onset of the cases.

None
period_days int

Days, up to ref_date, of the daily incidence (default 365).

365
window_days int

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

21
mean_si float

Mean and standard deviation (days) of the serial interval (21, 6.1).

21
std_si float

Mean and standard deviation (days) of the serial interval (21, 6.1).

21
plot bool

Draw the Rt curve (matplotlib).

True

Returns:

Type Description
dict

rt (Rt of the weekly sliding windows with at least 10 cases, or None), rt_ventana (Rt of the window, its 95% credible interval and the phase: "En ascenso", "Estable", "En descenso" or "Sin estimar"), incidencia (daily incidence), area (name of the area) and figure (or None).

Notes

The curve uses weekly sliding windows with at least 10 cases 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. The last days are usually incomplete (delay of report), which lowers Rt at the end.

Rt with a parametric serial interval (EpiEstim::estimate_R(), method "parametric_si").

Parameters:

Name Type Description Default
incidence array - like

Daily incidence (cases per day, consecutive days). As in EpiEstim, the cases of the first day are taken as imported.

required
t_start array-like of int

Start and end (1-based, inclusive) of each time window.

required
t_end array-like of int

Start and end (1-based, inclusive) of each time window.

required
mean_si float

Mean and standard deviation (days) of the serial interval.

21
std_si float

Mean and standard deviation (days) of the serial interval.

21
mean_prior float

Mean and standard deviation of the gamma prior of Rt.

5
std_prior float

Mean and standard deviation of the gamma prior of Rt.

5

Returns:

Type Description
DataFrame

One row per window: t_start, t_end, mean, std and the quantiles q025 ... q975 of the posterior of Rt.

Discretised serial interval: gamma distribution shifted by one day.

Same as EpiEstim::discr_si().

Active dengue transmission foci and diagnosis of the epidemiological scenario.

Python version of mp_active_foci() of densnv (R). It identifies the active transmission foci of a locality with DBSCAN (window) or ST-DBSCAN, delimits the transmission and control zones, selects the blocks to treat, tests the space-time interaction with the Knox test (global and by focus), estimates Rt with :func:rt_dengue and diagnoses the epidemiological scenario with the operational strategy.

Parameters:

Name Type Description Default
geocoded_dataset DataFrame

Geocoded cases with long, lat (EPSG:4326), ESTATUS_CASO and FEC_INI_SIGNOS_SINT; for Rt also the CVE_*_REP (or RES) keys.

required
cve_edo str or int

INEGI state key of the locality.

required
locality str

Name of the locality (as in rgeomex.extract_locality()).

required
status_caso int or list of int

1 probable, 2 confirmed.

(1, 2)
spatial_scale float

Spatial window in metres (flight range of Aedes aegypti, 400).

400
temporal_scale int

Temporal window in days (intrinsic + extrinsic incubation, 21).

21
min_cases int

Minimum cases in the space-time window to define a focus (3).

3
buffer_m float

Buffer of the control zone around the transmission zone (200 m).

200
ref_date str or date

Reference date; by default the latest onset in the locality.

None
method ('window', 'st-dbscan')

Fixed window or space-time DBSCAN (new and persistent foci).

"window"
n_sim int

Permutations of the Knox test (0 skips it).

999
perm_days int

Days, up to ref_date, of the cases used by the Knox test and by ST-DBSCAN (>= temporal_scale).

365
alpha float

Significance level (Holm-adjusted p-value by focus; Poisson test).

0.05
seed int

Seed of the permutations.

None
place ('REP', 'RES')

Place of the cases used for Rt.

"REP"
mean_si float

Serial interval for Rt (21, 6.1 days).

21
std_si float

Serial interval for Rt (21, 6.1 days).

21
capacity_cases float

Operational capacity: cases per week the brigades can work.

None
coverage_min float

Coverage of the locality by the recent cases to consider them dispersed; by default 0.40 with 21 days, 0.50 with 28 and linear in between.

None
foci_min float

Proportion of the recent cases in foci from which the cases are also considered dispersed (0.9).

0.9
print_map bool

Return the interactive map (folium) in map.

False
save bool

Save the selected blocks as a GeoPackage in dir.

False
dir str

Folder where the blocks are saved.

'./'

Returns:

Type Description
dict

foci, transmission, blocks, cases (GeoDataFrames in EPSG:4326, None without foci), knox (global Knox test), diagnostico (tabla, escenario, accion, detalle, rt, rt_figure, casos_ventana, casos_mes, pct_pares_tiempo, cobertura_casos, pct_casos_en_focos, pct_area_transmision) and map (folium, or None).

Heatmap of the cases by municipality (rows) and epidemiological week.

Parameters:

Name Type Description Default
dataset DataFrame

SINAVE dengue dataset (read_sinave()).

required
state str or list

State(s) of report, as in DES_EDO_REP (e.g. "GUERRERO"). None uses all the municipalities of the country.

None
year int

Year (ANO).

None
status int or list of int

Case status (ignored with hospitalizados=True).

(1, 2)
hospitalizados bool

Use the hospitalised cases (with date of admission) instead of the status.

False
plot bool

Also build the plotly figure.

True

Returns:

Type Description
dict

data (municipality, week, value) and figure (plotly).

Age-sex pyramid of the confirmed cases (ESTATUS_CASO == 2).

Males on the left, females on the right, by five-year age group.

Returns:

Type Description
dict

data (age_class, sex, count; groups without cases with 0) and figure (matplotlib).

Confirmed cases by final diagnosis and by serotype, by state (or by municipality of a state).

Parameters:

Name Type Description Default
data DataFrame

SINAVE dengue dataset.

required
year int

Year (ANO).

required
cve_edo str or int

State; with it the bars are the municipalities of the state.

None
inset tuple

Position of the serotype plot (left, bottom, width, height, as a fraction of the figure); replaces x_serotype, y_serotype and scale_serotype of R.

(0.58, 0.16, 0.38, 0.38)

Returns:

Type Description
dict

diagnosis (area, DES_DIAG_FINAL as DNG/DCSA/DG, n), serotypes (area, DENGUE_SER_TRIPLEX, n) and figure.

Treemap of the cases by final diagnosis, by state (country=True) or by municipality of a state.

Returns:

Type Description
dict

data (area, DES_DIAG_FINAL as DSA/DG/DNG, value) and figure.

Bump map: map of the cases with sigmoid curves to a ranking.

state=True ranks the states of Mexico; state=False the municipalities of cve_edo (optionally the top_n with most cases).

Returns:

Type Description
dict

data (NOMGEO, value, fine_cap = position in the ranking) and figure (matplotlib).

Interactive map (folium) of the cases by locality, with a panel of the top_n localities.

Parameters:

Name Type Description Default
data GeoDataFrame

Output of :func:cases_by_loc.

required
var str

Column to map ("probable", "confirmado", "DENV2"...).

'probable'

Returns:

Type Description
dict

top (rank, locality, cases) and map (folium).

Serotypes of the confirmed cases by municipality of a state.

Parameters:

Name Type Description Default
path_sinave str or Path

The dengue txt file ("DENGUE2_.txt").

required
cve_edo str or int

State key.

required

Returns:

Type Description
dict

serotypes (municipalities with D1..D4, number of serotypes and combination), cases (municipalities with confirmed cases n) and map (folium).