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
| # Claas Heuer, July 2015 | |
| # first get svn | |
| sudo apt-get install subversion | |
| # get the r-forge project: | |
| mkdir project | |
| cd project | |
| svn checkout svn+ssh://cheuer@r-forge.r-project.org/svnroot/cgen/ |
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
| # Claas Heuer, July 2015 | |
| # adopted from: http://www.r-bloggers.com/setup-up-the-inverse-of-additive-relationship-matrix-in-r/ | |
| ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), | |
| fid=c( NA, NA, 2, 2, 4, 2, 5, 5, NA, 8), | |
| mid=c( NA, NA, 1, NA, 3, 3, 6, 6, NA, 9)) | |
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
| # Claas Heuer, 2015 | |
| library(cpgen) | |
| library(pedigreemm) | |
| library(MCMCglmm) | |
| setwd("/home/claas/kaki/Analysedaten") | |
| X<-cscanx("Xa") |
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
| # Claas Heuer, 2015 | |
| library(rjags) | |
| # some data | |
| n = 1296 | |
| p_success <- 0.94 | |
| x <- as.integer(p_success*n) | |
| y <- c(rep(1,x),rep(0,n-x)) |
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
| # Claas Heuer, 2015 | |
| # plotting distributions (or any function) | |
| # is straightforward using the 'curve' function | |
| # lets plot the pdf of a normal distribution with mean=0 and sd=1 | |
| curve(dnorm(x,0,1),from = -10, to = 10, n = 100) | |
| # 'curve' evaluates the function given as first argument with one unknown over |
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
| # Claas Heuer, 2015 | |
| # | |
| # Generating 2 random vectors | |
| # that have some given correlation | |
| # | |
| # actually, this is a covariance | |
| cor = 0.98 | |
| # sample size |
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(MCMCglmm) | |
| n = 10000 | |
| x <- rnorm(n) | |
| y <- rnorm(n) | |
| dat <- data.frame(x=x,y=y) | |
| model <- MCMCglmm(cbind(y,x)~ -1 + trait,rcov= ~us(trait):units, data=dat, family=c("gaussian","gaussian")) |
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
| # modified from Marvin Gertz, 2015 | |
| # | |
| # Custom BLUP ############ | |
| blupLHS <- function (formula, ped, data, alpha, trim = FALSE) | |
| { | |
| colnames(ped)[1:3] <- c("ID", "SIRE", "DAM") | |
| if (any(!all.vars(formula) %in% colnames(ped))) | |
| stop("Formula has variables which are not present in the data.") | |
| ww <- match(all.vars(formula)[-1], colnames(ped)) | |
| ped$b <- apply(ped, 1, function(x) !any(is.na(x[ww]))) |
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
| # get dependencies | |
| # X11 stuff | |
| sudo yum install libXt-devel | |
| sudo yum install libX11-devel | |
| # readline | |
| sudo yum install readline-devel | |
| # get R |
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
| # Centos 6.5 comes with very old packages | |
| # first we need to get git | |
| sudo yum install git | |
| # then update binutils to build OpenBLAS | |
| # this is also needed | |
| sudo yum install texinfo |