sim_swf | R Documentation |
Simulate a population forwards with recombination that approximates the Structured Wright Fisher Process and tracks haplotype identity by descent where individuals represent demes, such that within a deme individual-level COI is considered. The model is also extended to consider spatial demes that individual hosts can move between.
sim_swf(pos, N, m, rho, mean_coi, tlim, migr_mat = 1, verbose = FALSE)
pos |
vector; the genomic coordinates for chromosome and position of the sites |
N |
integer vector; The number of individuals to consider in each deme |
m |
numeric numeric; Probability of internal migration where m represents the probability of moving from host_origin to host_new by m*(1-1/N) of each deme |
rho |
numeric; expected recombination rate |
mean_coi |
numeric vector; The lambda of a right-shifted Poisson process, 1 + Pos(lambda) representing the average COI of each deme |
tlim |
numeric; the maximum number of generations to consider before exiting gracefully if all samples have not coalesced |
migr_mat |
numeric matrix; Migrations rates or probabilities between destination and origin. Note, because this is a Wright-Fisher model, we are drawing parents and therefore migration matrix is parameterized towards "where one came from" versus "where one is headed": origin specified as columns and destination in rows. Default value of 1 indicates non-spatial model. Note, if using a probability matrix, rows must sum to 1 (valid marginal probability); otherwise, values will be assumed to be rates and converted to probabilities. |
verbose |
boolean |
Demes are assumed to be ordered throughout (i.e. the order needs to be consistent between N, m, mean_coi, and the rows and columns of the migration matrix).
The migration matrix is assumed to be a distance matrix that is either a rate or a probability. The program will coerce the matrix into a probability distribution between origin and destination based on the row-sums.
This function is intended to be fed into the get_arg function to summarize the simulation results,
Returns a list of length six that contains
pos: The simulated genetic coordinates
coi: The COI of each individual
recomb: A recombination list of length of tlim where each element contains the recombination block – as a boolean – of the two parental haplotypes.
parent_host1: the parental host assignments for the "paternal" haplotype
parent_host1: the parental host assignments for the "maternal" haplotype
parent_haplo1 "paternal" haplotype assigment (as above)
parent_haplo2 "maternal" haplotype assigment (as above)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.