TreeSearch (version 0.4.0)

Jackknife: Parsimony Ratchet

Description

Ratchet uses the parsimony ratchet (Nixon 1999) to search for a more parsimonious tree.

Usage

Jackknife(tree, dataset, resampleFreq = 2/3,
  InitializeData = PhyDat2Morphy, CleanUpData = UnloadMorphy,
  TreeScorer = MorphyLength, EdgeSwapper = TBRSwap, jackIter = 5000L,
  searchIter = 4000L, searchHits = 42L, verbosity = 1L, ...)

Ratchet(tree, dataset, InitializeData = PhyDat2Morphy, CleanUpData = UnloadMorphy, TreeScorer = MorphyLength, Bootstrapper = MorphyBootstrap, swappers = list(TBRSwap, SPRSwap, NNISwap), BootstrapSwapper = if (class(swappers) == "list") swappers[[length(swappers)]] else swappers, returnAll = FALSE, stopAtScore = NULL, stopAtPeak = FALSE, stopAtPlateau = 0L, ratchIter = 100, ratchHits = 10, searchIter = 4000, searchHits = 42, bootstrapIter = searchIter, bootstrapHits = searchHits, verbosity = 1L, suboptimal = 1e-08, ...)

ProfileRatchet(tree, dataset, swappers = list(TBRSwap, SPRSwap, NNISwap), BootstrapSwapper = if (class(swappers) == "list") swappers[[length(swappers)]] else swappers, returnAll = FALSE, stopAtScore = NULL, stopAtPeak = FALSE, stopAtPlateau = 0L, ratchIter = 100, ratchHits = 10, searchIter = 2000, searchHits = 40, bootstrapIter = searchIter, bootstrapHits = searchHits, verbosity = 1L, suboptimal = 1e-08, ...)

IWRatchet(tree, dataset, concavity = 10, swappers = list(TBRSwap, SPRSwap, NNISwap), BootstrapSwapper = if (class(swappers) == "list") swappers[[length(swappers)]] else swappers, returnAll = FALSE, stopAtScore = NULL, stopAtPeak = FALSE, stopAtPlateau = 0L, ratchIter = 100, ratchHits = 10, searchIter = 2000, searchHits = 40, bootstrapIter = searchIter, bootstrapHits = searchHits, verbosity = 1L, suboptimal = 1e-08, ...)

MultiRatchet(tree, dataset, ratchHits = 10, searchIter = 500, searchHits = 20, verbosity = 0L, swappers = list(RootedNNISwap), nSearch = 10, stopAtScore = NULL, ...)

IWMultiRatchet(tree, dataset, ratchHits = 10, concavity = 4, searchIter = 500, searchHits = 20, verbosity = 0L, swappers = list(RootedNNISwap), nSearch = 10, suboptimal = suboptimal, stopAtScore = NULL, ...)

RatchetConsensus(tree, dataset, ratchHits = 10, searchIter = 500, searchHits = 20, verbosity = 0L, swappers = list(RootedNNISwap), nSearch = 10, stopAtScore = NULL, ...)

IWRatchetConsensus(tree, dataset, ratchHits = 10, concavity = 4, searchIter = 500, searchHits = 20, verbosity = 0L, swappers = list(RootedNNISwap), nSearch = 10, suboptimal = suboptimal, stopAtScore = NULL, ...)

Arguments

tree

A tree of class phylo.

dataset

a dataset in the format required by TreeScorer().

resampleFreq

Double between 0 and 1 stating proportion of characters to resample

InitializeData

Function that sets up data object to prepare for tree search. The function will be passed the dataset parameter. Its return value will be passed to TreeScorer() and CleanUpData().

CleanUpData

Function to destroy data object on function exit. The function will be passed the value returned by InitializeData().

TreeScorer

function to score a given tree. The function will be passed three parameters, corresponding to the parent and child entries of a tree's edge list, and a dataset.

EdgeSwapper

a function that rearranges a parent and child vector, and returns a list with modified vectors; for example SPRSwap().

jackIter

Integer specifying number of jackknife iterations to conduct

searchIter

Integer specifying maximum rearrangements to perform on each bootstrap or ratchet iteration. To override this value for a single swapper function, set e.g. attr(SwapperFunction, 'searchIter') <- 99

searchHits

