- Notifications
You must be signed in to change notification settings - Fork0
R package to model and simulate admixed populations
License
StoreyLab/bnpsd
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Thebnpsd ("Balding-Nichols Pritchard-Stephens-Donnelly") R package is for simulating admixed populations.More specifically,bnpsd facilitates construction of admixed population structures and simulation of allele frequencies and genotypes from the BN-PSD admixture model.This model combines the Balding-Nichols (BN) allele frequency model for the intermediate subpopulations with the Pritchard-Stephens-Donnelly (PSD) model of individual-specific admixture proportions.This model enables the simulation of complex population structures, ideal for illustrating challenges in kinship coefficient and FST estimation.Note that simulated loci are drawn independently (in linkage equilibrium).
The stable version of the package is now on CRAN and can be installed using
install.packages("bnpsd")The current development version can be installed from the GitHub repository usingdevtools:
install.packages("devtools")# if neededlibrary(devtools)install_github('StoreyLab/bnpsd',build_vignettes=TRUE)
You can see the package vignette, which has more detailed documentation, by typing this into your R session:
vignette('bnpsd')This is a quick overview of the mainbnpsd functions.
Define the population structure (in this case for 1D admixture scenario).
library(bnpsd)# dimensions of data/model# number of locim_loci<-10# number of individualsn_ind<-5# number of intermediate subpopsk_subpops<-2# define population structure# FST values for k=2 subpopulationsinbr_subpops<- c(0.1,0.3)# admixture proportions from 1D geographyadmix_proportions<- admix_prop_1d_linear(n_ind,k_subpops,sigma=1)# also available:# - admix_prop_1d_circular# - admix_prop_indep_subpops# get pop structure parameters of the admixed individuals# the coancestry matrixcoancestry<- coanc_admix(admix_proportions,inbr_subpops)# FST of admixed individualsFst<- fst(admix_proportions,inbr_subpops)
Draw random allele frequencies and genotypes from this population structure.
# draw all random allele freqs and genotypesout<- draw_all_admix(admix_proportions,inbr_subpops,m_loci)# genotypesX<-out$X# ancestral allele frequencies (AFs)p_anc<-out$p_anc# OR... draw each vector or matrix separately# provided for additional flexibility# ancestral AFsp_anc<- draw_p_anc(m_loci)# independent subpops (intermediate) AFsp_subpops<- draw_p_subpops(p_anc,inbr_subpops)# individual-specific AFsp_ind<- make_p_ind_admix(p_subpops,admix_proportions)# genotypesX<- draw_genotypes_admix(p_ind)
This tree allows forcorrelated subpopulations (previous examples hadindependent subpopulations).
# best to start by specifying tree in Newick string formattree_str<-'(S1:0.1,(S2:0.1,S3:0.1)N1:0.1)T;'# and turn it into `phylo` object using the `ape` packagelibrary(ape)tree_subpops<- read.tree(text=tree_str )# true coancestry matrix corresponding to this treecoanc_subpops<- coanc_tree(tree_subpops )# admixture proportions from 1D geography# (constructed again but for k=3 tree)k_subpops<- nrow(coanc_subpops )admix_proportions<- admix_prop_1d_linear(n_ind,k_subpops,sigma=0.5 )# get pop structure parameters of the admixed individuals# the coancestry matrixcoancestry<- coanc_admix(admix_proportions,coanc_subpops )# FST of admixed individualsFst<- fst_admix(admix_proportions,coanc_subpops )# draw all random allele freqs and genotypes, tree versionout<- draw_all_admix(admix_proportions,tree_subpops=tree_subpops,m_loci=m_loci )# genotypesX<-out$X# ancestral allele frequencies (AFs)p_anc<-out$p_anc# OR... draw tree subpops (intermediate) AFs separatelyp_subpops_tree<- draw_p_subpops_tree(p_anc,tree_subpops )
Alejandro Ochoa, John D Storey. 2021. "Estimating FST and kinship for arbitrary population structures." PLoS Genet 17(1): e1009241. PubMed ID 33465078.doi:10.1371/journal.pgen.1009241. bioRxivdoi:10.1101/083923 2016-10-27.
Alejandro Ochoa, John D Storey. 2016. "FST And Kinship for Arbitrary Population Structures I: Generalized Definitions." bioRxivdoi:10.1101/083915.
About
R package to model and simulate admixed populations
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
