sim.metapopgen.dioecious: Simulate one-locus metapopulation genetics (dioecious life...

Description Usage Arguments Value Examples

View source: R/sim.metapopgen.dioecious.R

Description

Simulates the metapopulation genetics. The function will calculate automatically from its arguments the number of alleles l, the number of genotypes m, the number of demes n and the number of age-classes z. It is therefore important that all the arguments have the correct dimensions and size.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  res <- sim.metapopgen.dioecious(input.type,
                                  demographic.data,
                                  N1_M, N1_F,
                                  sigma_M, sigma_F,
                                  phi_F, phi_M,
                                  fec.distr_F = "poisson", fec.distr_M = "poisson",
                                  mu,
                                  delta,
                                  recr.dd="settlers", kappa0,
                                  T_max,
                                  save.res = F, save.res.T = seq(1,T_max),
                                  verbose = F)
                                  
                                  

Arguments

input.type

Character vector defining whether the input data are giving as arrays ("array") or as a data frame ("data.frame")

demographic.data

If the input is given as a data.frame (input.type = "data.frame"), a data frame giving 1) survival probabilities and fecundities for each genotype, deme, age-class, sex and time and 2) number of individuals for each genotype, deme, sex and age-class at the beginning of the simulation

N1_M

Number of male individuals at the beginning of the simulation. 3-D array giving the number of individuals of each genotype in each deme and each age-class at the beginning of the simulation. The first dimension is the genotype, the second dimension is the deme and the third dimension is the age-class. To be used when input.type = "array".

N1_F

Number of female individuals at the beginning of the simulation. The same as N1_M.

sigma_M

Survival probabilities for males. 4-D array of length c(m,n,z,T_max). sigma[j,i,x,t] is the survival probability for individuals of genotype j, age x in deme i at time t. Alternatively, sigma_M can be a 3-D array of length c(m,n,z): this will be interpreted as male survival probabilities constant in time. All the elements of sigma are bounded between [0,1]. To be used when input.type = "array".

sigma_F

Survival probabilities for females. The same as sigma_M.

phi_F

Mean female fecundity. 4-D array of length c(m,n,z,T_max). phi_F[j,i,x,t] is the female fecundity for individuals of genotype j, age x in deme i at time t. Alternatively, phi_F can be a 3-D array of length c(m,n,z): this will be interpreted as female fecundities constant in time. The female fecundity is the per capita number of female gametes (eggs for animals, embrio sacs for plants). All the elements of phi_F must be natural numbers. To be used when input.type = "array".

phi_M

Mean male fecundity. 4-D array of length c(m,n,z,T_max). phi_M[j,i,x,t] is the male fecundity for individuals of genotype j, age x in deme i at time t. Alternatively, phi_M can be a 3-D array of length c(m,n,z): this will be interpreted as male fecundities constant in time. The male fecundity is the per capita number of male gametes (sperms for animals, pollen grains for plants). All the elements of phi_F must be natural numbers. To be used when input.type = "array".

fec.distr_F, fec.distr_M

The distribution used to set fecundities: one of "fixed" or "poisson" (default). The "fixed" option sets the fecundity of each individual equal to the mean (phi_F and phi_M). Option "poisson" draws individual fecundities form a Poisson distribution with means phi_F and phi_M.

mu

Mutation rates. Square matrix of size l*l. mu[i,j] is the probability that allele j mutates into allele i. The elements of the diagonal of mu are the probabilities that the allele does not mutate, i.e. it must be colSums(mu) = 1

delta

Dispersal probabilities. Square matrix of size n*n. delta[i,j] is the dispersal probability from deme j to deme i. Alternatively, delta can be a 2-D array of length c(n,n): this will be interpreted as dispersal constant in time.

recr.dd

Defines how population regulation is performed. Currently inactive.

kappa0

2-D array of length c(n,T_max). Deme carrying capacity used to perform population regulation. kappa0 can also be a 1-D array of length n: this will be interpreted as a carrying capacity constant in time.

T_max

Number of years of simulations.

save.res

Boolean. If FALSE (default), the result of the simulation is stored in memory and returned to the user. If TRUE, the function does not return anything, but save the result in different files on disk. See "value" below.

save.res.T

Vector. If save.res=TRUE, this argument is used to define the time steps for which the state of the metapopulation will be saved on disk. It is used to save disk space in the case of long simulations with many demes or genotypes. It deafults to seq(1,T_max), that is, the results are saved every time step.

verbose

Boolean. If TRUE, the function will print much information, mainly used for debugging purposes. Default to FALSE.

Value

If save.res is FALSE: a named list with two elements, N_M and N_F, both 4-D arrays (ex: N_M[k,i,x,t] N_F[k,i,x,t]) of length c(m,n,z,tmax) giving the number of male and female individuals of genotype k, age x in deme i at time t.
If save.res is TRUE: the function does not return anything. Results are saved in files on disk. The function will create a folder named with the date and time of your simulation and create one RData file per year of simulation (but see argument save.res.T for defining the time steps for which the results are saved). Each file will contain the variables N_M and N_F, both 3-D arrays (N_M[k,i,x] N_F[k,i,x]) of length c(m,n,z) giving the number of male and fenale individuals of genotype k, age x in deme i at that time.

Examples

1
2
3
4
5
6
7
8
9
data(FourPopDioecious)
res <- sim.metapopgen.dioecious(input.type="array",N1_M=N1_M, N1_F=N1_F,
  sigma_M=sigma_M, sigma_F=sigma_F, phi_F=phi_F, phi_M=phi_M, mu=mu,
  delta=delta, kappa0=kappa0, T_max=T_max)

# This will save results on disk:
sim.metapopgen.dioecious(input.type="array",N1_M=N1_M, N1_F=N1_F,
  sigma_M=sigma_M, sigma_F=sigma_F, phi_F=phi_F, phi_M=phi_M, mu=mu,
  delta=delta, kappa0=kappa0, T_max=T_max, save.res=T)

MarcoAndrello/MetaPopGen-2.0 documentation built on Nov. 25, 2020, 11:20 p.m.