User Tools

Site Tools


APY in BLUPF90 programs


The algorithm for proven and young is used to generate a sparse representation of $\mathbf{G}^{-1}$, allowing ssGBLUP evaluations for millions of genotyped animals Misztal (2016). With the APY algorithm, animals are designated as core or noncore, and the computing resources to create the inverse of $\mathbf{G}$ are reduced by inverting only a portion of that matrix for core animals.

Computing the number of core animals

Run preGSf90 (or any BLUPF90 software that computes breeding values or variance components) with clean files (after quality control) to compute the number of eigenvalues explaining 98% of the variance of $\mathbf{G}$ Pocrnic et al. (2016). This is done through singular value decomposition. You will need to add the following options:

  OPTION no_quality_control

This option turns off all quality control.

  OPTION snp_svd stop

This option computes the singular value decomposition, squares the singular values to obtain eigenvalues, and stops the program after the calculations. The program will output something like this:

              All EVs    Positive EVs
 EIG 90%                    4380                   4380
 EIG 95%                    7494                   7494
 EIG 98%                   13030                  13030
 EIG 99%                   17842                  17842

Here, the number of eigenvalues explaining 98% is 13030, so this will be the number of core animals in APY. To avoid running this step frequently, the number explaining 99% of the variance of G can be used (i.e., 17842).

Creating an XrefID file with an indicator for core and noncore

Assuming your SNP file name is snp.dat_clean, you can edit the snp.dat_clean_XrefID or you can create a new XrefID file. Make sure you do not change the order of genotyped animals. The XrefID should have the same order as the SNP file. If a new XrefID file is created, e.g., APY_XrefID, use the following:

 OPTION SNP_file filename xrefidname

Where filename is the name of the SNP file and xrefidname is the name of the new XrefID that contains an extra column of core and noncore indicator.

$\mathbf{APY}$ $\mathbf{G}^{-1}$ Options

 OPTION apy Type Position Condition

Type: integer
1: Replaces the regular $\mathbf{G}^{-1}$ with $\mathbf{APY}$ $\mathbf{G}^{-1}$ .
2: Creates 2 dense blocks and 1 vector of APY $\mathbf{G}^{-1}$. Some options will be ignored.

Position: integer
Column number in the XrefID file to specify the core and noncore indicator for each genotyped animal.

Condition: character
Description of the condition for core (proven) or noncore animals (young).
General form:

(proven|young)(.ge.|.gt.|.eq.|.ne.|.lt.|.le.)(integer number)

No spaces between words are allowed.


  • young.eq.0 noncore if the column has 0.
  • proven.le.2008 core if the column has 2008 or less.

$\mathbf{A}_{22}^{-1}$ Options

The “noA22directinv” option can avoid creating the whole $\mathbf{A}_{22}$ and its inverse. Instead, this option creates 3 sub matrices of $\mathbf{A}^{-1}$ via the Henderson's (and Quaas) method.

  OPTION noA22directinv 1

This option still needs the diagonal elements of $\mathbf{A}_{22}^{-1}$. You can control the computing method for the diagonals with an option:

 OPTION whichA22iDiag Type Argument(s)


 OPTION whichA22iDiag 1
 OPTION whichA22iDiag 2 nelements
 OPTION whichA22iDiag 3
 OPTION whichA22iDiag 4 nrounds
 OPTION whichA22iDiag 5 nrounds nelements
  • Type=1 → Exact calculation + default (very slow)
  • Type=2 → Exact calculation + Simultaneous calculation of multiple elements + Parallelized with OpenMP
  • Type=3 → Monte Carlo approximation with ranlib (extremely slow)
  • Type=4 → Monte Carlo approximation with a faster random number generator + Parallelized with OpenMP
  • Type=5 → Monte Carlo approximation with a faster random number generator + Simultaneous calculation of multiple elements + Parallelized with OpenMP

The recommended option is

  OPTION whichA22iDiag 4 1000

Because this option produced almost the same solutions as ones from Type=1, in a faster way.

  • Argument(s)=nelements → number of elements for simultaneous calculations (Types 2 and 5 only)
  • Argument(s)=nrounds → number of rounds for the Monte Carlo approximation

Summary of options needed for APY

Using the most efficient implementation of APY and assuming the core animals are coded as 10 in the XrefID with core and noncore indicator

OPTION apy 2 3 proven.eq.10
OPTION noA22directinv 1
OPTION whichA22iDiag 4 1000

Saving and reading the matrices

For the type-1$\mathbf{APY}$ $\mathbf{G}^{-1}$, you can use “saveGInverse” and “readGInverse” for input/output the matrix. For the type-2 $\mathbf{APY}$ $\mathbf{G}^{-1}$, special options are required for the input/output:

  OPTION saveApyGInverse
  OPTION saveApyGInverse filename
  OPTION readApyGInverse
  OPTION readApyGInverse filename

The default file name is ApyGi. If you want to save the file with a different name, replace the filename statement with the desired name.


  • The VanRaden's method 1 is the only method available to create $\mathbf{G}$ in APY.
  • APY must be combined with OPTION no_quality_control.
  • BLUP90IOD2 is the only software that works with APY Type 2
  • BLUPF90 only takes APY Type 1
undoc/apy_in_blup90iod2.txt · Last modified: 2024/03/25 18:22 by

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki