sim.bdh.taxa.gsa: Simulate a Phylogenetic Network to a Specified Number of Taxa

View source: R/sim.bdh.taxa.R

sim.bdh.taxa.gsaR Documentation

Simulate a Phylogenetic Network to a Specified Number of Taxa

Description

Simulates a Phylogenetic Network under a birth-death-hybridization model. Simulates to a specified number of extant tips under the General Sampling Approach.

Usage

sim.bdh.taxa.gsa(
  m,
  n,
  numbsim,
  lambda,
  mu,
  nu,
  hybprops,
  hyb.inher.fxn,
  frac = 1,
  twolineages = FALSE,
  complete = TRUE,
  stochsampling = FALSE,
  hyb.rate.fxn = NULL,
  trait.model = NULL,
  mrca = deprecated()
)

Arguments

m

The number of taxa to simulate under the SSA

n

The number of taxa.

numbsim

Number of networks to simulate.

lambda

Speciation rate.

mu

Extinction rate.

nu

Hybridization rate.

hybprops

Vector that represents the proportion of Hybridizations that are lineage generative, lineage degenerative, and lineage neutral respectively.

hyb.inher.fxn

A function for drawing the hybrid inheritance probabilities.

frac

Sampling fraction: The proportion of extant tips included in the phylogeny (incomplete sampling).

twolineages

If twolineages=TRUE: The process originates with two lineages that share a common ancestor. If twolineages=FALSE: The process originates with two lineages.

complete

If complete = TRUE, the tree with the extinct lineages is returned. If complete = FALSE, the extinct lineages are suppressed.

stochsampling

When stochsampling=TRUE: Each extant tip is included into the final tree with probability frac.

hyb.rate.fxn

The probability of a successful hybridization as a function of genetic distance between taxa. The default value of 'NULL“ assumes that hybridization success is independent of genetic distance between taxa.

trait.model

A list that dictates how a trait affects the hybridization process. The default value of NULL doesn't take a trait into account for simulation. See Details for more information.

mrca

[Deprecated] Use the twolineages argument

Details

hyb.inher.fxn should return values between 0 and 1 and shouldn't require any arguments. E.g. make.beta.draw and make.uniform.draw create functions that fit these specifications

hyb.rate.fxn should take one argument for the genetic distance. The function should be defined on the range [0,Inf) and return values between [0,1]

trait.model is a list with the following named elements:

  • initial The initial trait state on the phylogeny

  • hyb.event.fxn A function that denotes the trait of a hybrid child after a hybridization event. The function should have the arguments parent_states and inheritance. parent_states is vector with the ploidy states of the hybrid parents while inheritance is the inheritance probability of the first lineage denoted in parent_states.

  • hyb.compatibility.fxn A function that describes when hybridization events can occur between two taxa based on their traits. The function should have the argument parent_states, a vector with the trait states of the two parents to the hybrid child. The function should return TRUE for when a hybridization event is allowed to proceed and FALSE otherwise.

  • time.fxn A function that describes how traits change over time. The function should have the arguments trait_states and timestep in that order. trait_states is a vector containing the ploidy of all taxa while timestep is the amount of time given for trait evolution. The function should return a vector with the updated ploidy states of all taxa.

  • spec.fxn A function that describes how the trait changes at speciation events.The function should have the argument tip_state which has the state of the lineage just before speciation. The function should return a vector with two values, one denoting the trait of each of the two new species after the event.

Value

out Returns a list of numbsim networks with the time since origin / most recent common ancestor being 'age.' If tree goes extinct or no tips are sampled, return value is '0'. If only one extant and no extinct tips are sampled, return value is '1'. Each network has an additional attribute "inheritance" that represents the inheritance probabilities on the edges in the "reticulation" attribute.

Examples

##smallest Quartan prime as seed for reproducibility
set.seed(17)
##Generate a tree with extinct leaves
net<-sim.bdh.taxa.gsa(m=21,n=5,1,3,2,0.5,c(1/3,1/3,1/3),
hyb.inher.fxn = make.uniform.draw(),complete=TRUE)[[1]]

jjustison/SiPhyNetwork documentation built on Sept. 14, 2024, 8:58 a.m.