Skip to content

Commit ade3ea2

Browse files
committed
flesh out signal discovery vignette
1 parent 86502a3 commit ade3ea2

File tree

1 file changed

+360
-0
lines changed

1 file changed

+360
-0
lines changed

vignettes/signal-discovery.Rmd

Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
---
2+
title: "Finding data sources and signals of interest"
3+
output: rmarkdown::html_vignette
4+
vignette: >
5+
%\VignetteIndexEntry{Finding data sources and signals of interest}
6+
%\VignetteEngine{knitr::rmarkdown}
7+
\usepackage[utf8]{inputenc}
8+
---
9+
10+
```{r, echo = FALSE, message = FALSE}
11+
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
12+
options(tibble.print_min = 4L, tibble.print_max = 4L, max.print = 4L)
13+
library(epidatr)
14+
library(dplyr)
15+
```
16+
17+
The Epidata API includes numerous data streams -- medical claims data, cases and deaths, mobility, and many others -- covering different geographic regions. This can make it a challenge to find the data stream that you are most interested in.
18+
19+
Example queries with all the endpoint functions available in this package are
20+
given [below](#example-queries).
21+
22+
23+
## Using the documentation
24+
25+
The Epidata documentation lists all the data sources and signals available
26+
through the API for
27+
[COVID-19](https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html) and
28+
for [other diseases](https://cmu-delphi.github.io/delphi-epidata/api/README.html#source-specific-parameters).
29+
The site also includes a search tool if you have a keyword (e.g. "Taiwan") in mind.
30+
31+
32+
## Interactive tooling
33+
34+
We provide a couple `epidatr` functions to help find data sources and signals.
35+
36+
The `avail_endpoints()` function lists endpoints, each of which, except for
37+
COVIDcast, corresponds to a single data source. `avail_endpoints()` outputs a
38+
`tibble` of endpoints and brief descriptions, which explicitly state when they
39+
cover non-US locations:
40+
41+
```{r, eval = FALSE}
42+
avail_endpoints()
43+
```
44+
45+
```{r, echo = FALSE}
46+
invisible(capture.output(endpts <- avail_endpoints()))
47+
knitr::kable(endpts)
48+
```
49+
50+
The `covidcast_epidata()` function lets you look more in-depth at the data
51+
sources available through the COVIDcast endpoint. The function describes
52+
all available data sources and signals:
53+
54+
```{r}
55+
covid_sources <- covidcast_epidata()
56+
head(covid_sources$sources, n = 2)
57+
```
58+
59+
Each source is included as an entry in the `covid_sources$sources` list, associated
60+
with a `tibble` describing included signals.
61+
62+
If you use an editor that supports tab completion, such as RStudio, type
63+
`covid_sources$source$` and wait for the tab completion popup. You will be able to
64+
browse the list of data sources.
65+
66+
```{r}
67+
covid_sources$signals
68+
```
69+
70+
If you use an editor that supports tab completion, type
71+
`covid_sources$signals$` and wait for the tab completion popup. You will be
72+
able to type the name of signals and have the autocomplete feature select
73+
them from the list for you. In the tab-completion popup, signal names are
74+
prefixed with the name of the data source for filtering convenience.
75+
76+
_Note_ that some signal names have dashes in them, so to access them
77+
we rely on the backtick operator:
78+
79+
```{r}
80+
covid_sources$signals$`fb-survey:smoothed_cli`
81+
```
82+
83+
These signal objects can be used directly to fetch data, without requiring us to use
84+
the `pub_covidcast()` function. Simply use the `$call` attribute of the object:
85+
86+
```{r}
87+
covid_sources$signals$`fb-survey:smoothed_cli`$call("state", "pa", epirange(20210405, 20210410))
88+
```
89+
90+
91+
## Example Queries
92+
93+
### COVIDcast Main Endpoint
94+
95+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html>
96+
97+
County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed in the API docs [here](https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html). The example below is for Orange County, California.
98+
99+
```{r}
100+
pub_covidcast(
101+
source = "fb-survey",
102+
signals = "smoothed_accept_covid_vaccine",
103+
geo_type = "county",
104+
time_type = "day",
105+
time_values = epirange(20201221, 20201225),
106+
geo_values = "06059"
107+
)
108+
```
109+
110+
The `covidcast` endpoint supports `*` in its time and geo fields:
111+
112+
```{r}
113+
pub_covidcast(
114+
source = "fb-survey",
115+
signals = "smoothed_accept_covid_vaccine",
116+
geo_type = "county",
117+
time_type = "day",
118+
time_values = epirange(20201221, 20201225),
119+
geo_values = "*"
120+
)
121+
```
122+
123+
### Other Covid Endpoints
124+
125+
#### COVID-19 Hospitalization: Facility Lookup
126+
127+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility_lookup.html>
128+
129+
```{r, eval = FALSE}
130+
pub_covid_hosp_facility_lookup(city = "southlake")
131+
pub_covid_hosp_facility_lookup(state = "WY")
132+
# A non-example (there is no city called New York in Wyoming)
133+
pub_covid_hosp_facility_lookup(state = "WY", city = "New York")
134+
```
135+
136+
#### COVID-19 Hospitalization by Facility
137+
138+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility.html>
139+
140+
```{r, eval = FALSE}
141+
pub_covid_hosp_facility(
142+
hospital_pks = "100075",
143+
collection_weeks = epirange(20200101, 20200501)
144+
)
145+
```
146+
147+
#### COVID-19 Hospitalization by State
148+
149+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp.html>
150+
151+
```{r, eval = FALSE}
152+
pub_covid_hosp_state_timeseries(states = "MA", dates = "20200510")
153+
```
154+
155+
### Flu Endpoints
156+
157+
#### Delphi's ILINet forecasts
158+
159+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/delphi.html>
160+
161+
```{r, eval = FALSE}
162+
del <- pub_delphi(system = "ec", epiweek = 201501)
163+
names(del[[1L]]$forecast)
164+
```
165+
166+
#### FluSurv hospitalization data
167+
168+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/flusurv.html>
169+
170+
```{r, eval = FALSE}
171+
pub_flusurv(locations = "ca", epiweeks = 202001)
172+
```
173+
174+
#### Fluview data
175+
176+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/fluview.html>
177+
178+
```{r, eval = FALSE}
179+
pub_fluview(regions = "nat", epiweeks = epirange(201201, 202001))
180+
```
181+
182+
#### Fluview virological data from clinical labs
183+
184+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/fluview_clinical.html>
185+
186+
```{r, eval = FALSE}
187+
pub_fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701))
188+
```
189+
190+
#### Fluview metadata
191+
192+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/fluview_meta.html>
193+
194+
```{r, eval = FALSE}
195+
pub_fluview_meta()
196+
```
197+
198+
#### Google Flu Trends data
199+
200+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/gft.html>
201+
202+
```{r, eval = FALSE}
203+
pub_gft(locations = "hhs1", epiweeks = epirange(201201, 202001))
204+
```
205+
206+
#### ECDC ILI
207+
208+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/ecdc_ili.html>
209+
210+
```{r, eval = FALSE}
211+
pub_ecdc_ili(regions = "Armenia", epiweeks = 201840)
212+
```
213+
214+
#### KCDC ILI
215+
216+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/kcdc_ili.html>
217+
218+
```{r, eval = FALSE}
219+
pub_kcdc_ili(regions = "ROK", epiweeks = 200436)
220+
```
221+
222+
#### NIDSS Flu
223+
224+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/nidss_flu.html>
225+
226+
```{r, eval = FALSE}
227+
pub_nidss_flu(regions = "taipei", epiweeks = epirange(200901, 201301))
228+
```
229+
230+
#### ILI Nearby Nowcast
231+
232+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/nowcast.html>
233+
234+
```{r, eval = FALSE}
235+
pub_nowcast(locations = "ca", epiweeks = epirange(202201, 202319))
236+
```
237+
238+
### Dengue Endpoints
239+
240+
#### Delphi's Dengue Nowcast
241+
242+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/dengue_nowcast.html>
243+
244+
```{r, eval = FALSE}
245+
pub_dengue_nowcast(locations = "pr", epiweeks = epirange(201401, 202301))
246+
```
247+
248+
#### NIDSS dengue
249+
250+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/nidss_dengue.html>
251+
252+
```{r, eval = FALSE}
253+
pub_nidss_dengue(locations = "taipei", epiweeks = epirange(200301, 201301))
254+
```
255+
256+
### PAHO Dengue
257+
258+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/paho_dengue.html>
259+
260+
```{r, eval=FALSE}
261+
pub_paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319))
262+
```
263+
264+
### Other Endpoints
265+
266+
#### Wikipedia Access
267+
268+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/wiki.html>
269+
270+
```{r, eval = FALSE}
271+
pub_wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319))
272+
```
273+
274+
### Private methods
275+
276+
These require private access keys to use (separate from the Delphi Epidata API key).
277+
To actually run these locally, you will need to store these secrets in your `.Reviron` file, or set them as environmental variables.
278+
279+
#### CDC
280+
281+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/cdc.html>
282+
283+
```{r, eval=FALSE}
284+
pvt_cdc(auth = Sys.getenv("SECRET_API_AUTH_CDC"), epiweeks = epirange(202003, 202304), locations = "ma")
285+
```
286+
287+
#### Dengue Digital Surveillance Sensors
288+
289+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/dengue_sensors.html>
290+
291+
```{r, eval=FALSE}
292+
pvt_dengue_sensors(
293+
auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
294+
names = "ght",
295+
locations = "ag",
296+
epiweeks = epirange(201404, 202004)
297+
)
298+
```
299+
300+
#### Google Health Trends
301+
302+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/ght.html>
303+
304+
```{r, eval=FALSE}
305+
pvt_ght(
306+
auth = Sys.getenv("SECRET_API_AUTH_GHT"),
307+
epiweeks = epirange(199301, 202304),
308+
locations = "ma",
309+
query = "how to get over the flu"
310+
)
311+
```
312+
313+
#### NoroSTAT metadata
314+
315+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/meta_norostat.html>
316+
317+
```{r, eval=FALSE}
318+
pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"))
319+
```
320+
321+
#### NoroSTAT data
322+
323+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/norostat.html>
324+
325+
```{r, eval=FALSE}
326+
pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "1", epiweeks = 201233)
327+
```
328+
329+
#### Quidel Influenza testing
330+
331+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/quidel.html>
332+
333+
```{r, eval=FALSE}
334+
pvt_quidel(auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), locations = "hhs1", epiweeks = epirange(200301, 202105))
335+
```
336+
337+
#### Sensors
338+
339+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/sensors.html>
340+
341+
```{r, eval=FALSE}
342+
pvt_sensors(
343+
auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
344+
names = "sar3",
345+
locations = "nat",
346+
epiweeks = epirange(200301, 202105)
347+
)
348+
```
349+
350+
#### Twitter
351+
352+
API docs: <https://cmu-delphi.github.io/delphi-epidata/api/twitter.html>
353+
354+
```{r, eval=FALSE}
355+
pvt_twitter(
356+
auth = Sys.getenv("SECRET_API_AUTH_TWITTER"),
357+
locations = "nat",
358+
epiweeks = epirange(200301, 202105)
359+
)
360+
```

0 commit comments

Comments
 (0)