PyPedal::pyp_nrm Namespace Reference


Functions

def a_matrix
def fast_a_matrix
def fast_a_matrix_r
def inbreeding
def inbreeding_vanraden
def recurse_pedigree
def recurse_pedigree_n
def recurse_pedigree_onesided
def recurse_pedigree_idonly
def recurse_pedigree_idonly_side
def inbreeding_tabular
def a_decompose
def form_d_nof
def a_inverse_dnf
def a_inverse_df
def partial_inbreeding
def fast_partial_a_matrix


Function Documentation

def PyPedal::pyp_nrm::a_decompose (   pedobj  ) 

Form the decomposed form of A, TDT', directly from a pedigree (after Henderson, 1976; Thompson, 1977; Mrode, 1996). Return D, a diagonal matrix, and T, a lower triagular matrix such that A = TDT'.

Parameters:
pedobj A PyPedal pedigree object.
Returns:
A diagonal matrix, D, and a lower triangular matrix, T. matrices
Form the decomposed form of A, TDT', directly from a pedigree (after
Henderson, 1976; Thompson, 1977; Mrode, 1996).  Return D, a diagonal
matrix, and T, a lower triagular matrix such that A = TDT'.

Definition at line 1096 of file pyp_nrm.py.

def PyPedal::pyp_nrm::a_inverse_df (   pedobj  ) 

Directly form the inverse of A from the pedigree file - accounts for inbreeding - using the method of Quaas (1976).

Parameters:
pedobj A PyPedal pedigree object.
Returns:
The inverse of the NRM, A, accounting for inbreeding. matrix
Directly form the inverse of A from the pedigree file - accounts for
inbreeding - using the method of Quaas (1976).

Definition at line 1359 of file pyp_nrm.py.

def PyPedal::pyp_nrm::a_inverse_dnf (   pedobj,
  filetag = '_a_inverse_dnf_' 
)

Form the inverse of A directly using the method of Henderson (1976) which does not account for inbreeding.

Parameters:
pedobj A PyPedal pedigree object.
Returns:
The inverse of the NRM, A, not accounting for inbreeding. matrix
Form the inverse of A directly using the method of Henderson (1976) which
does not account for inbreeding.

Definition at line 1270 of file pyp_nrm.py.

def PyPedal::pyp_nrm::a_matrix (   pedobj,
  save = 0 
)

a_matrix() is used to form a numerator relationship matrix from a pedigree. DEPRECATED. use fast_a_matrix() instead.

Parameters:
pedobj A PyPedal pedigree object.
save Flag to indicate whether or not the relationship matrix is written to a file.
Returns:
The NRM as a NumPy matrix. array
Form a numerator relationship matrix from a pedigree.  DEPRECATED.

Definition at line 43 of file pyp_nrm.py.

def PyPedal::pyp_nrm::fast_a_matrix (   pedigree,
  pedopts,
  save = 0,
  method = 'dense',
  debug = 0 
)

Form a numerator relationship matrix from a pedigree. fast_a_matrix() is a hacked version of a_matrix() modified to try and improve performance. Lists of animal, sire, and dam IDs are formed and accessed rather than myped as it is much faster to access a member of a simple list rather than an attribute of an object in a list. Further note that only the diagonal and upper off-diagonal of A are populated. This is done to save n(n+1) / 2 matrix writes. For a 1000-element array, this saves 500,500 writes.

Parameters:
pedigree A PyPedal pedigree.
pedopts PyPedal options.
save Flag to indicate whether or not the relationship matrix is written to a file.
method Use dense or sparse matrix storage.
debug Print NRM for debugging
Returns:
The NRM as Numarray matrix. matrix
Form a numerator relationship matrix from a pedigree.  fast_a_matrix() is a hacked
version of a_matrix() modified to try and improve performance.  Lists of animal,
sire, and dam IDs are formed and accessed rather than myped as it is much faster to
access a member of a simple list rather than an attribute of an object in a
list.  Further note that only the diagonal and upper off-diagonal of A are
populated.  This is done to save n(n+1) / 2 matrix writes.  For a 1000-element
array, this saves 500,500 writes.

