Animation of projected weekly cases - Australia
Source:vignettes/VariantAnimation-Australia.Rmd
VariantAnimation-Australia.Rmd
suppressPackageStartupMessages({
library(covmuller)
library(COVID19)
library(tidyverse)
})
theme_set(CovmullerTheme())
Get variants data for Australia
gisaid_metadata <- qs::qread("~/data/epicov/metadata_tsv_2024_04_11.qs")
gisaid_Australia <- gisaid_metadata %>%
filter(Country == "Australia") %>%
filter(Host == "Human")
# format metadata
gisaid_Australia <- FormatGISAIDMetadata(gisaid_Australia)
gisaid_Australia <- gisaid_Australia %>%
arrange(State, MonthYearCollected) %>%
filter(pangolin_lineage != "Unknown")
vocs <- GetVOCs()
custom_voc_mapping <- list(
`JN.1` = "JN.1",
`JN.1.*` = "JN.1",
`HV.1` = "HV.1",
`HV.1.*` = "HV.1",
`B.1` = "B.1",
`B.1.1.306` = "B.1",
`B.1.1.306.*` = "B.1",
`B.1.1.326` = "B.1",
`B.1.36.29` = "B.1",
`B.1.560` = "B.1",
`B.1.1` = "B.1",
`B.1.210` = "B.1",
`B.1.36.8` = "B.1",
`B.1.36` = "B.1",
`B.1.36.*` = "B.1"
)
gisaid_Australia <- gisaid_Australia %>% filter(pangolin_lineage != "None")
gisaid_Australia <- CollapseLineageToVOCs(
variant_df = gisaid_Australia,
vocs = vocs,
custom_voc_mapping = custom_voc_mapping,
summarize = FALSE
)
Get weekly cases for Australia
GetCases <- function() {
data <- read.csv("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/cases_deaths/new_cases.csv")
confirmed <- data %>% select(date, Australia)
colnames(confirmed)[2] <- c("cases")
confirmed$MonthYear <- GetMonthYear(confirmed$date)
confirmed$WeekYear <- tsibble::yearweek(confirmed$date)
return(confirmed)
}
GetCasesLong <- function() {
data <- read.csv("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/cases_deaths/new_cases.csv")
confirmed <- data %>% select(date, Australia)
colnames(confirmed)[2] <- c("cases")
confirmed$MonthYear <- GetMonthYear(confirmed$date)
confirmed$WeekYear <- tsibble::yearweek(confirmed$date)
confirmed_subset_weekwise <- confirmed %>%
group_by(WeekYear) %>%
summarise(cases = mean(cases, na.rm = T)) %>%
arrange(WeekYear)
confirmed_subset_weekwise$cases <- ceiling(confirmed_subset_weekwise$cases)
confirmed_subset_dateweekwise_long_india <- confirmed_subset_weekwise %>%
rename(n = cases) %>%
rename(WeekYearCollected = WeekYear)
}
confirmed <- GetCases()
confirmed_subset_dateweekwise_long <- GetCasesLong()
gisaid_Australia_weekwise <- SummarizeVariantsWeekwise(gisaid_Australia)
Distribution of variants
state_month_counts <- SummarizeVariantsMonthwise(gisaid_Australia)
state_month_counts$State <- "Australia"
state_month_prevalence <- CountsToPrevalence(state_month_counts)
vocs <- GetVOCs()
state_month_prevalence <- CollapseLineageToVOCs(
variant_df = state_month_prevalence,
vocs = vocs,
custom_voc_mapping = custom_voc_mapping, summarize = FALSE
)
p5 <- StackedBarPlotPrevalence(state_month_prevalence)
p5
Project weekly cases to variant prevalence data from GISAID
voc_to_keep <- gisaid_Australia_weekwise %>%
group_by(lineage_collapsed) %>%
summarise(n_sum = sum(n)) %>%
filter(n_sum > 50) %>%
pull(lineage_collapsed) %>%
unique()
gisaid_Australia_weekwise <- gisaid_Australia_weekwise %>% filter(lineage_collapsed %in% voc_to_keep)
Australia_cases_pred_prob_sel_long <- FitMultinomWeekly(gisaid_Australia_weekwise, confirmed_subset_dateweekwise_long)
the_anim <- PlotVariantPrevalenceAnimated(Australia_cases_pred_prob_sel_long, title = "Estimated cases (weekly average) in Australia by variant", caption = "**Source: gisaid.org and ourworldindata.org/coronavirus**<br>", date_breaks = "100 days")
gganimate::anim_save(filename = here::here("docs/articles/Australia_animated.gif"), animation = the_anim)
Look at cases from 2022,
confirmed_subset_dateweekwise_long <- GetCasesLong() %>%
filter(WeekYearCollected >= tsibble::yearweek("2021 W35"))
gisaid_Australia_subset <- gisaid_Australia %>% filter(MonthYearCollected > "Oct 2021")
gisaid_Australia_weekwise <- SummarizeVariantsWeekwise(gisaid_Australia_subset)
voc_to_keep <- gisaid_Australia_weekwise %>%
group_by(lineage_collapsed) %>%
summarise(n_sum = sum(n)) %>%
filter(n_sum > 50) %>%
pull(lineage_collapsed) %>%
unique()
gisaid_Australia_weekwise <- gisaid_Australia_weekwise %>% filter(lineage_collapsed %in% voc_to_keep)
Australia_cases_pred_prob_sel_long <- FitMultinomWeekly(gisaid_Australia_weekwise, confirmed_subset_dateweekwise_long)
the_anim <- PlotVariantPrevalenceAnimated(Australia_cases_pred_prob_sel_long, title = "Estimated cases (weekly average) in Australia by variant", caption = "**Source: gisaid.org and ourworldindata.org/coronavirus**<br>", date_breaks = "100 days")
gganimate::anim_save(filename = here::here("docs/articles/Australia_animated_2021.gif"), animation = the_anim)
Look at cases from 2023
confirmed_subset_dateweekwise_long <- GetCasesLong() %>%
filter(WeekYearCollected >= tsibble::yearweek("2022 W35"))
gisaid_Australia_subset <- gisaid_Australia %>% filter(MonthYearCollected > "October 2022")
gisaid_Australia_weekwise <- SummarizeVariantsWeekwise(gisaid_Australia_subset)
voc_to_keep <- gisaid_Australia_weekwise %>%
group_by(lineage_collapsed) %>%
summarise(n_sum = sum(n)) %>%
filter(n_sum > 50) %>%
pull(lineage_collapsed) %>%
unique()
gisaid_Australia_weekwise <- gisaid_Australia_weekwise %>% filter(lineage_collapsed %in% voc_to_keep)
Australia_cases_pred_prob_sel_long <- FitMultinomWeekly(gisaid_Australia_weekwise, confirmed_subset_dateweekwise_long)
the_anim <- PlotVariantPrevalenceAnimated(Australia_cases_pred_prob_sel_long, title = "Estimated cases (weekly average) in Australia by variant", caption = "**Source: gisaid.org and ourworldindata.org/coronavirus**<br>")
gganimate::anim_save(filename = here::here("docs/articles/Australia_animated_2023.gif"), animation = the_anim)
Look at cases in the past few weeks
confirmed_subset_dateweekwise_long <- GetCasesLong() %>%
filter(WeekYearCollected >= tsibble::yearweek("2023 W23"))
gisaid_Australia_subset <- gisaid_Australia %>% filter(MonthYearCollected > "June 2023")
gisaid_Australia_weekwise <- SummarizeVariantsWeekwise(gisaid_Australia_subset)
voc_to_keep <- gisaid_Australia_weekwise %>%
group_by(lineage_collapsed) %>%
summarise(n_sum = sum(n)) %>%
filter(n_sum > 50) %>%
pull(lineage_collapsed) %>%
unique()
gisaid_Australia_weekwise <- gisaid_Australia_weekwise %>% filter(lineage_collapsed %in% voc_to_keep)
Australia_cases_pred_prob_sel_long <- FitMultinomWeekly(gisaid_Australia_weekwise, confirmed_subset_dateweekwise_long)
the_anim <- PlotVariantPrevalenceAnimated(Australia_cases_pred_prob_sel_long, title = "Estimated cases (weekly average) in Australia by variant", caption = "**Source: gisaid.org and ourworldindata.org/coronavirus**<br>")
gganimate::anim_save(filename = here::here("docs/articles/Australia_animated_2024.gif"), animation = the_anim)