Package fwsim. October 5, 2018

Similar documents
Package dhsic. R topics documented: July 27, 2017

Package RTransferEntropy

Package clogitboost. R topics documented: December 21, 2015

Package CPE. R topics documented: February 19, 2015

Package FDRSeg. September 20, 2017

Package NlinTS. September 10, 2018

Package jmcm. November 25, 2017

Package idmtpreg. February 27, 2018

Package basad. November 20, 2017

Package RI2by2. October 21, 2016

Package SpatPCA. R topics documented: February 20, Type Package

Package netcoh. May 2, 2016

Package lomb. February 20, 2015

Package EMVS. April 24, 2018

Package noncompliance

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression

Package penmsm. R topics documented: February 20, Type Package

Package gma. September 19, 2017

Package scpdsi. November 18, 2018

Package mpmcorrelogram

Package pearson7. June 22, 2016

Package GPfit. R topics documented: April 2, Title Gaussian Processes Modeling Version Date

Package IsingFit. September 7, 2016

Package EnergyOnlineCPM

Package rgabriel. February 20, 2015

Package bivariate. December 10, 2018

Package leiv. R topics documented: February 20, Version Type Package

Package bayeslm. R topics documented: June 18, Type Package

Package DiscreteLaplace

Package ShrinkCovMat

Package RZigZag. April 30, 2018

Package Grace. R topics documented: April 9, Type Package

Package beam. May 3, 2018

Package metafuse. October 17, 2016

Package invgamma. May 7, 2017

Package bigtime. November 9, 2017

Package SK. May 16, 2018

Package FDRreg. August 29, 2016

Package depth.plot. December 20, 2015

Package sklarsomega. May 24, 2018

Package BayesNI. February 19, 2015

Package rnmf. February 20, 2015

Package HIMA. November 8, 2017

Package esaddle. R topics documented: January 9, 2017

Package ICGOR. January 13, 2017

Package sbgcop. May 29, 2018

Package orclus. R topics documented: March 17, Version Date

Package gwqs. R topics documented: May 7, Type Package. Title Generalized Weighted Quantile Sum Regression. Version 1.1.0

Package covsep. May 6, 2018

Package magma. February 15, 2013

Package matrixnormal

Package QuantifQuantile

Package covtest. R topics documented:

Package ltsbase. R topics documented: February 20, 2015

Package alabama. March 6, 2015

Package dlagm. January 17, 2018

Package gtheory. October 30, 2016

Package lsei. October 23, 2017

Package neat. February 23, 2018

Package icmm. October 12, 2017

Package spcov. R topics documented: February 20, 2015

Package MAPA. R topics documented: January 5, Type Package Title Multiple Aggregation Prediction Algorithm Version 2.0.4

Cluster analysis of Y-chromosomal STR population data using discrete Laplace distributions

Package MonoPoly. December 20, 2017

Package mlma. July 14, 2016

Package hierdiversity

Package msbp. December 13, 2018

Package varband. November 7, 2016

Package CovSel. September 25, 2013

Package mmm. R topics documented: February 20, Type Package

Package SpatialNP. June 5, 2018

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

Package LBLGXE. R topics documented: July 20, Type Package

Package neuralnet. August 16, 2016

Package SimSCRPiecewise

Package bhrcr. November 12, 2018

Package severity. February 20, 2015

Package PoisNonNor. R topics documented: March 10, Type Package

Package FinePop. October 26, 2018

Package RootsExtremaInflections

Package EDR. September 14, 2016

Package zic. August 22, 2017

Package esreg. August 22, 2017

Package gk. R topics documented: February 4, Type Package Title g-and-k and g-and-h Distribution Functions Version 0.5.

Package monmlp. R topics documented: December 5, Type Package

Package ssanv. June 23, 2015

Package MultisiteMediation

Package darts. February 19, 2015

Package nsga2r. February 20, 2015

Package flexcwm. R topics documented: July 11, Type Package. Title Flexible Cluster-Weighted Modeling. Version 1.0.

Package sscor. January 28, 2016

Package anoint. July 19, 2015

Package multivariance

Package rbvs. R topics documented: August 29, Type Package Title Ranking-Based Variable Selection Version 1.0.

Package BootWPTOS. R topics documented: June 30, Type Package

Package nardl. R topics documented: May 7, Type Package

Package jaccard. R topics documented: June 14, Type Package

Package polypoly. R topics documented: May 27, 2017

Package mixture. R topics documented: February 13, 2018

Package MAVE. May 20, 2018

Transcription:

Version 0.3.4 Title Fisher-Wright Population Simulation Package fwsim October 5, 2018 Author Mikkel Meyer Andersen and Poul Svante Eriksen Maintainer Mikkel Meyer Andersen <mikl@math.aau.dk> Description Simulates a population under the Fisher-Wright model (fixed or stochastic population size) with a one-step neutral mutation process (stepwise mutation model, logistic mutation model and exponential mutation model supported). The stochastic population sizes are random Poisson distributed and different kinds of population growth are supported. For the stepwise mutation model, it is possible to specify locus and direction specific mutation rate (in terms of upwards and downwards mutation rate). Intermediate generations can be saved in order to study e.g. drift. License GPL-2 Depends R (>= 3.1.0) LinkingTo Rcpp Imports Rcpp (>= 0.11), methods SystemRequirements C++11 NeedsCompilation yes Repository CRAN Date/Publication 2018-10-05 13:30:03 UTC R topics documented: fwsim-package....................................... 2 fwsim............................................ 2 init_........................................ 4.......................................... 6 Index 8 1

2 fwsim fwsim-package Haplotype tools Description Tools for analysing haplotypes, e.g. population simulation. Author(s) Mikkel Meyer Andersen Maintainer: Mikkel Meyer Andersen <mikl@math.aau.dk> fwsim Fisher-Wright Population Simulation Description Usage This package provides tools to simulate a population under the Fisher-Wright model with a stepwise neutral mutation process on r loci, where mutations on loci happen independently. The population sizes are either fixed (traditional/original Fisher-Wright model) or random Poisson distributed with exponential growth supported. Intermediate generations can be saved in order to study e.g. drift. For stochastic population sizes: Model described in detail at http://arxiv.org/abs/1210.1773. Let M be the population size at generation i and N the population size at generation i + 1. Then we assume that N conditionally on M is Poisson(αM) distributed for α > 0 (α > 1 gives expected growth and 0 < α < 1 gives expected decrease). For each haplotype x occuring m times in the i th generation, the number of children n is Poisson(αm) distributed independently of other haplotypes. It then follows that the sum of the number of haplotypes follows a Poisson(αM) distribution (as just stated in the previous paragraph) and that n conditionally on N follows a Binomial(N, m/m) as expected. The mutation model can be e.g. the stepwise neutral mutation model. See init_ for details. fwsim(g, H0, N0,, alpha = 1.0, SNP = FALSE, save_generations = NULL, progress = TRUE, trace = FALSE, ensure_children = FALSE,...) fwsim_fixed(g, H0, N0,, SNP = FALSE, save_generations = NULL, progress = TRUE, trace = FALSE,...) ## S3 method for class 'fwsim' print(x,...) ## S3 method for class 'fwsim' summary(object,...) ## S3 method for class 'fwsim' plot(x, which = 1L,...)

fwsim 3 Arguments G H0 number of generations to evolve (integer, remember postfix L). haplotypes of the initial population. Must be a vector or matrix (if more than one initial haplotype). The number of loci is the length or number of columns of H0. N0 count of the H0 haplotypes. The i th element is the count of the haplotype H0[i, ]. sum(n0) is the size of initial population. alpha a object created with init_. Alternatively, a numeric vector of length r of mutation probabilities (this will create a stepwise mutation model with r loci divide the mutation probabilities evenly between upwards and downwards mutation). vector of length 1 or G of growth factors (1 correspond to expected constant population size). If length 1, the value is reused in creating a vector of length G. SNP to make alleles modulus 2 to immitate SNPs. save_generations to save intermediate populations. NULL means that no intermediate population will be saved. Else, a vector of the generation numbers to save. progress whether to print progress of the evolution. trace whether to print trace of the evolution (more verbose than progress). ensure_children Ensures that every generation has at least one child; implemented by getting Poisson(αM) + 1 children. x Value object which A fwsim object. A fwsim object.... not used. A fwsim object with elements A number specifying the plot (currently only 1: the actual population sizes vs the expected sizes). pars the parameters used for the simulation saved_populations a list of haplotypes in the intermediate populations population haplotypes in the end population after G generations pop_sizes the population size for each generation expected_pop_sizes the expected population size for each generation Author(s) Mikkel Meyer Andersen <mikl@math.aau.dk> and Poul Svante Eriksen

4 init_ Examples # SMM (stepwise mutation model) example set.seed(1) fit <- fwsim(g = 100L, H0 = c(0l, 0L, 0L), N0 = 10000L, = c(loc1 = 0.001, Loc2 = 0.002, Loc3 = 0.003)) summary(fit) fit # SMM (stepwise mutation model) example H0 <- matrix(c(0l, 0L, 0L), 1L, 3L, byrow = TRUE) <- init_(modeltype = 1L, mutpars = matrix(c(c(0.003, 0.001), rep(0.004, 2), rep(0.001, 2)), ncol = 3, dimnames = list(null, c("dys19", "DYS389I", "DYS391")))) set.seed(1) fit <- fwsim(g = 100L, H0 = H0, N0 = 10000L, = ) xtabs(n ~ DYS19 + DYS389I, fit$population) plot(1l:fit$pars$g, fit$pop_sizes, type = "l", ylim = range(range(fit$pop_sizes), range(fit$expected_pop_sizes))) points(1l:fit$pars$g, fit$expected_pop_sizes, type = "l", col = "red") set.seed(1) fit_fixed <- fwsim_fixed(g = 100L, H0 = H0, N0 = 10000L, = ) # LMM (logistic mutation model) example mutpars.locus1 <- c(0.149, 2.08, 18.3, 0.149, 0.374, 27.4) # DYS19 mutpars.locus2 <- c(0.500, 1.18, 18.0, 0.500, 0.0183, 349) # DYS389I mutpars.locus3 <- c(0.0163, 17.7, 11.1, 0.0163, 0.592, 14.1) # DYS391 mutpars <- matrix(c(mutpars.locus1, mutpars.locus2, mutpars.locus3), ncol = 3) <- init_(modeltype = 2L, mutpars = mutpars) set.seed(1) H0_LMM <- matrix(c(15l, 13L, 10L), 1L, 3L, byrow = TRUE) fit_lmm <- fwsim(g = 100L, H0 = H0_LMM, N0 = 10000L, = ) xtabs(n ~ DYS19 + DYS389I, fit_lmm$population) init_ init_ Description Method to initialise a mutation model.

init_ 5 Usage init_(modeltype = 1, mutpars = NULL,...) ## S3 method for class '' print(x,...) Arguments modeltype mutpars x Details... not used. 1: SMM (traditional single-step mutation model). 2: LMM (Logistic mutation model introduced in Jochens (2011) 'Empirical Evaluation Reveals Best Fit of a Logistic Mutation Model for Human Y-Chromosomal Microsatellites'). 3: Exponential mutation model (unpublished). A matrix specifying the mutation parameters for each locus. Rows are parameters and columns are loci. If a vector, the same values are used for all loci. A object. Mutation parameters for each locus. Mutmodel 1 (SMM): 2 parameters per locus P(i -> i-1) = mu_d P(i -> i+1) = mu_u P(i -> i) = 1 - P(i -> i-1) - P(i -> i+1) = 1 - mu_d - mu_u mutpars[1, locus]: mu_d mutpars[2, locus]: mu_u Mutmodel 2 (LMM): 6 parameters per locus P(i -> i-1) = gamma_d / (1 + exp(alpha_d*(beta_d - i))) P(i -> i+1) = gamma_u / (1 + exp(alpha_u*(beta_u - i))) P(i -> i) = 1 - P(i -> i-1) - P(i -> i+1) mutpars[1, locus]: gamma_d mutpars[2, locus]: alpha_d mutpars[3, locus]: beta_d mutpars[4, locus]: gamma_u mutpars[5, locus]: alpha_u mutpars[6, locus]: beta_u Mutmodel 3 (EMM): 4 parameters per locus P(i -> i-1) = 1/((1 + exp(a + b*i))*(1 + exp(alpha + beta*i))) P(i -> i+1) = exp(alpha+beta*i)/((1+exp(a+b*i))*(1+exp(alpha+beta*i))) P(i -> i) = 1 - P(i -> i-1) - P(i -> i+1) = exp(a + b*i)/(1 + exp(a + b*i))

