popkin_A_min_subpops: Estimate the minimum expected value of a matrix 'A' using...

Description Usage Arguments Details Value See Also Examples

View source: R/popkin_A_min_subpops.R

Description

This function averages the values of a square matrix A between every subpopulation pair and returns the minimum of these averages. The return value can be used to adjust an A matrix to yield the kinship matrix.

Usage

1
popkin_A_min_subpops(A, subpops = NULL)

Arguments

A

A symmetric n-by-n matrix with values between every individual pair, including self comparisons.

subpops

A length-n vector of subpopulation assignments for each individual. If missing, every individual is effectively treated as a different population.

Details

If no subpopulation partition is provided, the function returns the minimum value of A. This default choice may be appropriate in some settings, but is susceptible to bias when there are few loci and many pairs of individuals with zero kinship (taking the most extreme estimate is clearly worse than averaging these values). This default is provided for convenience, to explore the data when a correct choice of subpopulations is not clear, but is not recommended as a final approach.

Value

The minimum of the average between-subpopulation A values, which estimates the minimum expected value of A

See Also

The \link[popkin_A] to generate the A matrix normally inputted into this function (popkin_A_min_subpops), and \link[popkin] is the wrapper function around both of these.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Construct toy data
X <- matrix(c(0,1,2,1,0,1,1,0,2), nrow=3, byrow=TRUE) # genotype matrix
subpops <- c(1,1,2) # subpopulation assignments for individuals

# NOTE: for BED-formatted input, use BEDMatrix!
# "file" is path to BED file (excluding .bed extension)
## library(BEDMatrix)
## X <- BEDMatrix(file) # load genotype matrix object

# calculate A from genotypes
A <- popkin_A(X)$A

# the recommended form using appropriate subpopulation labels
A_min_est <- popkin_A_min_subpops( A, subpops )

# this recovers the popkin estimate
kinship <- 1 - A / A_min_est
stopifnot( kinship == popkin( X, subpops ) )

# a simple default for exploratory analysis, equals min( A )
A_min_est <- popkin_A_min_subpops( A )
stopifnot( A_min_est == min( A ) )

popkin documentation built on Feb. 11, 2021, 5:07 p.m.