tree: a phylogenetic tree. The tree needs not to be ultrametric or fully dichotomous.
s: the percentage of tips to be cut off. It is set at 25% by default.
sdata: to be supplied to condition the species sampling. It can be either a named vector or a data.frame/matrix having the species names as first column. In case of stratified random sampling, sdata should contain the strata. Otherwise, the user can provide a sampling probability (meant as the probability to be removed from the tree) for each species.
nodes: the clades to be preserved. In this case the function maintains no less than 5 species at least in each of them.
categories: the categories to be preserved. In this case the function maintains no less than 5 species at least in each of them.
swap.si, swap.si2, swap.node: arguments si, si2, node as passed to swapONE. The default for both si and si2 is 0.1.
nsim: number of phylogenies to return. It is set at 1 by default.
Returns
The function returns phylo or multiPhylo object. The output always has an attribute "Call" which returns an unevaluated call to the function.
Examples
## Not run:DataCetaceans$treecet->treecet
plot(treecet,show.tip.label =FALSE,no.margin =TRUE)nodelabels(frame="n",col="red")# Select two clades for stratified random samplingclanods=c("crown_Odo"=150,"crown_Mysti"=131)sdata1<-do.call(rbind,lapply(1:length(clanods),function(w) data.frame(species=tips(treecet,clanods[w]),group=names(clanods)[w])))# generate a vector of probabilities based on body massprdata<-max(DataCetaceans$masscet)-DataCetaceans$masscet
# select two nodes to be preservednn=c(180,159)# generate two fictional categorical vectors to be preservedcat1<-sample(rep(c("a","b","c"),each=39),Ntip(treecet))names(cat1)<-treecet$tip.label
cat2<-rep(c("d","e"),each=100)names(cat2)<-sample(treecet$tip.label,100)# 1. Random samplingresampleTree(treecet,s=0.25,swap.si=0.3)->treecet1
# 1.1 Random sampling preserving cladesresampleTree(treecet,s=0.25,nodes=nn)->treecet2
# 2. Stratified random samplingresampleTree(treecet,sdata = sdata1,s=0.25)->treecet3
# 2.1 Stratified random sampling preserving clades and categoriesresampleTree(treecet,sdata = sdata1,s=0.25,nodes=nn,categories = list(cat1,cat2))->treecet4
# 3. Sampling conditioned on probabilityresampleTree(treecet,sdata = prdata,s=0.25,nsim=5)->treecet5
## End(Not run)