signaturescience / focustools

Forecasting COVID-19 in the US
https://signaturescience.github.io/focustools/
GNU General Public License v3.0
0 stars 0 forks source link

Vaccines! #35

Closed stephenturner closed 3 years ago

stephenturner commented 3 years ago

Let's look for data 💉

vpnagraj commented 3 years ago

vaccination data sources:

stephenturner commented 3 years ago

I'm not seeing good documentation for the API yet, but Youyang Gu has a few URLs that get some trend data at least at US + LTC levels. E.g. https://covid.cdc.gov/covid-data-tracker/COVIDData/getAjaxData?id=vaccination_trends_data

Not sure I understand/believe that plateau there.

library(tidyverse)
theme_set(theme_classic())

v <- jsonlite::fromJSON("https://covid.cdc.gov/covid-data-tracker/COVIDData/getAjaxData?id=vaccination_trends_data")$vaccination_trends_data %>% 
  as_tibble() %>% 
  mutate(Date=lubridate::as_date(Date))

v %>% 
  filter(Location=="US") %>% 
  select(Date, Admin_Dose_1_Cumulative, Admin_Dose_2_Cumulative) %>% 
  gather(key, Doses, -Date) %>% 
  na.omit() %>% 
  ggplot(aes(Date, Doses)) + geom_line(aes(col=key), lwd=1) + theme(legend.position="bottom") + labs(col=NULL)

image

vpnagraj commented 3 years ago

we've been working with some vaccination data for the compartmental models (see https://github.com/signaturescience/focustools/blob/compartmental/scratch/sveird-odin-scratch.R#L132-L160)

using one of the sources noted above:

vacc_*.csv files in https://github.com/scc-usc/ReCOVER-COVID-19/tree/master/results/forecasts

some code to explore that data:

library(tidyverse)
## devtools::install_github("vpnagraj/yawp", ref = "main")
library(yawp)

## get data on fully vaccinated
full_vacc <-
  read_csv("https://raw.githubusercontent.com/scc-usc/ReCOVER-COVID-19/master/results/forecasts/vacc_full.csv") %>%
  select(-population) %>%
  filter(Country == "US") %>%
  gather(date,count, -Country,-id) %>%
  mutate(inc_count = count - lag(count)) %>%
  mutate(rolling_average = yawp::mav(inc_count, 7, align = "left"))

## explore
rbind(yawp::more(head(full_vacc)), tail(full_vacc))

## plot
full_vacc %>%
  select(date:rolling_average) %>%
  rename(`Cumulative Vaccinations` = count, 
         `New Vaccinations` = inc_count, 
         `New Vaccinations (7-day average)` = rolling_average) %>%
  gather(Type, Count, -date) %>%
  mutate(date = as.Date(date)) %>%
  filter(!is.na(Count)) %>%
  #filter(Type !="Cumulative Vaccinations") %>%
  ggplot(aes(date, Count)) +
  geom_line(aes(group = Type, col = Type)) +
  scale_x_date(date_breaks = "1 week", date_labels = "%b %d") +
  labs(x = "Date", y = "Count", title = "Time series of full vaccination in the United States") +
  theme_minimal() +
  theme(legend.position =  "bottom", legend.title = element_blank(), axis.text.x = element_text(angle = 45, vjust = 1))

## what is the rate of vaccination (7-day average of n people / uspop becoming fully vaccinated)
## on march 31 2021 ?
uspop <- 328e6

full_vacc %>%
  arrange(date) %>%
  mutate(rate = rolling_average/uspop) %>%
  filter(date == "2021-03-31") %>%
  pull(rate)

## what is the total % of people in th US fully vaccinated
## on march 31 2021
full_vacc %>%
  arrange(date) %>%
  mutate(prop = count/uspop) %>%
  filter(date == "2021-03-31") %>%
  pull(prop)

vacc

so i think that's what we need to help explore compartmental models. if we need to revisit some kind of get_vacc function for focustools we can ... but i think for now it's ok to close this issue out