-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
If the translation table keys of the nexus file are not consecutive integers (which is possible for a MEGA timetree analysis output), read.mega / read.beast will return a incorrect @data table:
test.nex
#NEXUS
Begin Taxa;
Dimensions ntax=4;
TaxLabels
A
B
C
D
;
End;
Begin Trees;
Translate
1 A,
2 B,
4 C,
5 D
;
tree TREE1 = [&R] (((1[&rate=NA,branch_length=3.05210780043533E-003]:2.82146551149507E-003,2[&rate=NA,branch_length=3.11763249917918E-003]:2.82146551149507E-003)[&rate=NA,branch_length=3.27365421500745E-002,reltime=2.82146551149507E-003,reltime_stderr=3.48412420431308E-004,reltime_95%_CI={2.22004192087475E-003,3.58581860896548E-003},data_coverage=99%]:2.99429893613024E-002,4[&rate=NA,branch_length=2.83944102398042E-002]:3.27644548727974E-002)[&rate=NA,branch_length=4.76537203824402E-002,reltime=3.27644548727974E-002,reltime_stderr=2.55675381204422E-003,reltime_95%_CI={2.81342298521227E-002,3.81567047953361E-002},data_coverage=99%]:4.89568013527124E-002,5[&rate=NA,branch_length=8.39559068047214E-002]:8.17212562255099E-002)[&rate=NA,branch_length=1.28935725106037E-002,reltime=8.17212562255099E-002,reltime_stderr=4.03743281925163E-003,reltime_95%_CI={7.41901341411784E-002,9.00168707926448E-002},data_coverage=99%];
End;
> read.beast("text.nex")
'treedata' S4 object that stored information of
'text.nex'.
...@ phylo:
Phylogenetic tree with 4 tips and 3 internal nodes.
Tip labels:
A, B, C, D
Rooted; includes branch length(s).
with the following features available:
'branch_length', 'data_coverage', 'rate', 'reltime', 'reltime_0.95_CI', 'reltime_stderr'.
# The associated data tibble abstraction: 8 × 9
# The 'node', 'label' and 'isTip' are from the phylo tree.
node label isTip branch_length data_coverage rate reltime reltime_0.95_CI reltime_stderr
<int> <chr> <lgl> <chr> <chr> <chr> <chr> <list> <chr>
1 1 A TRUE 0.00305210780043533 NA NA NA <chr [1]> NA
2 2 B TRUE 0.00311763249917918 NA NA NA <chr [1]> NA
3 3 C TRUE NA NA NA NA <NULL> NA
4 4 D TRUE 0.0283944102398042 NA NA NA <chr [1]> NA
5 5 NA FALSE 0.0839559068047214 NA NA NA <chr [1]> NA
6 5 NA FALSE 0.0128935725106037 99% NA 0.0817212562255099 <dbl [2]> 0.00403743281925163
7 6 NA FALSE 0.0476537203824402 99% NA 0.0327644548727974 <dbl [2]> 0.00255675381204422
8 7 NA FALSE 0.0327365421500745 99% NA 0.00282146551149507 <dbl [2]> 0.000348412420431308
Note the node 3 (labeled C) has no associated data, which is not the case in the nexus file. Also, node 5 has two different entries.
The expected result will be:
node label isTip branch_length data_coverage rate reltime reltime_0.95_CI reltime_stderr
<int> <chr> <lgl> <chr> <chr> <chr> <chr> <list> <chr>
1 1 A TRUE 0.00305210780043533 NA NA NA <chr [1]> NA
2 2 B TRUE 0.00311763249917918 NA NA NA <chr [1]> NA
3 3 C TRUE 0.0283944102398042 NA NA NA <chr [1]> NA
4 4 D TRUE 0.0839559068047214 NA NA NA <chr [1]> NA
5 5 NA FALSE 0.0128935725106037 99% NA 0.0817212562255099 <dbl [2]> 0.00403743281925163
6 6 NA FALSE 0.0476537203824402 99% NA 0.0327644548727974 <dbl [2]> 0.00255675381204422
7 7 NA FALSE 0.0327365421500745 99% NA 0.00282146551149507 <dbl [2]> 0.000348412420431308
This issue arises after a recent fix of the ape package, which relaxed the restriction of the translation table when reading nexus files. Before that fix, translation table containing non-consecutive keys are not supported. (see ape#133 )
Metadata
Metadata
Assignees
Labels
No labels