Equations

Per Trait Equations

convert_genotype_to_phenotype:
gen # genotype
stdev # standard deviation
h2 # heritability
inbc # inbreeding coefficient
inbdp # inbreeding depression percentage
ph_v = (stdev**2) / h2
res_v = ph_v * (1 - h2)
res_stdev = sqrt(res_v)
ph = gen * 2 + nrandom(res_std)
phenotype = ph + inbc * 100 * inbdp
convert_genotype_to_pta:
gen # genotype
nd # number of daughters
ng # number of genomic tests
stdev # standard deviation
h2 # heritability
n = nd + ng * 2 * (1 / h2)
k = (4 - h2) / h2
urel = h2 + (n / (n + k))
rel = limit(urel, 0.99)
w1 = sqrt(rel)
w2 = sqrt(1 - rel)
noise = nrandom(stdev)
PTA = ((w1 * gen + w2 * noise) * (rel^0.25)) / 2
get_genotype_from_breeding:
s_gen # sire genotype
d_gen # dam genotype
mds # mendelian sample
sc = sqrt(2) / 2
pa = (s_gen + d_gen) / 2
scs = sc * mds
genotype = pa + scs
get_net_merit_dollars_addend:
gen # genotype
nmd # net merit dollars
net_merit_dollars = gen * nmd
limit:
x # any real number
max # maximum
# Yields the bounded value of x less than or equal to max.
nrandom:
stdev # standard deviation
# Yields a random value on a normal distribution.
sqrt:
x # any real number
# Yields the square root of x.

Cross Trait Equations

derive_phenotype_from_genotype:
gen # genotype
inbc # inbreeding coefficient
# Gets phenotypes from each trait's convert_genotype_to_phenotype function.
# Correlates using cholesky decomposition of phenotype covariance matrix.
derive_ptas_from_genotype:
gen # genotype
nd # number of daughters
ng # number of genomic tests
# Gets PTA from each trait's convert_genotype_to_pta function.
get_genotype_from_breeding:
sg # sire genotype
dg # dam genotype
# Gets correlated mendealian samples using get_random_genotype function.
# Finalizes genotype value using get_genotype_from_breeding
# function of each trait.
get_random_genotype
# Yields random set of values scaled to each traits standard deviation.
# Correlates values using plotting over cholesky decomposition of
# genotype covariance matrix.

Per Recessive Equations

get_recessives_from_breeding:
s # sire gene
d # dam gene
# [true, true], [true, false], or [false, false]
alleles = [get_passed_from_parent(s), get_passed_from_parent(d)]
get_passed_from_parent:
p # parent gene
# Yields either first or second allele of p with equal weight.
get_random:
prev # prevalence percent
# [true, true], [true, false], or [false, false]
alleles = [random() * 100 < prev, random() * 100 < prev]
random
#Yields a random value in range [0, 1]