Learn R Programming

phyloTop (version 1.1.1)

fastModelAnalysis: Fast Model Analysis

Description

A collection of functions which calculate properties of trees more quickly. These functions do a similar job to those in modelAnalysis but they may be slightly more difficult to use and adapt. Many functions in this package share preliminary calculations. This means that in using topSumm, for example, the same code is run several times. The idea behind these functions is to improve the speed by doing these calculations just once. These preliminary computations result in what I call a base. This will mostly be done with baseListCreate and is often most of the work in the calculation of a topology profile. Then, the final topologies of the given trees are created using baseListAnalysis. I refer to functions which create a base from a tree as baseFuncs and those which create a topology from a base as topFuncs.

Usage

baseCreate(tree,baseFuncs)
baseListCreate(treeList,baseFuncs,loadingBar = TRUE)
baseAnalysis(base,topFuncs)
baseListAnalysis(baseList,topFuncs,loadingBar = FALSE)

Arguments

tree
An object of class phylo4.
baseFuncs
A list of functions which each take a phylogenetic tree as an input and give any output.
treeList
A list where the elements of the list are cobjects of class phylo4.
loadingBar
A Boolean. If true, it results in the number of elements evaluated so far being printed as each is evaluated. This gives some indication of how long the function will take.
base
A list. Each element of the list is intented to be the result of an element of BaseFuncs on a phylogenetic tree.
baseList
A list where each element is a base. This results in a nested list.
topFuncs
A list of functions which ecah takes an element ofthe base and returns a number.

Value

  • baseCreateA base. That is a list where each element is a result of a function on a tree. The length of the list will be the same as the length as baseFuncs
  • baseListCreateA list where each element is the base (for the given baseFuncs) for an element of treeList. So it's length will be the same as that of treeList
  • baseAnalysisA matrix with one row and number of columns equal to the length of topFuncs.
  • baseListAnalysisA dataframe where each row corresponds to a different base and each column to a different topological property. So the number of columns is equal to the length of topFunc and the number of rows is equal to the length of baseList.

Details

baseCreate creates the base for a tree. That is, it runs a number of functions (contaied in list baseFuncs) on the tree and stores the result in a list. baseListCreate does the same as baseCreate but for a list of trees (called treeList). The result is therefore a list of bases. This is quite a complicated object. It is a list of the same length as treeList. Each element of this list is a base corresponding to a tree in treeList - that is a list of the same length as baseFuncs. loadingBar defaults to TRUE as this function may take a long time baseAnalysis analyses a given base using functions (contained in topFuncs) which act on each member of the base. That is, the first element of topFuncs will take the fist element of the base and return a number. The list of all these numbers is a topological profile of the tree. This list is what baseAnalysis returns. baseListAnalysis does the same as baseList but to each element of a list of bases. The result is a dataframe where each row corresponds to a different base and each column to a different topological property.

See Also

modelAnalysis contains simpler but slower functions with similar effects. There are also a number of ways to create treeList in this section. See allNodeAnalysis,configurations and treeAnalysis for some possibilities for what to put in baseFuncs. topFuncs conatins a number of useful options for putting in topFuncs

Examples

Run this code
## This is an example of using bases to speed up calculation of topological properties.

## Creates a tree
tree <- rtree4(50)

## Sets up the list of bases 
baseFuncs <- c(ladderNums, treeImb, nTipDescendants)

## Creates the base
base <- baseCreate(tree,baseFuncs)

## Sets up the list of functions from the base
## Note that the functions are matched with the correct base element
topFuncs <- c(fNLadders,fColless,function(x) {fNConfig(x,2)})

## Finds the topological properties
baseAnalysis(base,topFuncs)

## Now a new list of topFuncs
## Some of these use the same elements of the base
## This means that there will be a speed improvement
topFuncs2 <- c(topFuncs, function(x) {fNConfig(x,3)},fAvgLadder)

## Now we must create an appropriate base for these topFuncs
## Note that the elements are matched to those of topFuncs
base2 <- c(base,base[3],base[1])

## And the new topological properties
baseAnalysis(base2,topFuncs2)

Run the code above in your browser using DataLab