Integer specifying maximum times to hit best score before terminating a tree search within a ratchet iteration. To override this value for a single swapper function, set e.g. attr(SwapperFunction, 'searchHits') <- 99

verbosity

Level of detail to display in console: larger numbers provide more verbose feedback to the user.

further arguments to pass to TreeScorer() (e.g. TipsAreColumns, dataset).

Bootstrapper

Function to perform bootstrapped rearrangements of tree. First arguments will be an edgeList and a dataset, initialized using InitializeData(). Should return a rearranged edgeList.

swappers

A list of functions to use to conduct edge rearrangement during tree search. Provide functions like NNISwap to shuffle root position, or RootedTBRSwap if the position of the root should be retained. You may wish to use extreme swappers (such as TBR) early in the list, and a more subtle rearranger (such as NNI) later in the list to make incremental tinkerings once an almost-optimal tree has been found.

BootstrapSwapper

Function such as RootedNNISwap to use to rearrange trees within Bootstrapper().

returnAll

Set to TRUE to report all MPTs encountered during the search, perhaps to analyse consensus.

stopAtScore

stop search as soon as this score is hit or beaten.

stopAtPeak

Logical specifying whether to terminate search once a subsequent iteration recovers a sub-optimal score. Useful with methods that return all trees one rearrangement from the current tree, such as AllTBR(). Will be overridden if a passed function has an attribute stopAtPeak set by attr(FunctionName, 'stopAtPeak') <- TRUE.

stopAtPlateau

Integer. If > 0, tree search will terminate if the score has not improved after stopAtPlateau iterations. Useful with methods that return all trees one rearrangement from the current tree, such as AllTBR(). Will be overridden if a passed function has an attribute stopAtPlateau set by attr(FunctionName, 'stopAtPlateau') <- TRUE.

ratchIter

Stop when this many ratchet iterations have been performed.

ratchHits

Stop when this many ratchet iterations have found the same best score.

bootstrapIter

Integer specifying maximum rearrangements to perform on each bootstrap iteration (default: searchIter).

bootstrapHits

Integer specifying maximum times to hit best score on each bootstrap iteration (default: searchHits).

suboptimal

retain trees that are suboptimal by this score. Defaults to 1e-08 to counter rounding errors.

concavity

A numeric value to use as the concavity constant (k) in implied weighting. Defaults to 10; TNT sets a default of 3, but this is too low in some circumstances (Smith, 2019).

nSearch

Number of Ratchet searches to conduct (for RatchetConsensus())

Value

a list of trees recovered after jackknife iterations

This function returns a tree modified by parsimony ratchet iterations.

MultiRatchet() returns a list of optimal trees produced by nSearch ratchet searches, from which a consensus tree can be generated using ape::consensus() or TreeTools::ConsensusWithout().

IWMultiRatchet returns a list of optimal trees produced by nSearch Ratchet searches, using implied weighting.

Functions

  • Jackknife: Jackknife resampling. Note that at present this assumes that InitializeData will return a morphy object; if this doesn't hold for you, please let me know and I'll make the function more general.

  • ProfileRatchet: Shortcut for Ratchet search under Profile Parsimony

  • IWRatchet: Shortcut for Ratchet search using implied weights

  • RatchetConsensus: deprecated alias for MultiRatchet()

  • IWRatchetConsensus: deprecated alias for MultiRatchet()

References

  • Nixon1999TreeSearch

  • SmithTernTreeSearch

See Also

  • JackLabels(): Label nodes of a tree with jackknife supports.

Examples

Run this code
# NOT RUN {
data('Lobo', package='TreeTools')
njtree <- TreeTools::NJTree(Lobo.phy)
# Increase value of ratchIter and searchHits to do a proper search
quickResult <- Ratchet(njtree, Lobo.phy, ratchIter = 2, searchHits = 3)

# Plot result (legibly)
oldPar <- par(mar = rep(0, 4), cex = 0.75)
plot(quickResult)
par(oldPar)

# IW search is currently much slower:
quickIWResult <- IWRatchet(quickResult, Lobo.phy, concavity = 2.5,
                           ratchIter = 1, searchIter = 25, searchHits = 2,
                           swappers = RootedTBRSwap, verbosity = 5)
 
# }

Run the code above in your browser using DataLab