First, the bug fix. Yesterday, I realized that the traditional semi-colon had been cropped from the end of the Newick string in XML format. This makes sense, to some extent, because the end of the string is indicated by a </tree> tag anyway. Pulling the semicolon off the end of the tree string created by ape::write.tree is not quite as simple as it sounds. That is because in R a character string is stored as a single object, rather than a vector of individual characters. To do it, I used strsplit to split up the string, and then paste to put it back together (although in hindsight, I might have used toString instead). This was done basically as follows:
temp<-write.tree(tree) # write Newick to temp
temp<-unlist(strsplit(temp,NULL)) # split into character vector
# paste together, dropping the last character (a ";")
# write to file with tags
I also added a new function, rescaleSimmap (code here), which rescales a SIMMAP style "phylo" object in R. This function is analagous to rescaleTree in the 'geiger' package. This function takes the input tree and a new total depth (height) for the tree, and then rescales the branch lengths and the mapping elements ($maps and $mapped.edge) proportionally. I programmed this today because I discovered that (at least by default), for a given input tree and character value, SIMMAP samples not only mutational histories, but also total tree depth. Not sure why this is - I may investigate.
Post a Comment
Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.