Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
## Read in a binary GRM from GCTA as a matrix | |
## see https://cnsgenomics.com/software/gcta/#MakingaGRM | |
library(Matrix) | |
read_grm_bin <- function(prefix, size=4) { | |
bin_filename <- paste(prefix, 'grm.bin', sep='.') | |
n_filename <- paste(prefix, 'grm.N.bin', sep='.') | |
id_filename <- paste(prefix, 'grm.id', sep='.') |
This file contains 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
dat <- data.frame(obs=c(rep(0, times=100), rnorm(100, 10, 1))) | |
# observed data looks something like | |
hist(dat$obs) | |
# break into the zero-part and the normal part of the distribution | |
# observed zeros get zero for the first part, otherwise 1 | |
# observed zeros get NA for the second part, otherwise observed value | |
dat <- transform(dat, zero_part=ifelse(obs == 0, yes=0, no=1), | |
norm_part=ifelse(obs != 0, yes=obs, no=NA)) |
This file contains 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/sh | |
java -jar /path/to/GenomeAnalysisTK.jar $@ |
This file contains 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
# GCTA-power analysis | |
# see http://spark.rstudio.com/ctgg/gctaPower/ | |
# http://www.plosgenetics.org/article/info%3Adoi%2F10.1371%2Fjournal.pgen.1004269 | |
# Bivariate analysis (traits measured on different sets of individuals) | |
bivariate_2sample_power <- function (N1=4000, N2=4000, rG=0.5, h2_1=0.2, h2_2=0.2, varA=0.00002, alpha=0.05) { | |
# variance of genetic correlation (Equation 10) | |
var_rG <- |
This file contains 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
> n <- nrow(CC) | |
> Q <- INLA:::inla.pc.bym.Q(border, scale.model=TRUE) | |
> u <- .2/.31 | |
> alpha <- .01 | |
> phi.u <- .5 | |
> phi.alpha <- 2/3 | |
> formula2 <- agr ~ age + sex + age:sex + | |
+ f(geo, model='bym2', graph=border, | |
+ constr=TRUE, scale.model=TRUE, | |
+ hyper=list(phi=list(prior='pc', |
This file contains 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(MCMCglmm) | |
library(mvtnorm) | |
# separate covariances for each sex | |
Rf <- matrix(c(1, .4, .4, 1), nrow=2) | |
Rm <- matrix(c(1, 0, 0, 1), nrow=2) | |
# Simulate correlated phenotypes | |
females <- data.frame(rmvnorm(100, mean=c(0, 0), sigma=Rf)) | |
males <- data.frame(rmvnorm(100, mean=c(0, 0), sigma=Rm)) |
This file contains 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
# Spatial kernel for mixed-effects model | |
library(geosphere) # for distances between countries | |
library(ggplot2) | |
# Life-expectancy (le) and center coordinates | |
geo <- structure(list(ISO = structure(1:10, .Label = c("ALB", "BIH", "GRC", "HRV", "ITA", "MKD", "MLT", "MNE", "SRB", "TUN"), class = "factor"), Country = structure(c(1L, 2L, 4L, 3L, 5L, 6L, 7L, 8L, 9L, 10L), .Label = c("Albania", "Bosnia and Herzegovina", "Croatia", "Greece", "Italy", "Macedonia, FYR", "Malta", "Montenegro", "Serbia", "Tunisia"), class = "factor"), le = c(70.4, 70.7, 75.2, 70.5, 74.5, 69.6, 73.6, 74.1, 70.2, 64.1), longitude = c(20, 18, 22, 15.5, 12.8333, 22, 14.5833, 19, 21, 9), latitude = c(41, 44, 39, 45.1667, 42.8333, 41.8333, 35.8333, 42, 44, 34)), .Names = c("ISO", "Country", "le", "longitude", "latitude"), row.names = 1:10, class = "data.frame") | |
latlong <- geo[c('longitude', 'latitude')] |
This file contains 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
$ sudo R CMD INSTALL . | |
* installing to library ‘/usr/local/lib/R/library’ | |
* installing *source* package ‘....’ ... | |
Error : Invalid DESCRIPTION file | |
Required fields missing: | |
License | |
See the information on DESCRIPTION files in section 'Creating R | |
packages' of the 'Writing R Extensions' manual. |
NewerOlder