Skip to content

Instantly share code, notes, and snippets.

./plink --bfile GWAStutorial --out penn --make-bed
./plink --bfile penn --out qc_penn --maf 0.05 --hwe 0.0000001 --make-bed
awk -F "," 'NR>1 {print $1" 1 "$3" "$4}' GWAStutorial_clinical.csv> PENN.cov
awk -F "," 'NR>1 {print $1" 1 "$2+1}' GWAStutorial_clinical.csv> CAD.pheno
awk -F "," 'NR>1 && $5!~/NA/ {print $1" 1 "$5}' GWAStutorial_clinical.csv> TG.pheno
awk -F "," 'NR>1 && $6!~/NA/ {print $1" 1 "$6}' GWAStutorial_clinical.csv> HDL.pheno
awk -F "," 'NR>1 && $7!~/NA/ {print $1" 1 "$7}' GWAStutorial_clinical.csv> LDL.pheno
./plink --bfile qc_penn --out qc_CAD --pheno CAD.pheno --assoc --ci 0.95
@skoyama427
skoyama427 / MVMCMC.R
Created March 12, 2017 13:23
Multivariate additive model with MCMC
library(rstan)
library(MASS)
stanmodel <- "
data {
int N;
real x[N];
vector[2] y[N];
@skoyama427
skoyama427 / MVRNORM.R
Last active March 12, 2017 03:32
BayesianMVRNORM.R
stanmodel <- "
data {
int N;
matrix[N,2] X;
}
parameters {
library(mass)
library(mvtnorm)
set.seed(31415)
MU <- c(10, 30)
SIGMA <- c(20, 40)
RHO <- -0.7
CVM <- rbind(c(SIGMA[1]^2, SIGMA[1]*SIGMA[2]*RHO),
@skoyama427
skoyama427 / BayesianLASSO2.R
Last active February 7, 2017 13:53
BayesianLASSO modified
stancodeLASSO="
data {
int N;
int M;
vector[N] Y;
matrix[N, M] X;
}
parameters {
real<lower=0> S;
vector[M] B;
@skoyama427
skoyama427 / LASSO
Created February 5, 2017 14:12
Lasso regression
library(psych)
library(glmnet)
set.seed(1)
x1 <- rnorm(30); x2 <- rnorm(30); x3 <- rnorm(30); e <- rnorm(30)
X <- matrix(c(x1, x2, x3), byrow = F, ncol = 3) #explanatory variables
y <- 3 + 0.01*x1 + 0.01*x2 + 5*x3 + rnorm(30) #y is a linear combination of x1x2x3
fit <-glmnet(x = X, y = y, alpha = 1) #fit use glmnet (alpha=1 : LASSO)
@skoyama427
skoyama427 / tmux.cheat
Created February 2, 2017 10:16
Tmux cheat sheet
[[Session handling]]
<check session>
$ tmux ls
<attach>
$ tmux a -t 2
<detach>
PREFIX d
@skoyama427
skoyama427 / file0.txt
Created January 28, 2017 13:32
行列の形を保ったままapply ref: http://qiita.com/skoyama427/items/363fd86e6635bbd08ecb
m <- c(1:9, 3, 3)
structure(sapply(m, sqrt), dim=m))
structure(vapply(m, sqrt, numeric(1)), dim=m))
m[] <- sapply(m, sqrt)
m[] <- vapply(m, sqrt, numeric(1))
@skoyama427
skoyama427 / .vimrc
Created January 8, 2017 11:11
vimrc
set nohlsearch
set cursorline
set mouse=a
set noswapfile
set nobackup
set noundofile
set showmatch
set matchtime=1
set ttimeoutlen=10
set number