tgvaughan / remaster

High-fidelity stochastic tree simulation for BEAST 2.
https://tgvaughan.github.io/remaster
GNU General Public License v3.0
7 stars 1 forks source link

Sampling times of leaves in output tree #4

Closed ekankaka closed 1 year ago

ekankaka commented 1 year ago

Hi @tgvaughan , Is there a way to extract the time when each leaf (tip) in the output tree was actually sampled during the simulation e.g. from a punctualReaction below: <reaction spec="PunctualReaction" n="10" times="2 4 6 8 10"> I -> sample </reaction> I would like to assign each leaf in the tree the time when it was actually sampled in the simulation. Thanks.

tgvaughan commented 1 year ago

Hi @ekankaka, in the latest release, nodes are annotated with a "time" attribute which contains the simulation time at which the corresponding event occurred. You may have to use TypedTreeLogger to have them included in the output file, but I believe this solves your problem. (Let me know if otherwise!)

ekankaka commented 1 year ago

Solved, thanks!

JensUweUlrich commented 1 month ago

Hi @tgvaughan,

I also have a question related to the sampling times. If, for instance time = 0.013, does this mean. that the sample was take 0.013 years before the most recent sample was taken?

Thanks Jens

tgvaughan commented 1 month ago

Hi Jens,

For birth-death simulations, time in remaster is measured exclusively relative to the start of the birth-death process.

For coalescent simulations, the "start of the process" is the present, with time increasing into the past.

Hope this helps, Tim

JensUweUlrich commented 2 weeks ago

Hi Tim,

thanks for your detailed answer. Is there an option to append the sampling times to the leaf names in the alignment output file (e.g. leaf_23_0.176)?

Thanks Jens

tgvaughan commented 2 weeks ago

Hi Jens, no; the sample times are included as an attribute on each of the nodes. The format is quite simple though. For instance, here are the annotations used to indicate the age of both leaves and the root of a 2-leaf tree produced by a BD process which included sampling at a point 5 time units following its start:

(A[&time="5"]:0.5,B[&time="5"]:0.5)[&time="4.5"]

This format is parsed by many external tools, including icytree, figtree, and R using treeio::read.beast.