Closed ajrominger closed 1 year ago
This seems to be just how your machine decides to display digits. I think the branch lengths are actually properly input but displayed depending on your options. You can change it using options(digits)
. For example:
options(digits = 20)
y$edge.length[y$edge[, 2] == which(y$tip.label == 't6')]
## [1] 2.451123823006753355
Thanks for the appreciation (always appreciated ;) )
read.tree
does not truncate digits: they are all read in the limits defined by R.
First, R prints a number of digits according to this option:
R> options("digits")
$digits
[1] 7
This can be overriden by for instance print(, digits = )
. Try print(y$edge.length, digits = 22)
.
Then, real numbers in R are 64-bit floating-point numbers, so you cannot get that many digits stored in a number (16 digits is the typical number):
R> identical(2.45112382300675335500272922218, 2.4511238230067533)
[1] TRUE
R> identical(2.45112382300675335500272922218, 2.451123823006753)
[1] FALSE
The digits after '33' are truncated because they cannot be stored in a 64-bit reals. Maybe msprime uses 128-bit reals (known as long double in C/C++)?
Thanks so much for the prompt reply and info! This all makes a lot of sense. We're digging deeper into the msprime side of things, but now the R side is fully transparent to us, which is a huge help!
Thanks again!
Thanks so much for ape! I don't know where I'd be without it!
Recently I've been working
ape::phylo
objects and msprime. I am running into an issue with branch lengths seeming to be rounded to 6 decimal places byape::read.tree
. When greater than 6 decimal places are needed, is there any work-around to the default behavior ofape::read.tree
?Here's an example:
Thanks for any thoughts on this and thanks again for ape!