Skip to content

Instantly share code, notes, and snippets.

View chr1swallace's full-sized avatar

Chris Wallace chr1swallace

View GitHub Profile
@chr1swallace
chr1swallace / T1DManhattan.R
Created October 14, 2015 08:45
Create a Manhattan plot of T1D GWAS statistics downloaded from T1DBase
## download https://www.t1dbase.org/downloads/protected_data/GWAS_Data/hg19_gwas_t1d_barrett_4_18_0.gz
## you will need to create a login!
## Then...
x <- read.table("hg19_gwas_t1d_barrett_4_18_0.gz",sep="\t",skip=1,as.is=TRUE)
colnames(x) <- c("snp","Chr","Pos","PValue","OR","kk")
## libraries
library(ggplot2)
library(cowplot) # nicer ggplot theme
@chr1swallace
chr1swallace / gantt.R
Created November 7, 2014 07:19
create a timeline
# replace "gantt.csv" with path to wherever your .csv file is stored
x <- read.table("gantt.csv",sep=",",as.is=TRUE, header=TRUE) # read data
## look at what we read, check it makes sense
head(x)
## make sure dates are recognised as such
x$Start <- as.Date(x$Start)
x$End <- as.Date(x$End)
@chr1swallace
chr1swallace / fit-normals.R
Created April 30, 2014 08:33
Fits a two Guassian mixture model, assuming Z ~ N(0,1) with prob pi0, N(0,1+sigma^2) with prob 1-pi0.
##' Fit a specific two Guassian mixture distribution
##'
##' Assumes Z ~ N(0,1) with prob pi0,
##' Z ~ N(0,1+sigma^2) with prob 1-pi0
##'
##' Aims to estimate sigma^2 and pi0.
##'
##' @title fit.em
##' @param Z numeric vector of observed data
##' @param s2 initial value for sigma^2