Objects produced by FossilSim
contain all the information required by the paleotree
format and vice-versa, thus these two packages are fully compatible.
Converting from paleotree
is done using the paleotree.record.to.fossils
function, which returns a list of the corresponding phylo
, taxonomy
and fossils
objects.
record = paleotree::simFossilRecord(p = 0.1, q = 0.1, r = 0.1, nruns = 1, nTotalTaxa = c(30,40),
nExtant = 0, nSamp = c(5,25))
converted_record = paleotree.record.to.fossils(record = record)
converted_record
## $tree
##
## Phylogenetic tree with 31 tips and 30 internal nodes.
##
## Tip labels:
## t1, t3, t7, t11, t9, t13, ...
## Node labels:
## 32, 33, 34, 35, 36, 37, ...
##
## Rooted; includes branch lengths.
##
## $fossils
## sp edge hmin hmax
## 1 t1 1 984.2885 984.2885
## 2 t1 1 984.9917 984.9917
## 3 t1 1 995.7947 995.7947
## 4 t1 33 997.9842 997.9842
## 5 t3 2 977.9537 977.9537
## 6 t4 28 961.6694 961.6694
## 7 t4 60 974.8741 974.8741
## 8 t4 60 983.0542 983.0542
## 9 t5 27 983.2904 983.2904
## 10 t5 27 983.9442 983.9442
## ...
## Fossil record with 29 occurrences representing 15 species
## Fossils record simulated from or assigned to an existing taxonomy
##
## $taxonomy
## sp edge parent start end mode cryptic cryptic.id
## 1 t1 1 t0 996.0242 984.1087 r FALSE t1
## 2 t1 33 t0 999.0348 996.0242 r FALSE t1
## 3 t1 32 t0 1000.0000 999.0348 r FALSE t1
## 4 t2 31 t1 999.0348 987.1555 b FALSE t2
## 5 t3 2 t1 982.6862 977.5751 b FALSE t3
## 6 t3 37 t1 984.3494 982.6862 b FALSE t3
## 7 t3 36 t1 985.9100 984.3494 b FALSE t3
## 8 t3 35 t1 986.3314 985.9100 b FALSE t3
## 9 t3 34 t1 996.0242 986.3314 b FALSE t3
## 10 t4 28 t3 968.2221 953.9786 b FALSE t4
## 11 t4 61 t3 972.2772 968.2221 b FALSE t4
## 12 t4 60 t3 986.3314 972.2772 b FALSE t4
## 13 t5 27 t3 985.9100 972.7037 b FALSE t5
## 14 t6 26 t3 984.3494 980.0552 b FALSE t6
## 15 t7 3 t3 973.4339 963.9684 b FALSE t7
## 16 t7 40 t3 978.9826 973.4339 b FALSE t7
## 17 t7 39 t3 981.0656 978.9826 b FALSE t7
## 18 t7 38 t3 982.6862 981.0656 b FALSE t7
## 19 t8 17 t7 953.5104 952.1067 b FALSE t8
## 20 t8 53 t7 974.7463 953.5104 b FALSE t8
## 21 t8 52 t7 981.0656 974.7463 b FALSE t8
## 22 t9 5 t7 971.4490 971.0861 b FALSE t9
## 23 t9 41 t7 978.9826 971.4490 b FALSE t9
## 24 t10 19 t8 966.1319 964.9105 b FALSE t10
## 25 t10 56 t8 968.8033 966.1319 b FALSE t10
## 26 t10 55 t8 970.6759 968.8033 b FALSE t10
## 27 t10 54 t8 974.7463 970.6759 b FALSE t10
## 28 t11 4 t7 973.4339 966.9530 b FALSE t11
## 29 t12 30 t4 972.2772 969.0177 b FALSE t12
## 30 t13 6 t9 970.6163 966.6611 b FALSE t13
## 31 t13 42 t9 971.4490 970.6163 b FALSE t13
## 32 t14 25 t10 970.6759 970.0985 b FALSE t14
## 33 t15 7 t13 966.0056 963.3092 b FALSE t15
## 34 t15 46 t13 966.0234 966.0056 b FALSE t15
## 35 t15 45 t13 969.4651 966.0234 b FALSE t15
## 36 t15 44 t13 969.9011 969.4651 b FALSE t15
## 37 t15 43 t13 970.6163 969.9011 b FALSE t15
## 38 t16 16 t15 969.9011 961.6804 b FALSE t16
## 39 t17 15 t15 969.4651 962.7418 b FALSE t17
## 40 t18 21 t10 963.6001 959.3928 b FALSE t18
## 41 t18 57 t10 968.8033 963.6001 b FALSE t18
## 42 t19 29 t4 968.2221 967.2668 b FALSE t19
## 43 t20 20 t10 966.1319 953.5160 b FALSE t20
## 44 t21 9 t15 962.9985 954.9255 b FALSE t21
## 45 t21 47 t15 966.0234 962.9985 b FALSE t21
## 46 t22 8 t15 966.0056 959.0296 b FALSE t22
## 47 t23 22 t18 960.7569 954.4628 b FALSE t23
## 48 t23 58 t18 963.6001 960.7569 b FALSE t23
## 49 t24 10 t21 959.3697 955.9505 b FALSE t24
## 50 t24 49 t21 961.0975 959.3697 b FALSE t24
## ...
## Taxonomy representing 31 species across 61 edges.
If the paleotree
record is fully extinct, i.e contains no extant samples, the age of the record will be encoded in the field origin.time
of the tree.
converted_record$tree$origin.time
## [1] 1000
Similarly, converting from the FossilSim
objects to paleotree
format is done using the fossils.to.paleotree.record
function, which requires a fossils
object and either a phylo
or taxonomy
object. If no taxonomy is provided, all speciation events in the tree will be assumed to be symmetric (bifurcating).
t = ape::rtree(6)
f = sim.fossils.poisson(rate = 2, tree = t)
converted_record = fossils.to.paleotree.record(fossils = f, tree = t)
converted_record
## $t8
## $t8$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 1.000000 NA 2.383516 1.500349 0.000000 1.000000
##
## $t8$sampling.times
## [1] 2.085077 2.063856 1.785298
##
##
## $t4
## $t4$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 2.0000000 1.0000000 1.5003491 0.5702621 0.0000000 2.0000000
##
## $t4$sampling.times
## [1] 0.9750461 0.8258748
##
##
## $t9
## $t9$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 3.0000000 1.0000000 1.5003491 0.9801043 0.0000000 3.0000000
##
## $t9$sampling.times
## [1] 1.1584846 0.9956939 1.3111476
##
##
## $t1
## $t1$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 4.0000000 3.0000000 0.9801043 0.2131562 0.0000000 4.0000000
##
## $t1$sampling.times
## [1] 0.3602269 0.4704336
##
##
## $t10
## $t10$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 5.0000000 3.0000000 0.9801043 0.5062916 0.0000000 5.0000000
##
## $t10$sampling.times
## [1] 0.8534006
##
##
## $t3
## $t3$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 6.0000000 5.0000000 0.5062916 0.1720527 0.0000000 6.0000000
##
## $t3$sampling.times
## [1] 0.4453817
##
##
## $t2
## $t2$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 7.0000000 5.0000000 0.5062916 0.0000000 1.0000000 7.0000000
##
## $t2$sampling.times
## [1] 0
##
##
## $t11
## $t11$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 8.000000 NA 2.383516 2.040861 0.000000 8.000000
##
## $t11$sampling.times
## [1] 2.339343
##
##
## $t6
## $t6$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 9.000000 8.000000 2.040861 1.357577 0.000000 9.000000
##
## $t6$sampling.times
## [1] 1.613225
##
##
## $t5
## $t5$taxa.data
## taxon.id ancestor.id orig.time ext.time still.alive looks.like
## 10.000000 8.000000 2.040861 2.028629 0.000000 10.000000
##
## $t5$sampling.times
## numeric(0)
##
##
## attr(,"class")
## [1] "fossilRecordSimulation"