Simulating trees for ape

set.seed(40)

The trees in 'newick' format produced by scrm's -T option are compatible with the read.tree function from package 'ape'. This quick example shows how we can exploid this to visualize the Ancestral Recombination Graph (ARG) simulated with scrm.

First, we call scrm to simulate the ARG:

library(scrm)
sum_stats <- scrm('5 1 -r 1.5 100 -T')
sum_stats$trees[[1]]

Now we can convert the trees into ape's internal format using read.tree:

library(ape)
trees <- read.tree(text = paste0(sum_stats$trees[[1]]))
trees

And -- for example -- print the trees:

plot(trees, no.margin = TRUE)


Try the scrm package in your browser

Any scripts or data that you put into this service are public.

scrm documentation built on March 18, 2022, 7:12 p.m.