Tuesday, February 22, 2011

New "beta" read.simmap() function available

I have added the capacity to read "nexus" style SIMMAPv1.0 tree files to my new read.simmap() function. To remind the reader, this function (v0.2 on my beta version page) is an improvement over earlier versions in that it allows the user to retain the order and the times spent in each mapped state along each edge of the tree. My earlier read.simmap() function (v0.1) destroyed the ordering of the states on each edge, storing only the total branch length in each state for each edge. The present version can read both "nexus" and "phylip" style tree files; as well as multiple trees (in which case, the function will create a modified "multiPhylo" object in memory).

For example, to load and use the present version:

> source("read.simmap.R")
> tree<-"((A:{aqua,0.3:terr,0.4:aqua,0.3},B:{aqua,1.0}):{aqua,1.0},(C:{aqua,0.25:terr,0.75},D:{aqua,1.0}):{aqua,1.0});"
> mapped.tree<-read.simmap(text=tree,format="phylip")


The modified "phylo" object that is created by read.simmap() in this case has the following structure:

> mapped.tree
$edge
[,1] [,2]
[1,] 5 6
[2,] 6 1
[3,] 6 2
[4,] 5 7
[5,] 7 3
[6,] 7 4
$Nnode
[1] 3
$tip.label
[1] "A" "B" "C" "D"
$edge.length
[1] 1 1 1 1 1 1
$maps
$maps[[1]]
aqua
1
$maps[[2]]
aqua terr aqua
0.3 0.4 0.3
$maps[[3]]
aqua
1
$maps[[4]]
aqua
1
$maps[[5]]
aqua terr
0.25 0.75
$maps[[6]]
aqua
1
$mapped.edge
state
edge aqua terr
5,6 1.00 0.00
6,1 0.60 0.40
6,2 1.00 0.00
5,7 1.00 0.00
7,3 0.25 0.75
7,4 1.00 0.00
attr(,"class")
[1] "phylo"

No comments:

Post a Comment