Definition at line 127 of file pyp_nrm.py.

def PyPedal::pyp_nrm::fast_a_matrix_r (   pedigree,
  pedopts,
  save = 0,
  method = 'dense' 
)

Form a relationship matrix from a pedigree. fast_a_matrix_r() differs from fast_a_matrix() in that the coefficients of relationship are corrected for the inbreeding of the parents.

Parameters:
pedobj A PyPedal pedigree object.
save Flag to indicate whether or not the relationship matrix is written to a file.
Returns:
A relationship as Numarray matrix. matrix
Form a relationship matrix from a pedigree.  fast_a_matrix_r() differs from
fast_a_matrix() in that the coefficients of relationship are corrected for the
inbreeding of the parents.

Definition at line 263 of file pyp_nrm.py.

def PyPedal::pyp_nrm::fast_partial_a_matrix (   pedigree,
  founder,
  founderlist,
  pedopts,
  method = 'dense',
  debug = 0 
)

fast_partial_a_matrix() calculates a partial kinship matrix for a given founder in a pedigree, and returns a dictionary of partial inbreeding coefficients between that founder and and descendants (non-founders) in the pedigree.

Parameters:
pedigree A PyPedal pedigree.
founder Founder of interest.
founderlist List of founders in the pedigree.
pedopts PyPedal options.
method Use dense or sparse matrix storage.
debug Print NRM for debugging
Returns:
The NRM as Numarray matrix. matrix
fast_partial_a_matrix() calculates a partial kinship matrix for a given
founder in a pedigree, and returns a dictionary of partial inbreeding
coefficients between that founder and and descendants (non-founders) in
the pedigree.

Definition at line 1636 of file pyp_nrm.py.

def PyPedal::pyp_nrm::form_d_nof (   pedobj  ) 

Form the diagonal matrix, D, used in decomposing A and forming the direct inverse of A. This function does not write output to a file - if you need D in a file, use the a_decompose() function. form_d() is a convenience function used by other functions. Note that inbreeding is not considered in the formation of D.

Parameters:
pedobj A PyPedal pedigree object.
Returns:
A diagonal matrix, D. matrix
Form the diagonal matrix, D, used in decomposing A and forming the direct
inverse of A.  This function does not write output to a file - if you need D in
a file, use the a_decompose()  function.  form_d() is a convenience function
used by other functions.  Note that inbreeding is not considered in the
formation of D.

Definition at line 1210 of file pyp_nrm.py.

def PyPedal::pyp_nrm::inbreeding (   pedobj,
  method = 'tabular',
  gens = 0,
  rels = 0,
  output = 1 
)

inbreeding() is a proxy function used to dispatch pedigrees to the appropriate function for computing CoI. By default, small pedigrees < 10,000 animals) are processed with the tabular method directly. For larger pedigrees, or if requested, the recursive method of VanRaden (1992) is used.

Parameters:
pedobj A PyPedal pedigree object.
method Keyword indicating which method of computing CoI should be used (tabular|vanraden).
gens The number of generations from the pedigree to be used for calculating CoI. By default, gens=0, which uses the complete pedigree.
rels Flag indicating whether or not summary statistics should be computed for coefficients of relationship.
output Flag indicating whether or not output files should be written.
Returns:
A dictionary of CoI keyed to renumbered animal IDs. dictionary
inbreeding() is a proxy function used to dispatch pedigrees to the appropriate
function for computing CoI.  By default, small pedigrees < 10,000 animals) are
processed with the tabular method directly.  For larger pedigrees, or if requested,
the recursive method of VanRaden (1992) is used.

Definition at line 409 of file pyp_nrm.py.

def PyPedal::pyp_nrm::inbreeding_tabular (   pedobj,
  gens = 0,
  rels = 0 
)

