disease risk modelling and visualization using r
play

Disease risk modelling and visualization using R Paula Moraga - PowerPoint PPT Presentation

Disease risk modelling and visualization using R Paula Moraga useR! 2018 Brisbane, 10 July 2018 1/51 Outline Introduction to disease mapping Tutorials Tutorial: areal data Tutorial: geostatistical data Presentations options: interactive


  1. Disease risk modelling and visualization using R Paula Moraga useR! 2018 Brisbane, 10 July 2018 1/51

  2. Outline Introduction to disease mapping Tutorials Tutorial: areal data Tutorial: geostatistical data Presentations options: interactive dashboards and Shiny apps SpatialEpiApp Shiny Tutorial: Shiny 2/51

  3. Introduction to disease mapping 3/51

  4. John Snow’s map of cholera deaths in Soho, London, 1854 4/51

  5. Disease mapping Disease maps help understand the spatial patterns of disease and its determinants. This information can guide decision makers and programme managers to better allocate limited resources and to design strategies for disease prevention and control 5/51

  6. Types of spatial data 1. Areal data 2. Geostatistical data 3. Point patterns Moraga and Lawson 2012 Moraga et al. 2015 Moraga and Montes 2011 6/51

  7. Modelling • Disease risk predictions are based on the observed disease cases, the number of individuals at risk, and risk factors information such as demographic and environmental factors • Models describe the variability in the response variable as a function of the risk factors covariates and random effects to account for unexplained variability 7/51

  8. Areal data Moraga and Lawson 2012 8/51

  9. Areal data Disease risk is often estimated by the Standardized Mortality Ratio: SMR i = Y i E i • Y i number of observed cases in area i • E i number of expected cases in area i (number expected cases if area had the same disease rate as the standard population) • SMR i > 1 ( < 1 ): more (fewer) cases observed than expected • Expected cases calculated using indirect standardization m r ( s ) j n ( i ) � E i = j j =1 • r ( s ) disease rate in strata j in standard population = j (number disease cases)/(population) in strata j in standard pop • n ( i ) population in strata j in area i j • strata j can indicate age group, sex, etc 9/51

  10. Areal data • SMRs may be misleading and insufficiently reliable in areas with small populations • In contrast, model-based approaches enable to incorporate covariates and borrow information from neighboring areas to improve local estimates, resulting in the smoothing of extreme rates based on small sample sizes 10/51

  11. Areal data Model to estimate disease risks θ i in areas i = 1 , . . . , n Y i | θ i ∼ Po ( E i × θ i ) , log( θ i ) = z ′ i β + u i + v i • u i is an structured spatial effect to account for the spatial dependence between relative risks (areas that are close show more similar risk than areas that are not close) • v i is an unstructured spatial effect to account for independent area-specific noise 11/51

  12. Geostatistical data Moraga et al. 2015 12/51

  13. Geostatistical data Y i | P ( x i ) ∼ Binomial ( N i , P ( x i )) , logit ( P ( x i )) = z ′ i β + S ( x i ) + v i Risk factors covariates Gaussian Random Field (e.g. temperature, precipitation, vegetation, etc) NASA Earth Observations 13/51

  14. Coordinate Reference Systems (CRS) 1 unprojected or geographic : Latitude/Longitude for referencing location on the ellipsoid Earth 2 projected : Easting/Northing for referencing location on 2-dimensional representation of Earth. Common projection: Universal Transverse Mercator (UTM) 14/51

  15. Tutorials 15/51

  16. Install R packages install.packages ( c ("dplyr", "ggplot2", "leaflet", "geoR", "rgdal", "raster", "sp", "spdep", "SpatialEpi", "SpatialEpiApp")) install.packages ("INLA", repos = "https://inla.r-inla-download.org/R/stable", dep = TRUE) 16/51

  17. Tutorial: areal data 17/51

  18. Areal data. Lung cancer in Pennsylvania https://paula-moraga.github.io/tutorial-areal-data/ 18/51

  19. Tutorial: geostatistical data 19/51

  20. Geostatistical data. Malaria in The Gambia https://paula-moraga.github.io/tutorial-geostatistical-data/ 20/51

  21. Presentations options: interactive dashboards and Shiny apps 21/51

  22. Interactive dashboards with flexdashboard • https://rmarkdown.rstudio.com/flexdashboard/ • Uses R Markdown to publish a group of related data visualizations as a dashboard • Components that can be included include plots, tables, value boxes and htmlwidgets 22/51

  23. Layout 23/51

  24. Example https://rmarkdown.rstudio.com/flexdashboard/examples.html 24/51

  25. Interactive Shiny web applications • https://shiny.rstudio.com/ • Shiny is a web application framework for R that enables to build interactive web applications 25/51

  26. SpatialEpiApp 26/51

  27. R package SpatialEpiApp • Shiny web application that allows to visualize spatial and spatio-temporal disease data, estimate disease risk and detect clusters • Risk estimates by fitting Bayesian models with INLA • Detection of clusters by using the scan statistics in SaTScan Launch SpatialEpiApp: install.packages ("SpatialEpiApp") library (SpatialEpiApp) run_app () 27/51

  28. Data entry 28/51

  29. Interactive 29/51

  30. Maps 30/51

  31. Clusters 31/51

  32. Report 32/51

  33. Shiny 33/51

  34. Shiny • Shiny is a web application framework for R that enables to build interactive web applications • https://shiny.rstudio.com/ 34/51

  35. Examples https://shiny.rstudio.com/gallery/single-file-shiny-app.html 35/51

  36. Examples https://shiny.rstudio.com/gallery/telephones-by-region.html 36/51

  37. Structure of a Shiny App A Shiny app is a directory that contains an R file called app.R . app.R has three components: • user interface object ( ui ) which controls the layout and appearance of the app • server() function with the instructions to build the objects displayed in the ui • call to shinyApp() that creates the Shiny app from the ui / server pair 37/51

  38. Content app.R # define user interface object ui <- fluidPage ( ) # define server() function server <- function (input, output){ } # call to shinyApp() which returns the Shiny app shinyApp (ui = ui, server = server) Save app.R inside the appdir directory. Launch the app: library (shiny) runApp ("appdir_path") 38/51

  39. Inputs 39/51

  40. Outputs • Plots, tables, texts, images 40/51

  41. Inputs, outputs and reactivity • Inputs: we can interact with the app by modifying their values • Outputs: objects we want to show in the app ui <- fluidPage ( *Input (inputId = myinput, label = mylabel, ...) *Output (outputId = myoutput, ...) ) server <- function (input, output){ output $ myoutput <- render * ({ # code to build the output. # If it uses an input value (input$myinput), # the output will be rebuilt whenever # the input value changes })} 41/51

  42. Inputs, outputs and reactivity 42/51

  43. HTML widgets Interactive web visualizations using JavaScript http://www.htmlwidgets.org/ 43/51

  44. Leaflet http://rstudio.github.io/leaflet/ 44/51

  45. Dygraphs http://rstudio.github.io/dygraphs 45/51

  46. DataTables http://rstudio.github.io/DT/ 46/51

  47. Options to share a Shiny app 1 Share R scripts with other users • need R library (shiny) runApp ("appdir_path") 2 Host app as a web page at its own URL • do not need R • app can be navigated through the internet with a web browser • host apps on own servers or using one of the ways RStudio offers such as shinyapps.io and Shiny Server https://paulamoraga.shinyapps.io/spatialepiapp/ 47/51

  48. Tutorial: Shiny 48/51

  49. Tutorial: Shiny https://paula-moraga.github.io/tutorial-shiny-spatial/ 49/51

  50. References • Paula Moraga. SpatialEpiApp: A Shiny Web Application for the analysis of Spatial and Spatio-Temporal Disease Data, (2017), Spatial and Spatio-temporal Epidemiology, 23:47-57 • Winston Chang, Joe Cheng, JJ Allaire, Yihui Xie and Jonathan McPherson (2017). shiny: Web Application Framework for R. https://CRAN.R-project.org/package=shiny • Barbara Borges and JJ Allaire (2017). flexdashboard: R Markdown Format for Flexible Dashboards. https://CRAN.R-project.org/package=flexdashboard 50/51

  51. Thanks! https://Paula-Moraga.github.io Twitter @_PaulaMoraga_ 51/51

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend