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)
<- scrm('5 1 -r 1.5 100 -T')
sum_stats $trees[[1]] sum_stats
## [1] "[11]((1:0.0401804,2:0.0401804):0.892823,(4:0.483554,(5:0.184723,3:0.184723):0.298831):0.449449);"
## [2] "[67]((1:0.0401804,2:0.0401804):0.892823,(4:0.483554,(3:0.157116,5:0.157116):0.326438):0.449449);"
## [3] "[6](4:0.483554,((1:0.0401804,2:0.0401804):0.431344,(3:0.157116,5:0.157116):0.314408):0.0120295);"
## [4] "[7]((3:0.157116,5:0.157116):0.775887,(4:0.483554,(1:0.0401804,2:0.0401804):0.443373):0.449449);"
## [5] "[9]((4:0.309287,(3:0.157116,5:0.157116):0.152171):0.623716,(1:0.0401804,2:0.0401804):0.892823);"
Now we can convert the trees into ape’s internal format using
read.tree
:
library(ape)
<- read.tree(text = paste0(sum_stats$trees[[1]]))
trees trees
## 5 phylogenetic trees
And – for example – print the trees:
plot(trees, no.margin = TRUE)