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 / thresher-demo
Created April 12, 2018 08:59
Sample code for thresher
#' Load the package
library(Thresher)
#' Generate random data
set.seed(3928270)
ranData <- matrix(rnorm(100*12), ncol=12)
colnames(ranData) <- paste("G", 1:12, sep='')
#' Perform dim reduction
@seabbs
seabbs / ggpres
Created April 10, 2018 08:33
Function to increase graph text size
#' Adjust test size on a ggplot to make it visible in presentations
#'
#' Change the size of text on a \code{ggplot} so that a plot designed to look good in print is readable when included in a slide in a presentation (or vice verse)
#' @param g A \code{ggplot} graph
#' @param title_size The font size for the title, legend title and axes titles
#' @param text_size The font size for for the axis lables, legend text and facet text
#' @return A \code{ggplot} graph
#' @author Ella Kaye
#' @examples
#'
@seabbs
seabbs / rif_res_tb
Created March 15, 2018 11:37
rif resistant TB
## Get packages
if (!require(pacman)) install.packages("pacman"); library(pacman)
p_load_gh("seabbs/getTBinR")
p_load_gh("thomasp85/patchwork")
p_load("tidyverse")
p_load("ggridges")
p_load("viridis")
## Get data
@seabbs
seabbs / dist_tb_inc_region
Last active March 7, 2018 13:42
Exploring distributions of TB incidence rates over time by region
## Get required packages, managed via pacman
if (!require(pacman)) install.packages("pacman"); library(pacman)
p_load("getTBinR")
p_load("tidyverse")
p_load("viridis")
p_load("hrbrthemes")
p_load("ggridges")
p_load_gh("thomasp85/patchwork", dependencies = TRUE)
@seabbs
seabbs / com_tb_inc_mort
Created February 14, 2018 11:04
Comparison of regional TB incidence and mortality rates
# install.packages("getTBinR")
library(getTBinR)
# install.packages("tidyverse")
library(tidyverse)
# install.packages("viridis")
library(viridis)
# install.packages("hrbrthemes")
library(hrbrthemes)
# install.packages("scales")
library(scales)
@seabbs
seabbs / HIV_and_TB
Last active January 31, 2018 11:33
Exploring HIV and TB incidence in high burden countries
# install.packages("getTBinR")
library(getTBinR)
# install.packages("tidyverse")
library(tidyverse)
# install.packages("gridExtra")
library(gridExtra)
# Get the data - WHO data
tb_df <- get_tb_burden()
dict <- get_data_dict()
@seabbs
seabbs / run_tb_dashboard_ex
Created January 28, 2018 10:22
Run Explore Global TB dashboard
## Get the package
install.packages("getTBinR")
## Run the dashboard - if the dependencies are not installed you will be asked to install them.
getTBinR::run_tb_dashboard()
@seabbs
seabbs / leaflet_tb
Created January 25, 2018 15:15
Playing with leaflet and TB data
mapStates = map("state", fill = TRUE, plot = FALSE)
leaflet(data = mapStates) %>% addTiles() %>%
addPolygons(fillColor = topo.colors(10, alpha = NULL), stroke = FALSE)
@seabbs
seabbs / tab_ci
Last active January 16, 2018 16:41
Tableau R code ci
FLOAT(SCRIPT_REAL("qbinom(0.001, .arg2, .arg1 / .arg2) / .arg2",
WINDOW_SUM(SUM([prob_Accepted]), -[No. of days for rolling average] + 1, 0),
WINDOW_SUM(COUNT([prob_Accepted]), -[No. of days for rolling average] + 1, 0)))
@seabbs
seabbs / explore_case_detection
Created January 11, 2018 16:16
Explore case detection and incidence rates in the WHO Tuberculosis data
# install.packages("getTBinR")
library(getTBinR)
# install.packages("tidyverse")
library(tidyverse)
# install.packages("gridExtra")
library(gridExtra)
# Get the data
tb_burden <- get_tb_burden(download_data = TRUE, save = TRUE)
dict <- get_data_dict(download_data = TRUE, save = TRUE)