inbreeding_tabular() computes CoI using the tabular method by calling fast_a_matrix() to form the NRM directly. In order for this routine to return successfully requires that you are able to allocate a matrix of floats of dimension len(myped)**2.

Parameters:
pedobj A PyPedal pedigree object.
gens The number of generations from the pedigree to be used for calculating CoI. By default, gens=0, which uses the complete pedigree.
rels Flag indicating whether or not summary statistics should be computed for coefficients of relationship.
Returns:
A dictionary of CoI keyed to renumbered animal IDs dictionary
inbreeding_tabular() computes CoI using the tabular method by calling
fast_a_matrix() to form the NRM directly.  In order for this routine
to return successfully requires that you are able to allocate a matrix
of floats of dimension len(myped)**2.

Definition at line 1013 of file pyp_nrm.py.

def PyPedal::pyp_nrm::inbreeding_vanraden (   pedobj,
  cleanmaps = 1,
  gens = 0,
  rels = 0 
)

inbreeding_vanraden() uses VanRaden's (1992) method for computing coefficients of inbreeding in a large pedigree. The method works as follows: 1. Take a large pedigree and order it from youngest animal to oldest (n, n-1, ..., 1); 2. Recurse through the pedigree to find all of the ancestors of that animal n; 3. Reorder and renumber that "subpedigree"; 4. Compute coefficients of inbreeding for that "subpedigree" using the tabular method (Emik and Terrill, 1949); 5. Put the coefficients of inbreeding in a dictionary; 6. Repeat 2 - 5 for animals n-1 through 1; the process is slowest for the early pedigrees and fastest for the later pedigrees.

Parameters:
pedobj A PyPedal pedigree object.
cleanmaps Flag to denote whether or not subpedigree ID maps should be deleted after they are used (0|1).
gens The number of generations from the pedigree to be used for calculating CoI. By default, gens=0, which uses the complete pedigree.
rels Flag indicating whether or not summary statistics should be computed for coefficients of relationship.
Returns:
A dictionary of CoI keyed to renumbered animal IDs dictionary
inbreeding_vanraden() uses VanRaden's (1992) method for computing coefficients of
inbreeding in a large pedigree.  The method works as follows:
1.  Take a large pedigree and order it from youngest animal to oldest (n, n-1, ...,
    1);
2.  Recurse through the pedigree to find all of the ancestors of that animal n;
3.  Reorder and renumber that "subpedigree";
4.  Compute coefficients of inbreeding for that "subpedigree" using the tabular
    method (Emik and Terrill, 1949);
5.  Put the coefficients of inbreeding in a dictionary;
6.  Repeat 2 - 5 for animals n-1 through 1; the process is slowest for the early
    pedigrees and fastest for the later pedigrees.

Definition at line 619 of file pyp_nrm.py.

def PyPedal::pyp_nrm::partial_inbreeding (   pedobj,
  animals = [],
  gens = 0,
  rels = 1,
  cleanmaps = 1 
)

partial_inbreeding() computes coefficients of partial inbreeding, which is the probability that an individual, i, is IDB at a locus and that the alleles were derived from ancestor j.

Parameters:
pedobj A PyPedal pedigree object.
animals An empty list of renumbered animal IDs to process (do all when list empty).
gens The number of generations from the pedigree to be used for calculating CoI. By default, gens=0, which uses the complete pedigree.
rels Flag indicating whether or not summary statistics should be computed for coefficients of relationship.
Returns:
A dictionary of partial CoI keyed to renumbered animal IDs. dictionary
partial_inbreeding() computes coefficients of partial inbreeding,
which is the probability that an individual, i, is IDB at a locus
and that the alleles were derived from ancestor j.
Input: A PyPedal pedigree object.
Output: A dictionary of partial CoI keyed to renumbered animal IDs.

Definition at line 1480 of file pyp_nrm.py.

