Loop function over all trees in object of class 'multiphylo'
0
0
Entering edit mode
8.9 years ago

I wish to run some analyses on all the trees that come as output in the BEAST run. Most of the functions say they can be run only on the objects of class 'phylo'. For example - functions in the package 'laser'. I am trying to use a for loop and iterating over all the objects in multiphylo. For eg, to fit a birth-date model

library(laser)

f=read.nexus(file.choose())
bdmodel<-0
for(i in 1:length(f))
{
    bdmodel[i]<-bd(branching.times(trees[[i]]), ai = seq(0.05, 0.99, length.out = 20))
    print(usq[i])
}
print(i)

Is there a better way of doing this? I wish to iterate particular operations on all the trees in the multiphylo object and get output for each single tree.

Phylogenetics R loop • 2.3k views
ADD COMMENT

Login before adding your answer.

Traffic: 1649 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6