admix_prop_indep_subpops {bnpsd}R Documentation

Construct admixture proportion matrix for independent subpopulations


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.


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



Length-n vector of subpopulation labels


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).


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


# 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)

[Package bnpsd version 1.3.13 Index]