I have a dataset of binary morphological characters and would like to know how many of them are parsimony informative. Is there a way to calculate this with an R package?
1 Answer
The ape
library (Analyses of Phylogenetics and Evolution) using the MPR
method (Most Parsimonious Reconstruction).
Information on ape
is here.
The format
install.packages(“ape”)
library(ape)
MPR(x, phy, outgroup)
x : a vector of integers.
phy : an object of class "phylo"; the tree must be unrooted and fully dichotomous.
outgroup : an integer or a character string giving the tip of phy used as outgroup.
Rooting the tree is recommended. In the example rooting isn't used but an outgroup is used as taxa t1
, that will be fine.
Generating random data,
vectx <- rpois(50, 1) # make random data
tree <- rtree(50, rooted = FALSE) # also rtree(50) make random tree
MPR(vectx, tree, "t1")
Thats it, there's nothing more. Data, tree = steps.
Clarification the question is number of parsimonious characters. As a strict definition the number of informative characters is the same as the number of steps and thats what MPR
will describe ... thats easy.
There are other possible meanings
- The number of parsimonious characters/steps to make a tree is calculated via
MPR
as above. - if its the actual changes at a given position in the alignment (or vector) for each node in the tree - thats the answer below - but thats complicated.
- If its simply is this site (not character) is parsimoniously informative and this one isn't then the "alignment" or vector could be used one character position at a time and subject to
MPR
and the step length would determine how parsimoniously informative each site was ... thus point 3 is easily doable inR
Note Calculating the actual sites on the alignment and associated changes per node is easily done outside R
, but within R
I don't know if thats doable.
Wait, I'm wrong it's doable but I would envisage its difficult to implement. Calculating parsimonious characters for each given node in a tree - yes I do that - doing that in R
... errhhh thats not me. There are Pythonic ways in, but I've not implemented them.