library(data.table) library(ggplot2) library(here)
cases <- fread("https://raw.githubusercontent.com/KITmetricslab/covid19-forecast-hub-de/master/data-truth/RKI/truth_RKI-Incident%20Cases_Germany.csv") # nolint # Restrict to cases in Germany and format date cases <- cases[location == "GM"] cases[, date := as.Date(date)] # Summarise to weekly cases starting on Saturday to Sync with the forecast hubs cases[, cases := frollsum(value, n = 7)] # Filter from the 20th March and keep only Saturdays cases <- cases[date >= as.Date("2021-03-20")] cases <- cases[weekdays(date) %in% "Saturday"] # Only most recennt case data is available cases[, cases_available := date] # Drop unnecessary columns set(cases, j = c("value", "location", "location_name"), value = NULL) # Summary summary(cases)
sequences <- fread("https://raw.githubusercontent.com/dwolffram/covid19-variants/main/data/sequencing_germany.csv") # nolint # Get total sequence count sequences[, seq_total := rowSums(.SD, na.rm = TRUE), .SDcols = grep("_count", colnames(sequences)) ] # Pull out and format variables of interest sequences <- sequences[ , .( date = week_end, seq_total, seq_voc = B.1.617.2_count, share_voc = B.1.617.2_proportion / 100, seq_available ) ] # Check sequence totals and proportions sequences[, est_seq_total := seq_voc / share_voc] # Replace proprotion using totals and voc sequences sequences[, share_voc := seq_voc / seq_total][, est_seq_total := NULL] # Include sequences from 18th of April sequences <- sequences[date >= as.Date("2021-04-18")] # Summary summary(sequences)
notifications <- merge(cases, copy(sequences)[, date := date - 1], by = "date", all.x = TRUE ) notifications[, `:=`(location_name = "Germany", location = "DE")] setcolorder(notifications, c("date", "location_name", "location")) # save to observations folder fwrite(notifications, file = here("data/observations/rki.csv")) # Summary summary(notifications)
ggplot(unique(notifications[, .(date, cases)])) + aes(x = date, y = cases) + geom_col(alpha = 0.8) + theme_bw()
ggplot(notifications[!is.na(share_voc)]) + aes(x = date, y = share_voc, col = seq_available, group = seq_available) + geom_point(size = 1.1, alpha = 0.8) + geom_line(alpha = 0.6) + theme_bw() + theme(legend.position = "bottom")
latest_seq <- notifications[, .SD[seq_available == max(seq_available)], by = date ] seq_change <- merge( notifications[, .(date, share_voc, seq_available)], latest_seq[, .(date, latest_voc = share_voc)], by = "date" ) seq_change[, per_latest := share_voc / latest_voc] ggplot(seq_change) + aes(x = date, y = per_latest, col = seq_available, group = seq_available) + geom_point(size = 1.1, alpha = 0.8) + geom_line(alpha = 0.6) + theme_bw() + theme(legend.position = "bottom")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.