Hotspots de la Transmisión de Dengue
en R



Dr. Felipe Dzul Manzanilla

Dr. Fabián Correa-Morales


Created: 2024-01-31

Updated: 2024-01-31

Compiled: 2024-02-14


Temario


  • Flujograma del cálculo de los hotspots del dengue.
  • Geocodificación.
  • Extraer la localidad.
  • Contar los casos por AGEB.
  • Calcular los hotspots.
  • Visualizar los hotspots.

Flujograma del Cálculo de los Hotspots del Dengue


Geocodificación de las bases de dengue en R


  • Darse de alta en el servicio de Geocoding API de gooogle
  • Subir las bases de dengue en R.
  • Geocodificar las bases de Dengue.
  • Unir y guardar las bases de dengue geocodificadas.

Geocodificación de las Bases de Dengue en R


# Step 1. load dengue dataset the current week ####
#y <- denhotspots::read_dengue_dataset(path = "1.data/current_week/DENGUE2_.txt",
#                                      spatial_resolution = "country",
#                                      status_caso = c(1, 2)) 
# Step 2. load dengue dataset the last week ####
#x <- denhotspots::read_dengue_dataset(path = "1.data/last_week/DENGUE2_.txt",
#                                      spatial_resolution = "country",
#                                      status_caso = c(1, 2))
# Step 3. extract the ids not geocoded ####
#z <- y |>
#    dplyr::filter(!FOL_ID %in% unique(x$FOL_ID)) |>
#    dplyr::arrange(FOL_ID)

# Step 4. save the results ####
#write.csv(z, 
#          file = "dengue_mx_2024_01_23.csv")
# Step 1. subir el vectores de direcciones ####
# addresses <- denhotspots::data_geocoden(infile = "dengue_mx_2024_01_23",
#                                        data = FALSE,
#                                        sinave_new = TRUE)
# Step 2. text manipulation ####
# stringr::str_subset(addresses, "#")
# addresses <- stringr::str_replace_all(addresses,
#                                      pattern = "#",
#                                      replacement = " ")
# Step 3. geocoding ####
# denhotspots::geocoden(infile = "dengue_mx_2024_01_23")
# Step 4. load the dengue geocoded & dengue dataset #####
# z <- readRDS("~/Library/CloudStorage/OneDrive-Personal/proyects/geocoding_mex/2024/dengue_mx_2024_01_23_temp_geocoded.rds")
# Step 5. load the dengue dataset ####
#data <- denhotspots::data_geocoden(infile = "dengue_mx_2024_01_23", 
#                                   data = TRUE,
#                                   sinave_new = TRUE)
# Step 6. save the results #####
#denhotspots::save_geocoden(x = z,
#                           y = data,
#                           directory = "9.geocoded_data",
#                           loc = "dengue_mx_2024_01_23")
#Step 1 load geocoded dengue dataset current week ####
# load("~/Library/CloudStorage/OneDrive-Personal/proyects/geocoding_mex/2024/9.geocoded_data/geo_dengue_mx_2024_01_23.RData")
# Step 2. load geocoded dengue dataset last week ####
# load("~/Library/CloudStorage/OneDrive-Personal/proyects/geocoding_mex/2024/8.RData/denmex_2024.RData")
# Step 3. row binding ####
# z <- rbind(z, y)
# Step 4. load the current week dataset 
# w <- denhotspots::read_dengue_dataset(path = "1.data/current_week/DENGUE2_.txt",
#                                      spatial_resolution = "country",
#                                      status_caso = c(1, 2))
# Step 5. eliminate the CASOS DESCARTADOS ####
# z <- z |>
#    dplyr::filter(VEC_ID %in% unique(w$VEC_ID)) |>
#    dplyr::arrange(VEC_ID)
# Step 6. save the results ####
# save(z, file = "8.RData/denmex_2024.RData")

Identificación de los hotspots de dengue en R


# Step 1. load the dataset ####
load("/Users/fdzul/Dropbox/hotspots_2023/8.RData/denmex.RData")
# Step 2. extract the locality ####
x <- rgeomex::extract_ageb(locality = c("Guadalajara", "Zapopan", 
                                        "Tlaquepaque", "Tonalá"), 
                           cve_edo = "14")
# Step 3. cases by AGEB ####
library(magrittr)
z <- denhotspots::point_to_polygons(x = xy,
                                    y = x$ageb,
                                    ids = names(x$ageb)[-10],
                                    time = ANO,
                                    coords = c("long", "lat"),
                                    crs = 4326,
                                    dis = "DENV") 
# Step 4. hotspots ####
hotspots <- denhotspots::gihi(x = z,
                              id = names(z)[c(1:9)], 
                              time = "year",
                              dis = "DENV",
                              gi_hi = "gi",
                              alpha = 0.95)

Visualización de los Hotspots de Dengue


denhotspots::staticmap_intensity(x = hotspots,
                                 pal = rcartocolor::carto_pal,
                                 pal_name = TRUE,
                                 name = "OrYel",
                                 breaks = 1,
                                 dir_pal = -1,
                                 x_leg = 0.5,
                                 y_leg = 0.1,
                                 ageb = TRUE)

Visualización de los Hotspots de Dengue


mapview::mapview(hotspots,
                 zcol = "intensity_gi",
                 layer.name = "Intensidad",
                 label = FALSE,
                 color = "white",
                 lwd = 0.5, 
                 col.regions =  rcartocolor::carto_pal(n = max(hotspots$intensity_gi), 
                                                       name = "OrYel"))

Laboratorio 1. Geocodificación de las Bases de Dengue en R


Dios Botic