Skip to content

Instantly share code, notes, and snippets.

@jwaage
jwaage / MB_packload.R
Last active March 3, 2016 14:14
Microbiome package loader
source("lib/check_packages.R")
check_packages()
load("data/ubp_phyloseq_metagenomeseq.RData")
library(vegan)
library(ggplot2)
library(cluster)
library(phyloseq)
library(cowplot)
library(reshape2)
library(scales)
@jwaage
jwaage / getGenotypes.R
Created January 25, 2016 11:10
Get genotypes from SQL server (must be on COPSAC net)
getSNPImputed <- function(SNPs)
{
#Counting allele 1
if (!require("data.table")) stop("Install packages data.table")
if (!require("RMySQL")) stop("Install packages RMySQL")
if (!require("rio")) stop("Install packages rio")
if (!require("gtools")) stop("Install packages gtools")
convertProbsToDoses <- function(props, alleleToReturnAorB="A")
@jwaage
jwaage / COPSAC_KM.R
Created January 25, 2016 11:09
Survival analysis and kaplan meyer plots
# Welcome to the COPSAC ggplot Kaplan-Meier template. It builds nice and very customizable KM curves as shown below. Please run the two functions to load into memory, it works like a SAS macro.
# Load dependencies
library(survival)
library(ggplot2)
library(cowplot)
library(reshape2)
# Run these functions to load into memory
# Define custom function to create a survival data.frame. Credit http://www.ceb-institute.org/bbs/wp-content/uploads/2011/09/handout_ggplot2.pdf
createSurvivalFrame <- function(f.survfit){