This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Notes on survival analysis | |
author: Gibran Hemani | |
date: "`r Sys.Date()`" | |
output: pdf_document | |
bibliography: survival.bib | |
--- | |
These notes are based on [http://data.princeton.edu/wws509/notes](http://data.princeton.edu/wws509/notes). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In R: | |
load("/panfs/panasas01/shared/alspac/deprecated/gib/aries_renormalised/condanal_results.RData") | |
mprobes <- c("cg06500161", "cg11024682", "cg07094298", "cg04011474", "cg10192877", "cg17782974", "cg20496314", "cg07202479", "cg09494176", "cg17501210", "cg21139312", "cg26403843") | |
b <- subset(condres, CPG %in% mprobes) | |
write.table(unique(b$SNP), file="~/snplist.txt", row=F, col=F, qu=F) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impute <- function(X) | |
{ | |
apply(X, 2, function(x) { | |
x[is.na(x)] <- mean(x, na.rn=T) | |
return(x) | |
}) | |
} | |
# Original matrix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [[ $# > 1 ]] | |
do | |
key="$1" | |
case $key in | |
-g|--rootname) | |
genort="${2}" | |
shift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rowCors = function(x, y) | |
{ | |
sqr = function(x) x*x | |
if(!is.matrix(x)||!is.matrix(y)||any(dim(x)!=dim(y))) | |
stop("Please supply two matrices of equal size.") | |
x = sweep(x, 1, rowMeans(x)) | |
y = sweep(y, 1, rowMeans(y)) | |
cor = rowSums(x*y) / sqrt(rowSums(sqr(x))*rowSums(sqr(y))) | |
return(cor) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("aries_funnorm.randomeffect.pc10.160915.Robj") | |
load("samplesheet_aries.160915.Robj") | |
# Make sure that all the sample_names in samplesheet match the colnames in norm.beta.random | |
all(samplesheet$Sample_Name == colnames(norm.beta.random)) | |
# This is not the case so we need to match things up | |
# Get the intersect | |
ids <- intersect(samplesheet$Sample_Name, colnames(norm.beta.random)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reshape2) | |
library(ggplot2) | |
library(alspac) | |
b <- findVars("bmi") | |
b <- subset(b, cat2=="Clinic" & cat3 == "Child") | |
bmi <- extractVars(b) | |
c <- cor(bmi[,-c(1:3)], use="pair") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m <- 100 | |
n <- 100 | |
eff <- rnorm(m) | |
x <- matrix(rbinom(m*n,2,0.5), n, m) | |
yhat <- x %*% eff | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: A frailty effect is sufficient to explain the apparent association of a smoking heaviness variant on smoking initiation in a cross sectional population | |
date: "`r Sys.Date()`" | |
output: pdf_document | |
bibliography: smoking_age.bib | |
--- | |
```{r, echo=FALSE} | |
opts_chunk$set(warning=FALSE, message=FALSE, echo=FALSE) | |
``` |