Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Added EM algorithm with 2 random effects
Browse files Browse the repository at this point in the history
  • Loading branch information
GAYNOR Chris committed Nov 19, 2018
1 parent 03bab12 commit 76a803a
Show file tree
Hide file tree
Showing 14 changed files with 428 additions and 73 deletions.
14 changes: 8 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Package: AlphaMME
Type: Package
Title: Alpha Mixed Model Equations
Version: 0.1.0
Date: 2018-01-25
Authors@R: c(person("Chris","Gaynor",email="[email protected]",role="cre"))
Description: This package contains mixed model equation solvers written in C++.
Version: 0.1.1
Date: 2018-11-04
Authors@R: c(person("Chris","Gaynor",email="[email protected]",role=c("aut","cre")))
Description: Fast mixed model solvers for genomic selection. All solvers are written in C++
and based on solvers found in other R packages.
License: MIT + file LICENSE
URL: https://bitbucket.org/hickeyjohnteam/alphamme
Imports: Rcpp (>= 0.12.13), RcppArmadillo
Imports: Rcpp (>= 0.12.13)
LinkingTo: Rcpp, RcppArmadillo
RoxygenNote: 6.0.1
Encoding: UTF-8
RoxygenNote: 6.1.0
NeedsCompilation: true
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export(solveMVM)
export(solveRRBLUP)
export(solveRRBLUPMK)
export(solveRRBLUPMV)
export(solveRRBLUP_EM)
export(solveRRBLUP_EM2)
export(solveUVM)
import(Rcpp)
import(RcppArmadillo)
Expand Down
9 changes: 6 additions & 3 deletions R/AlphaMME.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#' @title Alpha Mixed Model Equations
#'
#' @description
#' This package contains mixed model equation solvers written in C++.
#' This package is designed for genomic selection. It contains
#' several mixed model equation solvers from other R packages.
#' The solvers have been rewritten in C++ and streamlined for
#' increased speed and more efficient memory usage.
#'
#' @docType package
#' @name AlphaMME-package
NULL
#' @name AlphaMME
NULL
53 changes: 49 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#' file. Requires knowledge of the number of rows
#' and columns in the file.
#'
#' @param fileName path to the file to read
#' @param fileName path to the file being read
#' @param rows number of rows to read in
#' @param cols number of columns to read in
#' @param sep a single character seperating data entries
#' @param sep a single character delimiter seperating data entries
#' @param skipRows number of rows to skip
#' @param skipCols number of columns to skip
#'
Expand Down Expand Up @@ -109,10 +109,11 @@ solveRRBLUPMV <- function(Y, X, M, tol = 1e-6, maxIter = 1000L) {
#' @param Zlist a list of Z matrices
#' @param Klist a list of K matrices
#' @param maxIter maximum number of iteration
#' @param tol tolerance for convergence
#'
#' @export
solveMKM <- function(y, X, Zlist, Klist, maxIter = 40L) {
.Call(`_AlphaMME_solveMKM`, y, X, Zlist, Klist, maxIter)
solveMKM <- function(y, X, Zlist, Klist, maxIter = 40L, tol = 1e-4) {
.Call(`_AlphaMME_solveMKM`, y, X, Zlist, Klist, maxIter, tol)
}

#' @title Solve Multikernel RR-BLUP
Expand All @@ -130,6 +131,50 @@ solveRRBLUPMK <- function(y, X, Mlist, maxIter = 40L) {
.Call(`_AlphaMME_solveRRBLUPMK`, y, X, Mlist, maxIter)
}

#' @title Solve RR-BLUP with EM
#'
#' @description
#' Solves a univariate mixed model of form \eqn{y=X\beta+Mu+e} using
#' the Expectation-Maximization algorithm.
#'
#' @param Y a matrix with n rows and 1 column
#' @param X a matrix with n rows and x columns
#' @param M a matrix with n rows and m columns
#' @param Vu initial guess for variance of marker effects
#' @param Ve initial guess for error variance
#' @param tol tolerance for declaring convergence
#' @param maxIter maximum iteration for attempting convergence
#' @param useEM should EM algorithm be used. If false, no estimation of
#' variance components is performed. The initial values are treated as true.
#'
#' @export
solveRRBLUP_EM <- function(Y, X, M, Vu, Ve, tol = 1e-6, maxIter = 100L, useEM = TRUE) {
.Call(`_AlphaMME_solveRRBLUP_EM`, Y, X, M, Vu, Ve, tol, maxIter, useEM)
}

#' @title Solve RR-BLUP with EM and 2 random effects
#'
#' @description
#' Solves a univariate mixed model of form \eqn{y=X\beta+M_1u_1+M_2u_2+e} using
#' the Expectation-Maximization algorithm.
#'
#' @param Y a matrix with n rows and 1 column
#' @param X a matrix with n rows and x columns
#' @param M1 a matrix with n rows and m1 columns
#' @param M2 a matrix with n rows and m2 columns
#' @param Vu1 initial guess for variance of the first marker effects
#' @param Vu2 initial guess for variance of the second marker effects
#' @param Ve initial guess for error variance
#' @param tol tolerance for declaring convergence
#' @param maxIter maximum iteration for attempting convergence
#' @param useEM should EM algorithm be used. If false, no estimation of
#' variance components is performed. The initial values are treated as true.
#'
#' @export
solveRRBLUP_EM2 <- function(Y, X, M1, M2, Vu1, Vu2, Ve, tol = 1e-6, maxIter = 100L, useEM = TRUE) {
.Call(`_AlphaMME_solveRRBLUP_EM2`, Y, X, M1, M2, Vu1, Vu2, Ve, tol, maxIter, useEM)
}

#' @title Calculate G Matrix
#'
#' @description
Expand Down
9 changes: 0 additions & 9 deletions man/AlphaMME-package.Rd

This file was deleted.

13 changes: 13 additions & 0 deletions man/AlphaMME.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/readMat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/solveMKM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions man/solveRRBLUP_EM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions man/solveRRBLUP_EM2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 76a803a

Please sign in to comment.