In order to provide some worked examples, we first generate two random phylogenetic trees, with similar parameter settings. We simulate one tree with lambda = 0.4, and one tree with lambda = 0.25, both with 100 tips.
The two trees look similar, but are not identical in shape.
This becomes even more obvious when we plot their normalized Lineage Through Time plots:
Sometimes, it might be more interesting to look at the average nLTT plot across a large number of replicate trees, or to calculate the average normalized Lineages Through Time, for a large number of replicate trees.
Let us first generate 100 random trees:
Using the function nltts_plot we can now plot the normalized Lineages Through Time for all replicates, and on top of that plot the average normalized Lineages Through Time. The replicates are all plotted in grey, and the average lines are plotted in red and blue respectively:
Instead of plotting the average normalized Lineages Through Time, we can also calculate them, and store them in a matrix:
This allows us to do further analysis, and also allows us to plot the two average nLTT plots on top of each other, to see whether the two average nLTT plots differ from each other (mind you, m1 and m2 are matrices, not nLTT objects, so we can plot them using the normal plotting tools available in R)
m1 <- get_average_nltt_matrix(trees1, dt = 0.001) m2 <- get_average_nltt_matrix(trees2, dt = 0.001) plot(m1, type = "s", col = "red", lwd = 2, xlim = c(0, 1), ylim = c(0, 1), xlab = "Normalized Time", ylab = "Normalized number of lineages") lines(m2, type = "s", col = "blue", lwd = 2) legend("topleft", c("trees1", "trees2"), col = c("red", "blue"), lty = 1, lwd = 2)