Skip to contents

Returns total genetic variance between populations in a MultiPop-class object.

In contrast to varG, which computes variance within each terminal population from individual genetic values, varGPop computes variance among population means.

Usage

varGPop(x, level = 1L)

Arguments

x

A MultiPop-class object.

level

Integer scalar \(\ge 1\) indicating the aggregation level for population means (see Details).

Value

A variance-covariance matrix of genetic values across traits, representing variance between populations at the requested aggregation level.

Details

This function first computes mean genetic values using meanGPop at the requested level. The resulting matrix (rows = populations, columns = traits) is then passed to popVar to calculate a variance-covariance matrix of genetic values across traits, representing variance between populations at the requested level.

If the requested level yields only one aggregated population, there is no between-population variation to estimate. In this case, the function returns a variance-covariance matrix of zeros and issues a warning.

See also

Examples

founderPop = quickHaplo(nInd = 16, nChr = 1, segSites = 10)
SP = SimParam$new(founderPop)
SP$addTraitA(10)
pop = newPop(founderPop, simParam = SP)

mp = splitPop(
  pop,
  by = list(
    sample(rep(LETTERS[1:2], length.out = pop@nInd)),
    function(x) sample(letters[5:6], length(x), replace = TRUE)
  )
)

# Between-population variance at different aggregation levels
varGPop(mp, level = 2)
#>             Trait1
#> Trait1 0.007930609
varGPop(mp, level = 1)
#>              Trait1
#> Trait1 0.0005108003

# Compare with within-population variance
varG(mp)
#> $A
#> $A$e
#>          Trait1
#> Trait1 1.239755
#> 
#> $A$f
#>          Trait1
#> Trait1 1.022679
#> 
#> 
#> $B
#> $B$e
#>          Trait1
#> Trait1 1.123425
#> 
#> $B$f
#>           Trait1
#> Trait1 0.7761631
#> 
#>