data("rtrees50")
write.table(rtrees50, file = 'temp.txt', quote=FALSE,
row.names = FALSE, col.names = FALSE)
#creates a temporary file with trees in Newick format, identical to
# output from PHYLOGEN & other software
btimes <- getBtimes.batch(fname = "temp.txt")
# now btimes is a matrix of branching times. Rows are different trees;
# columns are branching times.
# To verify that this has correctly read the tree, we can plot the log-
# lineages through time for the first tree:
plotLtt(btimes[1,])
# And we can compute the gamma statistic for this set of branching times:
gamStat(btimes[1,])
# or if you wanted to compute the gamma statistic for each tree:
result <- as.numeric(apply(btimes, MARGIN=1, gamStat, return.list=FALSE))
hist(result) #plot histogram of gamma stat values for trees
unlink("temp.txt") #clean up; delete temp file.
Run the code above in your browser using DataLab