add.mutations: Add Mutations on a Coalescent Tree

Description Usage Arguments Details Value Examples

View source: R/coalesceR.R

Description

Add mutations on a coalescent tree.

Usage

1

Arguments

tree

an object generated by the sim.tree command

mu

mutation rate

graphics

a logical variable, which is TRUE if the user wants to plot the history, and FALSE otherwise

labels

a logical variable, which is TRUE if the user wants labels to be plotted on the tree, and FALSE otherwise

Details

Adds mutation on a coalescent tree generated by the sim.tree command, using the mutation rate ‘mu’. The mutation model is an Infinite Allele Model. If ‘graphics = TRUE’, then a coalescent tree is drawn, with mutations sketched on the tree. Allelic states of the leafs are represented with different colors. If ‘labels = TRUE’, then the labels are drawn on the graph.

Value

an object of class ‘history’ which is a list with components:

state

the allelic state of each leaf

node

the list of nodes (internal and leafs) in the tree

ancestor

the ancestor of each node

label

the label of each leaf

branch.length

the length of the branch above each node

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## This is to simulate a coalescent tree using the Hudson's algorithm, 
## with 20 sampled lineages. In this example, the current population size
## is 100. It was 1000 before a bottleneck that occurred 50 generations ago

tree <- sim.tree(method = "hudson",sample = 20,current = 100,ancestral = 1000,time = 50)

## This is to generate a history, with a graphical outputs with labels,
## using a mutation rate of 0.001

history <- add.mutations(tree,mu = 0.001,graphics = TRUE, labels = TRUE)

coalesceR documentation built on May 2, 2019, 4:42 p.m.