admix_prop_indep_subpops: Construct admixture proportion matrix for independent...

Description Usage Arguments Value Examples

View source: R/admix_prop_indep_subpops.R

Description

This function constructs an admixture proportion matrix where every individuals is actually unadmixed (draws its full ancestry from a single intermediate subpopulation). The inputs are the vector of subpopulation labels labs for every individual (length n), and the length-k vector of unique subpopulations subpops in the desired order. If subpops is missing, the sorted unique subpopulations observed in labs is used. This function returns the admixture proportion matrix, for each individual 1 for the column corresponding to its subpopulation, 0 otherwise.

Usage

1
admix_prop_indep_subpops(labs, subpops = sort(unique(labs)))

Arguments

labs

Length-n vector of subpopulation labels

subpops

Optional length-k vector of unique subpopulations in desired order. Stops if subpops does not contain all unique labels in labs (no error if subpops contains additional labels).

Value

The n-by-k admixture proportion matrix. The unique subpopulation labels are given in the column names.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# vector of subpopulation memberships
labs <- c(1, 1, 1, 2, 2, 3, 1)
# admixture matrix with subpopulations (along columns) sorted
admix_proportions <- admix_prop_indep_subpops(labs)

# declare subpopulations in custom order
subpops <- c(3, 1, 2)
# columns will be reordered to match subpops as provided
admix_proportions <- admix_prop_indep_subpops(labs, subpops)

# declare subpopulations with unobserved labels
subpops <- 1:5
# note columns 4 and 5 will be false for all individuals
admix_proportions <- admix_prop_indep_subpops(labs, subpops)

bnpsd documentation built on Aug. 25, 2021, 5:07 p.m.