Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa3c345
commit e100c93
Showing
11 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
Package: rrBLUP | ||
Title: Ridge regression and other kernels for genomic selection | ||
Version: 2.5 | ||
Version: 2.7 | ||
Author: Jeffrey Endelman | ||
Maintainer: Jeffrey Endelman <j.endelman@gmail.com> | ||
Description: One application is to estimate marker effects by ridge regression; alternatively, BLUPs can be calculated based on kinship. The genetic covariance between lines can be modeled using a marker-based, additive relationship matrix, or via Gaussian and exponential kernels. | ||
Depends: Matrix | ||
License: GPL-3 | ||
LazyLoad: yes | ||
Packaged: 2011-11-23 15:18:07 UTC; jeffendelman | ||
Packaged: 2011-12-01 21:44:59 UTC; jeffendelman | ||
Repository: CRAN | ||
Date/Publication: 2011-11-23 16:04:50 | ||
Date/Publication: 2011-12-02 16:23:08 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
ebd0f441dd7cc78ac5317311a1315f55 *DESCRIPTION | ||
725cf45b6b4fc35a46619125c9a56ed5 *NAMESPACE | ||
c0b87a2036de8c52f506910c514b523e *R/A.mat.R | ||
7ffecd7c7d19252b56998ccd147228c4 *DESCRIPTION | ||
cb2bbc1c5b8ede3c305c7f88a3534ab4 *NAMESPACE | ||
1b905944441d29705c33c76a49c037b0 *R/A.mat.R | ||
ed40c1ee328c5c1a360f8f19e1c3da6f *R/GWA.R | ||
1eb18cf7496f7a40675c50be85207f5b *R/impute.R | ||
12d0dfead32ae78381bb56fe1b09573e *R/kinship.BLUP.R | ||
2a44ea8e534f08600a1cb26458a8ae28 *R/mixed.solve.R | ||
17386c1cd7a17192e8fd416a61490556 *R/kinship.BLUP.R | ||
e6a37c2566e88f73c91bd18120dd5923 *R/mixed.solve.R | ||
b74e4e9e2c643e550a83c5ee4eb7e905 *inst/CITATION | ||
ac7f617ca9597ea9a6c7dae0442cf0b6 *man/A.mat.Rd | ||
be5fbfb20ec993da916e34e007aabbe0 *man/GWA.Rd | ||
5f2221a320a663d862e94a88b6b6f8db *man/impute.Rd | ||
4c7aa162fd21063299e894fed121f018 *man/kinship.BLUP.Rd | ||
db24d688f1817159d86971b2500c5a54 *man/mixed.solve.Rd | ||
cdbdc329a3d94433d03b1cfbc9b4fe22 *man/A.mat.Rd | ||
30f584df388d3bd33156b8b0d23c3f1e *man/GWA.Rd | ||
10f9448d8e12fd7ae964728e953fb2aa *man/impute.Rd | ||
9e7862d767ca15b2e4416b9bce8254b0 *man/kinship.BLUP.Rd | ||
8b32359363bbf005fb6ee26ea7dd6725 *man/mixed.solve.Rd |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
importFrom(Matrix,nearPD) | ||
export(mixed.solve,impute,GWA,kinship.BLUP,A.mat) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,60 @@ | ||
A.mat <- function(G,method,min.MAF=0.01) { | ||
method = toupper(method) | ||
freq <- colMeans(G+1)/2 | ||
markers <- which((freq >= min.MAF)&(1-freq >= min.MAF)) | ||
freq <- freq[markers] | ||
G <- G[,markers] | ||
m <- ncol(G) | ||
n <- nrow(G) | ||
|
||
if (method=="IBS") { | ||
A <- tcrossprod(G)/m+1 | ||
} else if (method=="UAR") { | ||
X <- G + 1 | ||
Y <- t(t(X)/sqrt(2*freq*(1-freq))) | ||
c <- sqrt(2*freq/(1-freq)) | ||
z <- matrix(colSums(t(Y)*c),n,1) | ||
one <- matrix(rep(1,n),n,1) | ||
q <- sum(c^2) | ||
A <- (tcrossprod(Y)-tcrossprod(one,z)-tcrossprod(z,one)+tcrossprod(one)*q)/m | ||
} else {stop("Invalid method")} | ||
A | ||
} | ||
A.mat <- function(G,method="IBS",min.MAF=0.01,max.missing=1,PD=TRUE) { | ||
|
||
crossprod.na <- function(x1,x2) { | ||
mean(x1 * x2,na.rm=TRUE) | ||
} | ||
tcrossprod.na <- function(G) { | ||
apply(G,1,function(x,G){apply(G,1,crossprod.na,x)},G) | ||
} | ||
|
||
method <- toupper(method) | ||
n <- nrow(G) | ||
|
||
if (length(which(is.na(G))) > 0) { | ||
|
||
freq <- apply(G+1,2,function(x){mean(x,na.rm=TRUE)})/2 | ||
frac.missing <- apply(G,2,function(x){length(which(is.na(x)))})/n | ||
markers <- which((freq >= min.MAF)&(1-freq >= min.MAF)&(frac.missing < max.missing)) | ||
freq <- freq[markers] | ||
G <- G[,markers] | ||
m <- ncol(G) | ||
|
||
if (method=="IBS") { | ||
A <- tcrossprod.na(G)+1 | ||
} else if (method=="UAR") { | ||
X <- G + 1 | ||
Y <- t(t(X)/sqrt(2*freq*(1-freq))) | ||
c <- sqrt(2*freq/(1-freq)) | ||
z <- matrix(colMeans(t(Y)*c,na.rm=TRUE),n,1) | ||
one <- matrix(rep(1,n),n,1) | ||
q <- mean(c^2) | ||
A <- tcrossprod.na(Y)-tcrossprod(one,z)-tcrossprod(z,one)+tcrossprod(one)*q | ||
} else {stop("Invalid method")} | ||
|
||
if (PD) { | ||
as.matrix(nearPD(A)$mat) | ||
} else {A} | ||
|
||
} else { | ||
|
||
freq <- colMeans(G+1)/2 | ||
markers <- which((freq >= min.MAF)&(1-freq >= min.MAF)) | ||
freq <- freq[markers] | ||
G <- G[,markers] | ||
m <- ncol(G) | ||
|
||
if (method=="IBS") { | ||
A <- tcrossprod(G)/m+1 | ||
} else if (method=="UAR") { | ||
X <- G + 1 | ||
Y <- t(t(X)/sqrt(2*freq*(1-freq))) | ||
c <- sqrt(2*freq/(1-freq)) | ||
z <- matrix(colSums(t(Y)*c),n,1) | ||
one <- matrix(rep(1,n),n,1) | ||
q <- sum(c^2) | ||
A <- (tcrossprod(Y)-tcrossprod(one,z)-tcrossprod(z,one)+tcrossprod(one)*q)/m | ||
} else {stop("Invalid method")} | ||
|
||
A | ||
} # if missing data | ||
} |
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
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
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
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
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
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
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