## Create a function to test
maxLadd <- function(tree) {max(ladderNums(tree))}
## Create a model
## NOTE THE USE OF 'as'
bdModel <- function() {as(rlineage(0.5,0.1,Tmax=6),'phylo4')}
## A simple example of modelSummary
modelSummary(function(){rtree4(50)},topList=c(avgLadder,sackin),n=10)
## Another example using the created model and function
modelSummary(bdModel,topList=c(maxLadd,sackin),n=10,loadingBar=FALSE)
## Create a list of trees for more detailed analysis
bdTrees <- modelCreate(bdModel,10)
## Select a number of topological summaries to calculate
summaries <- c(avgLadder,maxLadd,sackin,function(tree){nConfig(tree,2)})
## Calculate these summaries for the trees in question
bdSummary <- treeListSummary(bdTrees,summaries)
names(bdSummary) <- c('avgLadder','maxLadd','Sackin','Cherries')
### I WILL NOW ILLUSTRATE SOME USES OF THE PACKAGE
### THESE METHODS USE LIBARY ggplot2
### IT WILL NEED TO BE SEPERATELY INSTALLED IF YOU WISH TO USE IT
# Initialize a plot
p <- ggplot(data=bdSummary)
# Simple bar plot
p + geom_bar(aes(avgLadder),binwidth=0.1)
# Simple scatter plot
p + geom_point(aes(x=Sackin,y=Cherries))
### See exampleSummary for more examples of plots
Run the code above in your browser using DataLab