Skip to content

Instantly share code, notes, and snippets.

View seabbs's full-sized avatar
🏠
Working from home

Sam Abbott seabbs

🏠
Working from home
View GitHub Profile
@seabbs
seabbs / explore-covid-19-data-truncation
Last active September 30, 2021 16:20
Explores Covid-19 data truncation in England (i.e when data is updated in later releases) using an experimental model in EpiNow2. By default looks at test positive cases but this can be updated by changing the selected variable in line 27.
# Note: estimate_truncation is experimental so use this for exploratory purposes
# only and/or with a high level of interpretation
# Packages ----------------------------------------------------------------
# install packages
# install.packages(c("data.table", "purrr", "remotes", "EpiNow2"))
library(data.table)
library(purrr)
library(covidregionaldata)
library(EpiNow2)
@seabbs
seabbs / covid19-utla-rt-from-admissions.R
Last active June 9, 2021 12:17
R code using {covid19.nhs.data} and estimates from epiforecasts.io/covid to generate a gif of the effective reproduction for Covid-19 using hospital admissions by upper-tier local authority in England.
# Packages ----------------------------------------------------------------
library(covid19.nhs.data)
library(vroom)
library(dplyr)
library(tidyr)
library(lubridate)
library(gganimate)
#devtools::install_github("thomasp85/transformr")
library(transformr)
library(gifski)
@seabbs
seabbs / covidregionaldata-0.9.1-overview.R
Created May 7, 2021 14:50
An overview of the features included in the 0.9.1 release of covidregionaldata. See the release notes for more details: https://github.com/epiforecasts/covidregionaldata/releases/tag/v0.9.1
library(covidregionaldata)
# set up a data cache
start_using_memoise()
#> Using a cache at: /tmp/RtmphiSeWY
# check for supported countries
get_available_datasets()
#> # A tibble: 18 x 8
#> origin class level_1_region level_2_region level_3_region type data_urls
@seabbs
seabbs / process-rt.R
Created March 9, 2021 11:18
Example script for processing samples.
# Packages ----------------------------------------------------------------
require(data.table, quietly = TRUE)
require(EpiNow2, quietly = TRUE)
require(purrr)
require(ggplot2)
# Target date -------------------------------------------------------------
creation_date <- Sys.Date()
extraction_date <- creation_date
@seabbs
seabbs / covid19-ltla-admissions.R
Last active January 25, 2021 14:53
R code using {covid19.nhs.data} to generate a gif of weekly Covid-19 hospital admissions by lower-tier local authority in England.
# Packages ----------------------------------------------------------------
library(covid19.nhs.data)
library(dplyr)
library(tidyr)
library(lubridate)
library(gganimate)
#devtools::install_github("thomasp85/transformr")
library(transformr)
library(gifski)
library(ggplot2)
@seabbs
seabbs / covid19-utla-admissions.R
Last active January 25, 2021 14:52
R code using {covid19.nhs.data} to generate a gif of Covid-19 hospital admissions byupper-tier local authority in England.
# Packages ----------------------------------------------------------------
library(covid19.nhs.data)
library(dplyr)
library(tidyr)
library(lubridate)
library(gganimate)
#devtools::install_github("thomasp85/transformr")
library(transformr)
library(gifski)
library(ggplot2)
@seabbs
seabbs / update-site.sh
Last active September 10, 2020 09:23
#!bin/bash
cd /home/azureuser/
git clone git@github.com:epiforecasts/covid-rt-estimates.git
cd covid-rt-estimates
sudo bash bin/update-docker.sh "build"
sudo bash bin/update-via-docker.sh
FILE=last-update/update-complete
while [ ! -f "$FILE" ]; do
#!bin/bash
cd /home/azureuser/covid-rt-estimates
git add --all
git commit -m "update estimates"
git push
@seabbs
seabbs / change_with_rw_padding
Last active August 21, 2020 17:26
Evaluates Rt over two fixed time points with Rt assumed to vary based on a random walk in-between the two time points and after a period of time.
library(EpiNow2)
library(data.table)
# Get example case counts
reported_cases <- EpiNow2::example_confirmed[1:60]
# Add a dummy breakpoint (used only when optionally estimating breakpoints)
reported_cases <- reported_cases[, breakpoint := data.table::fifelse((date >= as.Date("2020-03-16") & date <= as.Date("2020-03-29")) | date >= as.Date("2020-04-11"),
1, 0)]
# Set up example generation time
@seabbs
seabbs / update-rt-estimates.sh
Last active August 17, 2020 19:38
Update Rt estimates on a remote server over SSH. Run with: sudo bash update-rt-estimates.sh server-public-ip
#!/bin/bash
# Get rid of the older update script
rm update-via-ssh.sh
# Get the new update script
curl --fail https://raw.githubusercontent.com/epiforecasts/covid-rt-estimates/master/bin/update-via-ssh.sh > update-via-ssh.sh
# Run the update script
bash update-via-ssh.sh ~/.ssh/id_rsa azureuser@$1 github-username-here github-pat-here