View source: R/avg_kinship_subpops.R
avg_kinship_subpops | R Documentation |
This function calculates a kinship matrix between subpopulations, whose values are the average kinship values between all individual pairs where one individual is in the first subpopulation and the other individual is in the second subpopulation.
To estimate coancestry instead of kinship, which is recommended to get more interpretable diagonal values, the input kinship matrix should be transformed using inbr_diag()
.
avg_kinship_subpops(kinship, subpops, subpop_order = unique(subpops))
kinship |
A symmetric |
subpops |
The length- |
subpop_order |
The optional order of subpopulations in the output matrix.
|
The symmetric K
-by-K
kinship matrix between subpopulations, where K
is the number of unique subpopulations in subpops
, ordered as in subpop_order
.
# a toy kinship matrix with 5 individuals belonging to 2 subpopulations kinship <- matrix( c( 0.7, 0.4, 0.4, 0.1, 0.0, 0.4, 0.7, 0.4, 0.2, 0.1, 0.4, 0.4, 0.7, 0.2, 0.0, 0.1, 0.2, 0.2, 0.6, 0.1, 0.0, 0.1, 0.0, 0.1, 0.6 ), nrow = 5, ncol = 5 ) subpops <- c(1, 1, 1, 2, 2) # calculate mean kinship between (and within) subpopulations # a 2x2 matrix avg_kinship_subpops( kinship, subpops ) # calculate coancestry estimate instead (difference is diagonal) avg_kinship_subpops( inbr_diag( kinship ), subpops )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.