def PyPedal::pyp_nrm::recurse_pedigree (   pedobj,
  anid,
  _ped 
)

recurse_pedigree() performs the recursion needed to build the subpedigrees used by inbreeding_vanraden(). For the animal with animalID anid recurse_pedigree() will recurse through the pedigree myped and add references to the relatives of anid to the temporary pedigree, _ped.

Parameters:
pedobj A PyPedal pedigree.
anid The ID of the animal whose relatives are being located.
_ped A temporary PyPedal pedigree that stores references to relatives of anid.
Returns:
A list of references to the relatives of anid contained in myped. list
recurse_pedigree() performs the recursion needed to build the subpedigrees used by
inbreeding_vanraden().  For the animal with animalID anid recurse_pedigree() will
recurse through the pedigree myped and add references to the relatives of anid to
the temporary pedigree, _ped.

Definition at line 852 of file pyp_nrm.py.

def PyPedal::pyp_nrm::recurse_pedigree_idonly (   pedobj,
  anid,
  _ped 
)

recurse_pedigree_idonly() performs the recursion needed to build subpedigrees.

Parameters:
pedobj A PyPedal pedigree.
anid The ID of the animal whose relatives are being located.
_ped A PyPedal list that stores the animalIDs of relatives of anid.
Returns:
A list of animalIDs of the relatives of anid contained in myped. list
recurse_pedigree_idonly() performs the recursion needed to build subpedigrees.

Definition at line 945 of file pyp_nrm.py.

def PyPedal::pyp_nrm::recurse_pedigree_idonly_side (   pedobj,
  anid,
  _ped,
  side = 's' 
)

recurse_pedigree_idonly_side() performs the recursion needed to build a subpedigree containing only animal IDs for either all sires or all dams. That is, a pedigree would go sire-paternal grandsire-paternal great-grandsire, etc.

Parameters:
pedobj A PyPedal pedigree.
anid The ID of the animal whose relatives are being located.
_ped A PyPedal list that stores the animalIDs of relatives of anid.
side The side of the pedigree to follow ('s'|'d').
Returns:
A list of animalIDs of the relatives of anid contained in myped. list
recurse_pedigree_idonly_side() performs the recursion needed to build
a subpedigree containing only animal IDs for either all sires or all
dams.  That is, a pedigree would go sire-paternal grandsire-paternal
great-grandsire, etc.

Definition at line 977 of file pyp_nrm.py.

def PyPedal::pyp_nrm::recurse_pedigree_n (   pedobj,
  anid,
  _ped,
  depth = 3 
)

recurse_pedigree_n() recurses to build a pedigree of depth n. A depth less than 1 returns the animal whose relatives were to be identified.

Parameters:
pedobj A PyPedal pedigree.
anid The ID of the animal whose relatives are being located.
_ped A temporary PyPedal pedigree that stores references to relatives of anid.
depth The depth of the pedigree to return.
Returns:
A list of references to the relatives of anid contained in myped. list
recurse_pedigree_n() recurses to build a pedigree of depth n.  A depth
less than 1 returns the animal whose relatives were to be identified.

Definition at line 884 of file pyp_nrm.py.

def PyPedal::pyp_nrm::recurse_pedigree_onesided (   pedobj,
  anid,
  _ped,
  side 
)

recurse_pedigree_onesided() recurses to build a subpedigree from either the sire or dam side of a pedigree.

Parameters:
pedobj A PyPedal pedigree.
side The side to build: 's' for sire and 'd' for dam.
anid The ID of the animal whose relatives are being located.
_ped A temporary PyPedal pedigree that stores references to relatives of anid.
Returns:
A list of references to the relatives of anid contained in myped. list
recurse_pedigree_onesided() recurses to build a subpedigree from either the sire
or dam side of a pedigree.

Definition at line 915 of file pyp_nrm.py.


Generated on Fri Mar 28 14:34:59 2008 for PyPedal by  doxygen 1.5.3