The pyp_metrics Module

pyp_metrics contains a set of procedures for calculating metrics on PyPedal pedigree objects. These metrics include coefficients of inbreeding and relationship as well as effective founder number, effective population size, and effective ancestor number.

Module Contents

a_coefficients(myped, filetag='_coefficients_', a='', method='nrm') [#]

a_coefficients() writes population average coefficients of inbreeding and relationship to a file, as well as individual animal IDs and coefficients of inbreeding.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
method
If no relationship matrix is passed, determines which procedure should be called to build one (nrm|frm).

a_effective_ancestors(myped, filetag='_f_a_', a='', gen='', n=25) ⇒ float [#]

a_effective_ancestors() calls either a_effective_ancestors_definite() or a_effective_ancestors_indefinite() based on pedigree size using an arbitrarily-assigned threshold of 1,000 animals. For small pedigrees (N <= 1,000) the exact computation is performed. For larger pedigrees, an approximate computation is carried out based on inexact lower and upper bounds of f_a (see Boichard et al. (1996) pp.9-10). If no number of ancestors is specified in the call to a_effective_ancestors() and the indef- inite routine is used, a default of 25 is used. Boichard's algorithms require information about the GENERATION of animals. If you do not provide an input pedigree with generations things may not work. By default the most recent generation -- the generation with the largest generation ID -- will be used as the reference population.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
gen
Generation of interest.
gen
Number of ancestors to use with the indefinite routine.
Returns:
The effective founder number.

a_effective_ancestors_definite(myped, filetag='_f_a_definite_', a='', gen='') ⇒ float [#]

a_effective_ancestors_definite() uses the algorithm in Appendix B of Boichard et al. (1996) to compute the effective ancestor number for a myped pedigree. NOTE: One problem here is that if you pass a pedigree WITHOUT generations and error is not thrown. You simply end up wth a list of generations that contains the default value for Animal() objects, 0. Boichard's algorithm requires information about the GENERATION of animals. If you do not provide an input pedigree with generations things may not work. By default the most recent generation -- the generation with the largest generation ID -- will be used as the reference population.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
gen
Generation of interest.
Returns:
The effective founder number.

a_effective_ancestors_indefinite(myped, filetag='_f_a_definite_', a='', gen='', n=25) ⇒ float [#]

a_effective_ancestors_indefinite() uses the approach outlined on pages 9 and 10 of Boichard et al. (1996) to compute approximate upper and lower bounds for f_a. This is much more tractable for large pedigrees than the exact computation provided in a_effective_ancestors_definite(). NOTE: One problem here is that if you pass a pedigree WITHOUT generations and error is not thrown. You simply end up wth a list of generations that contains the default value for Animal() objects, 0. NOTE: If you pass a value of n that is greater than the actual number of ancestors in the pedigree then strange things happen. As a stop-gap, a_effective_ancestors_indefinite() will detect that case and replace n with the number of founders - 1. Boichard's algorithm requires information about the GENERATION of animals. If you do not provide an input pedigree with generations things may not work. By default the most recent generation -- the generation with the largest generation ID -- will be used as the reference population.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
gen
Generation of interest.
Returns:
The effective founder number.

a_effective_founders_boichard(myped, filetag='_f_e_boichard_', a='', gen='') ⇒ float [#]

a_effective_founders_boichard() uses the algorithm in Appendix A of Boichard et al. (1996) to compute the effective founder number for myped. Note that results from this function will not necessarily match those from a_effective_founders_lacy(). Boichard's algorithm requires information about the GENERATION of animals. If you do not provide an input pedigree with generations things may not work. By default the most recent generation -- the generation with the largest generation ID -- will be used as the reference population.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
gen
Generation of interest.
Returns:
The effective founder number.

a_effective_founders_lacy(myped, filetag='_f_e_lacy_', a='') ⇒ float [#]

a_effective_founders_lacy() calculates the number of effective founders in a pedigree using the exact method of Lacy.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
Returns:
The effective founder number.

common_ancestors(anim_a, anim_b, myped, filetag='_steps_') ⇒ list [#]

common_ancestors() returns a list of the ancestors that two animals share in common.

anim_a
The renumbered ID of the first animal, a.
anim_b
The renumbered ID of the second animal, b.
myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
Returns:
A list of animals related to anim_a AND anim_b

effective_founder_genomes(myped, filetag='_gene_drop_', rounds=10, verbose=0, quiet=1) ⇒ float [#]

effective_founder_genomes() simulates the random segregation of founder alleles through a pedigree. At present only two allels are simulated for each founder. Summary statistics are computed on the most recent generation.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
rounds
The number of times to simulate segregation through the entire pedigree.
verbose
A flag to indicate whether or not diagnostic/debugging information is printed.
Returns:
The effective number of founder genomes over based on 'rounds' gene-drop simulations.

fast_a_coefficients(myped, filetag='_coefficients_', a='', method='nrm', debug=0) [#]

a_fast_coefficients() writes population average coefficients of inbreeding and relationship to a file, as well as individual animal IDs and coefficients of inbreeding.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
method
If no relationship matrix is passed, determines which procedure should be called to build one (nrm|frm).

mating_coi(anim_a, anim_b, myped, filetag='_mating_coi_') ⇒ float [#]

mating_coi() returns the coefficient of inbreeding of offspring of a mating between two animals, anim_a and anim_b.

anim_a
The renumbered ID of an animal, a.
anim_b
The renumbered ID of an animal, b.
myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
Returns:
The coefficient of relationship of anim_a and anim_b

min_max_f(myped, filetag='_min_max_f_', a='', n=10) ⇒ list [#]

min_max_f() takes a pedigree and returns a list of the individuals with the n largest and n smallest coefficients of inbreeding.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
a
A numerator relationship matrix (optional).
n
An integer (optional, default is 10).
Returns:
A list of the individuals with the n largest and the n smallest CoI in the pedigree.

pedigree_completeness(myped, filetag='_pedigree_completeness_') [#]

pedigree_completeness() computes an arbitrary measure of pedigree completeness for each animal in the pedigree. Writes a file of individual pedigree completeness coefficients to a file. Also writes a file of summary data for th population.

myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.

related_animals(anim_a, myped, filetag='_related_') ⇒ list [#]

related_animals() returns a list of the ancestors that two animals share in common.

anim_a
The renumbered ID of an animal, a.
myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
Returns:
A list of animals related to anim_a

relationship(anim_a, anim_b, myped, filetag='_relationship_') ⇒ float [#]

relationship() returns the coefficient of relationship for two animals, anim_a and anim_b.

anim_a
The renumbered ID of an animal, a.
anim_b
The renumbered ID of an animal, b.
myped
A PyPedal pedigree object.
filetag
A descriptor prepended to output file names.
Returns:
The coefficient of relationship of anim_a and anim_b

theoretical_ne_from_metadata(metaped, filetag='_ne_from_metadata_') [#]

theoretical_ne_from_metadata() computes the theoretical effective population size based on the number of sires and dams contained in a pedigree metadata object. Writes results to an output file.

metaped
A PyPedal pedigree metadata object.
filetag
A descriptor prepended to output file names.