rcophylo: Simulate cophylogenies

View source: R/rcophylo.R

rcophyloR Documentation

Simulate cophylogenies

Description

This function simulates the process of a parasite lineage that codiversifies with a host lineage through a number of possible events such as cospeciation, extinction and host-switching. The host tree can either be supplied or simulated along with the parasite tree.

Usage

rcophylo(
  beta = 0.1,
  nu = 0.5,
  gamma = 0,
  sigma = 0,
  kappa = 0,
  delta = 0,
  thetaS = NULL,
  thetaE = NULL,
  HTree = NULL,
  lambda = 1,
  mu = 0.5,
  K = Inf,
  tmax = NULL,
  nHmax = Inf,
  PStartT = 0,
  iniHBranch = NULL,
  Gdist = NULL,
  exportFormat = "cophylogeny",
  timestep = 0.001
)

Arguments

beta

a numeric value giving the baseline parasite host shift rate.

nu

a numeric value giving the parasite extinction rate.

gamma

a numeric value giving the dependency of host shift success on phylogenetic distance between the old and the new host.

sigma

a numeric value determining how successful host shift are when the new host is already infected by a parasite. Specifically, the probability of host shift success (1-\sigma)^n, where n is the number of pre-existing parasites on the new host branch.

kappa

a numeric value giving the parasite speciation rate within hosts.

delta

a numeric value giving the probability of lineage loss during co-speciation. delta=0 specifies faithful transmission of the parasites to both new host species, whereas delta=1 specifies that parasites will only be inherited by one daughter host species.

thetaS

a numeric value giving the influence of parasite infection on host speciation rate. thetaS acts as a multiplier of the speciation rate, so thetaS = 1 specifies the default conditions. If thetaS is not required, the parameter can be left as the default NULL.

thetaE

a numeric value giving the influence of parasite infection on host speciation rate. If coinfections are absent, thetaE is a simple multiplier of the extinction rate. If hosts can be infected by multiple parasites at a time, extinction rate is a power function \mu*\theta_E^n where n is the number of coinfections. If thetaE is not required, the parameter can be left as the default NULL.

HTree

a pre-built host phylogenetic tree.

lambda

a numeric value giving the host speciation rate.

mu

a numeric value giving the host extinction rate.

K

a numeric value giving the carrying capacity for the host species.

tmax

a numeric value giving the length of the simulation.

nHmax

a numeric value giving the number of host species at which the simulation is stopped.

PStartT

the timepoint at which a parasite invades the host tree (default set to 0).

iniHBranch

numerical. The host branch number from which the parasite invasion is initiated. If left at the default value NA, a randomly chosen host branch alive at PStartT (time of infection) will be selected.

Gdist

optional: a pre-calculated distance matrix of the living host branches at PStartT (time of infection). Providing this matrix will speed up the calculation which may be useful when running several simulations on the same host tree.

exportFormat

a string specifying either "cophylogeny" or "raw". Where "cophylogeny" specifies that the output will be exported as class "cophylogeny" (the default). "raw" exports the output as two objects of class "data.frame".

timestep

a numeric value giving the time step by which the simulation proceeds. Increase to make the simulation faster or decrease to make it more precise.

Value

By default, an object of class "cophylogeny" is returned that is a list of phylo objects (one for the host and one for the parasite), as specified in the R-package "ape". If the argument exportFormat is set to "raw" the function returns a list of dataframes containing information on all the branches in the trees. (These dataframes are what the function uses internally.)

Examples

cophylogeny <- rcophylo(tmax=5)
print(cophylogeny)
plot(cophylogeny)

JanEngelstaedter/cophy documentation built on Nov. 7, 2023, 9:37 a.m.