set.seed(444)
#example for 20 taxa
candleRes<-simCandleTaxa(20)
#let look at the taxa...
taxa<-candleRes$taxonRanges
taxicDivCont(taxa)
#because ancestors don't even exist as taxa
#the true diversity curve can go to zero
#kinda bizarre!
#the tree should give a better idea
tree<-candleRes$tree
phyloDiv(tree)
#well, okay, its a tree.
#get the 'ideal cladogram' ala taxa2cladogram
#much easier with candle-simulations as no paraphyletic taxa
cladogram<-tree
cladogram$edge.length<-NULL
plot(cladogram)
#trying out trueCandle
#random times of observation: uniform distribution
time.obs<-apply(taxa,1,function(x) runif(1,x[2],x[1]))
tree1<-trueCandle(candleRes,time.obs)
layout(1:2)
plot(tree)
plot(tree1)
#let's look at the change in the terminal branches
plot(tree$edge.length,tree1$edge.length)
#can see some edges are shorter on the new tree, cool
#let's now simulate sampling and use FADs
layout(1:2)
plot(tree);axisPhylo()
FADs<-sampleRanges(candleRes$taxonRanges,r=0.1)[,1]
tree1<-trueCandle(candleRes,FADs)
plot(tree1);axisPhylo()
#can condition on sampling some average number of taxa
#analagous to simFossilTaxa_SRcond
r<-0.1
avgtaxa<-50
sumRate<-0.2
ntaxa_orig<-avgtaxa/(r/(r+sumRate)) #avg number necc for an avg number sampled
candles<-simCandleTaxa(ntaxa=ntaxa_orig,sumRate=sumRate)
#note that conditioning must be conducted using full sumRate
#this is because durations are functions of both rates
#just like in bifurcation
layout(1)Run the code above in your browser using DataLab