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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / wrapper-dockerfile
Created April 24, 2018 17:35
wrapper docker file to overwrite server
FROM seabbs/showmeperseus:latest
MAINTAINER "Sam Abbott" contact@samabbott.co.uk
WORKDIR /home/rstudio/ShowMePerseus
EXPOSE 3838
CMD R -e 'shiny::runApp(port = 3838)'
@seabbs
seabbs / splash.5.4.getTBinR
Last active May 16, 2018 11:16
splash image for getTBinR 5.4
## Get required packages - managed using pacman
if (!require(pacman)) install.packages("pacman"); library(pacman)
p_load("getTBinR")
p_load("ggplot2")
p_load("viridis")
p_load("dplyr")
p_load("forcats")
p_load("ggridges")
p_load_gh("thomasp85/patchwork")