# Chapter 16 Disease surveillance with **SpatialEpiApp**

**SpatialEpiApp** (Moraga 2017b) is an R package that contains a Shiny web application to visualize spatial and spatio-temporal disease data, estimate disease risk and detect clusters. **SpatialEpiApp** may be useful for many researchers and practitioners working in public health and lacking the adequate statistical and programming skills to effectively use the statistical software required to conduct disease surveillance analyses. With **SpatialEpiApp**, users simply need to upload a map and disease data, and then click the buttons that create the input files required, analyze the data, and process the output to generate tables and plots with the results.

**SpatialEpiApp** allows to fit Bayesian hierarchical models to obtain disease risk estimates and their uncertainty by using **R-INLA** (Rue et al. 2018), and to detect clusters by using the scan statistics implemented in the `SaTScan`

software (Kulldorff 2006). Moreover, the application allows user interaction and includes interactive visualizations by using the packages **leaflet** for rendering maps (Cheng, Karambelkar, and Xie 2018), **dygraphs** for plotting time series (Vanderkam et al. 2018), and **DT** for displaying data objects (Xie, Cheng, and Tan 2019). It also enables the generation of reports containing the analyses performed by using R Markdown (Allaire et al. 2019). In this chapter we describe the main components of **SpatialEpiApp**. Moraga (2017a) can be seen for more details about its use, methods and examples.

## 16.1 Installation

The development version of **SpatialEpiApp** can be installed from GitHub by using the `install_github()`

function of the **devtools** package (Wickham, Hester, and Chang 2019).

```
library(devtools)
install_github("Paula-Moraga/SpatialEpiApp")
```

Then, the application can be launched by loading the package and executing the `run_app()`

function.

```
library(SpatialEpiApp)
run_app()
```

## 16.2 Use of **SpatialEpiApp**

**SpatialEpiApp** consists of three pages, namely, ‘Inputs’, ‘Analysis’ and ‘Help’.

### 16.2.1 ‘Inputs’ page

The ‘Inputs’ page is the first page we see when we launch the application (Figure 16.1). In this page we can upload the map and the disease data, and select the type of analysis to be conducted.

- The map is a shapefile with the areas of the study region. The shapefile needs to contain the id and the name of the areas.
- The data is a CSV file that contains the cases and population for each area, time, and individual level covariates (e.g., age, sex). If areal level covariates are used, the data need to specify the cases and population for each area and time, and the values of the covariates (e.g., socio-economic index).

Note that the ids of the areas in the CSV file need to be the same as the ids of the areas in the shapefile so that the data and the map can be linked. Time can be year, month or day, and all dates need to be consecutive. For example, if we work with years from 2000 to 2010, we need to provide information of all years 2000, 2001, 2002, \(\ldots\) 2010. The application does not work if we have, for example, only years 2000, 2005 and 2010. Once we have uploaded the map and the data, we need to select the type of analysis by specifying the temporal unit, the date range, and the type of analysis which can be spatial or spatio-temporal.

### 16.2.2 ‘Analysis’ page

In the ‘Analysis’ page, we can visualize the data, perform the statistical analyses, and generate reports (Figure 16.2). On the top of the page, there are four buttons:

- ‘Edit Inputs’ which is used when we wish to return to the ‘Inputs’ page to modify the analysis options or upload new data,
- ‘Maps Pop O E SIR’ which creates plots of the population, observed, expected and SIR variables,
- ‘Estimate Risk’ which is used to estimate the disease risk and its uncertainty,
- ‘Detect Clusters’ which is used for the detection of disease clusters.

To obtain disease risk estimates, we need to install the **R-INLA** package. To detect clusters, we need to download and install the `SaTScan`

software from http://www.satscan.org. Then we need to locate the folder where the `SaTScan`

software is installed and copy the `SaTScanBatch64`

executable in the `SpatialEpiApp/SpatialEpiApp/ss`

folder which is located in the R library path. Note that the R library path can be obtained by typing `.libPaths()`

.

The ‘Analysis’ page also contains four tabs called ‘Interactive’, ‘Maps’, ‘Clusters’ and ‘Report’ that include tables and plots with the results. The ‘Maps’ tab (Figure 16.3) shows the results obtained by clicking the ‘Map Pop O E SIR’ and the ‘Estimate Risk’ buttons. Specifically, it shows a summary table, maps, and time plots of the population, observed number of cases, expected number of cases, SIR, disease risk, and lower and upper limits of 95% credible intervals.

The ‘Clusters’ tab (Figure 16.4) shows the results of the cluster analysis. Specifically, it shows a map with the clusters detected for each of the times of the study period, and a plot with all clusters over time. This tab also includes a table with the information relative to each of the clusters, such as the areas that form the clusters and their significance.

In the ‘Report’ tab (Figure 16.5), we can download a PDF document with the results of our analysis. The report includes maps and tables summarizing the population, observed number of cases, expected number of cases, SIR, disease risk, and lower and upper limits of the 95% credible intervals, as well as the clusters detected.

### 16.2.3 ‘Help’ page

Finally, the ‘Help’ button redirects to the ‘Help’ page which shows information about the use of **SpatialEpiApp**, as well as the statistical methodology and the R packages employed to build the application.

### References

Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2019. *Rmarkdown: Dynamic Documents for R*. https://CRAN.R-project.org/package=rmarkdown.

Cheng, Joe, Bhaskar Karambelkar, and Yihui Xie. 2018. *Leaflet: Create Interactive Web Maps with the Javascript ’Leaflet’ Library*. https://CRAN.R-project.org/package=leaflet.

Kulldorff, Martin. 2006. “SaTScan(TM) V. 7.0. Software for the Spatial and Space-Time Scan Statistics.” http://www.satscan.org.

Moraga, Paula. 2017a. “SpatialEpiApp: A Shiny Web Application for the analysis of Spatial and Spatio-Temporal Disease Data.” *Spatial and Spatio-Temporal Epidemiology* 23: 47–57. doi:https://doi.org/10.1016/j.sste.2017.08.001.

Moraga, Paula. 2017b. *SpatialEpiApp: A Shiny Web Application for the Analysis of Spatial and Spatio-Temporal Disease Data*. https://CRAN.R-project.org/package=SpatialEpiApp.

Rue, Havard, Finn Lindgren, Daniel Simpson, Sara Martino, Elias Teixeira Krainski, Haakon Bakka, Andrea Riebler, and Geir-Arne Fuglstad. 2018. *INLA: Full Bayesian Analysis of Latent Gaussian Models Using Integrated Nested Laplace Approximations*.

Vanderkam, Dan, JJ Allaire, Jonathan Owen, Daniel Gromer, and Benoit Thieurmel. 2018. *Dygraphs: Interface to ’Dygraphs’ Interactive Time Series Charting Library*. https://CRAN.R-project.org/package=dygraphs.

Wickham, Hadley, Jim Hester, and Winston Chang. 2019. *Devtools: Tools to Make Developing R Packages Easier*. https://CRAN.R-project.org/package=devtools.

Xie, Yihui, Joe Cheng, and Xianying Tan. 2019. *DT: A Wrapper of the Javascript Library ’Datatables’*. https://CRAN.R-project.org/package=DT.