6 mutpars[1, locus]: a mutpars[2, locus]: b mutpars[3, locus]: alpha mutpars[4, locus]: beta Value A object (a list with entires modeltype and mutpars). Examples mutpars <- matrix(c(c(0.003, 0.001), rep(0.004, 2), rep(0.001, 2)), ncol = 3) <- init_(modeltype = 1L, mutpars = mutpars) mutpars.locus1 <- c(0.149, 2.08, 18.3, 0.149, 0.374, 27.4) # DYS19 mutpars.locus2 <- c(0.500, 1.18, 18.0, 0.500, 0.0183, 349) # DYS389I mutpars.locus3 <- c(0.0163, 17.7, 11.1, 0.0163, 0.592, 14.1) # DYS391 mutpars <- matrix(c(mutpars.locus1, mutpars.locus2, mutpars.locus3), ncol = 3) <- init_(modeltype = 2L, mutpars = mutpars) Mutation model logic Description Usage Functions for mutation model logic, e.g. probability of downwards and upwards mutations etc. _not_mut(, locus, alleles) _dw_mut(, locus, alleles) _up_mut(, locus, alleles) approx_stationary_dist(, alleles) Arguments locus alleles a object created with init_. the locus of interest (integer, remember postfix L). vector of integers (remember postfix L) of the alleles of interest. Value Mutation probabilities for locus locus in mutation model at alleleles alleles.

7 Author(s) Mikkel Meyer Andersen <mikl@math.aau.dk> and Poul Svante Eriksen Examples mutpars.locus1 <- c(0.149, 2.08, 18.3, 0.149, 0.374, 27.4) # DYS19 mutpars.locus2 <- c(0.500, 1.18, 18.0, 0.500, 0.0183, 349) # DYS389I mutpars.locus3 <- c(0.0163, 17.7, 11.1, 0.0163, 0.592, 14.1) # DYS391 mutpars <- matrix(c(mutpars.locus1, mutpars.locus2, mutpars.locus3), ncol = 3) <- init_(modeltype = 2L, mutpars = mutpars) _not_mut(, locus = 1L, alleles = 10L:20L) _dw_mut(, locus = 1L, alleles = 10L:20L) _up_mut(, locus = 1L, alleles = 10L:20L) statdists <- approx_stationary_dist(, alleles = 5L:20L) bp <- barplot(statdists, beside = TRUE) text(bp, 0.02, round(statdists, 1), cex = 1, pos = 3) text(bp, 0, rep(rownames(statdists), ncol($mutpars)), cex = 1, pos = 3) mutpars <- matrix(c(c(0.003, 0.001), rep(0.004, 2), rep(0.001, 2)), ncol = 3) <- init_(modeltype = 1L, mutpars = mutpars) statdists <- approx_stationary_dist(, alleles = 5L:20L) statdists bp <- barplot(statdists, beside = TRUE) text(bp, 0.02, round(statdists, 1), cex = 1, pos = 3) text(bp, 0, rep(rownames(statdists), ncol($mutpars)), cex = 1, pos = 3)

Index Topic Fisher-Wright fwsim, 2, 6 Topic package fwsim-package, 2 approx_stationary_dist (), 6 fwsim, 2 fwsim-package, 2 fwsim_fixed (fwsim), 2 init_, 2, 3, 4, 6, 6 _dw_mut (), 6 _not_mut (), 6 _up_mut (), 6 plot.fwsim (fwsim), 2 print.fwsim (fwsim), 2 print. (init_), 4 summary.fwsim (fwsim), 2 8