inapplicable-package: Inapplicable data in parsimony analysis

Description Details Author(s) References See Also Examples

Description

This package correctly calculates tree parsimony scores when datasets contain inapplicable data, and provides functions to rearrange trees whilst preserving the outgroup. The package also contains heuristic search methods to locate the most parsimonious tree.

Details

This package calculates the parsimony score on phylogenetic trees. It can also be used to find the most parsimonious tree. The Examples section below provides a step-by-step guide to using this package on your own data.

Character data are read from a restricted NEXUS format using the R function read.nexus.data; see the latter function's documentation for details.

NEXUS files can be edited in any standard text editor, for example Notepad++.

A notable annoyance is that the parser cannot interpret curly braces, for example 01. Ambiguous tokens of this nature should be replaced with a separate character, for example 'A' to denote 01, 'B' to denote 12, perhaps using a search-and-replace operation in your favourite text editor.

Be aware that the algorithm distinguishes between character-states that are inapplicable; character-states that are ambiguous (but definitely not inapplicable); and character-states that are ambiguous (and may or may not be applicable). These three cases should be denoted with different tokens: perhaps '-', '+' and '?'.

Author(s)

Martin R. Smith

References

BRAZEAU, M. D., GUILLERME, T. and SMITH, M. R. 2017. [Morphological phylogenetic analysis with inapplicable data](https://www.biorxiv.org/content/early/2017/10/26/209775). BioRxiv. doi:10.1101/209775

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## Not run: 

## Walkthrough of package functions

## NOT UP TO DATE. WILL BE UPDATED IN EARLY NOVEMBER 2017...

## To use this script on your own data, launch R, and type (or copy-paste) the following text
## into the R console.  Lines starting with '#' are comments and do not need to be copied.


## To install the package for the first time, type
install.packages('inapplicable')

## Once the package has been installed, load it using
library(inapplicable)

## Data can be read from a nexus file (note the restrictions detailed above):
my.data <- read.nexus.data('C:/path/to/filename.nex')

## Alternatively you can use a built-in dataset:
data(inapplicable.datasets); my.data <- inapplicable.datasets[[1]]

## Data should be converted to the phyDat format, with the inapplicable token listed as a level:
my.phyDat <- phyDat(my.data, type='USER', levels=c(0:9, '-'))

## Load a bifurcating tree,
tree <- read.nexus(treename.nex)
## or generate a random starting tree, 
tree <- rtree(length(my.phyDat), rooted=TRUE, tip.label=names(my.phyDat), br=NULL)
## or use neighbour joining to generate a starting tree
tree <- ape::nj(phangorn::dist.hamming(my.phyDat))
tree$edge.length <- NULL;

## Root the tree on an appropriate outgroup, if desired
my.outgroup <- names(my.phyDat[1])
tree <- ape::root(tree, my.outgroup, resolve.root=TRUE)

## View the starting tree by typing
par(mar=rep(0.5, 4)) # Shrinks the margins of the plot so there's more space for the tree
plot(tree)

## Calculate the tree's parsimony score
InapplicableFitch(tree, my.phyDat)

## Search for a better tree
better.tree <- TreeSearch(tree, my.phyDat, verbosity=5)
## Use Nearest Neighbour interchange to find a local optimum
better.tree <- TreeSearch(better.tree, my.phyDat, Rearrange = TreeSearch::RootedNNI,
                          maxIter=40000, maxHits=75, verbosity=2)
## Try the parsimony ratchet (Nixon, 1999) for a more exhaustive search of treespace
better.tree <- Ratchet(better.tree, my.phyDat, maxIt=25, maxIter=250, maxHits=20, k=5)
## The default parameters may not be enough to find the most parsimonious tree; type 
##    ?Ratchet or ?SectorialSearch to view all search parameters.

## View the results
plot(better.tree)

## Once you have reached the most parsimonious tree, 
## retain multiple trees to determine the consensus: 
best.trees <- RatchetConsensus(better.tree, my.phyDat, nSearch=10, maxIt=25, 
                               maxIter=250, maxHits=20, k=5)

## Calculate and display the consensus tree
plot(my.consensus <- consensus(best.trees))

## End(Not run)

ms609/inapplicable documentation built on May 23, 2019, 7:49 a.m.