xavierdidelot / BactDating

Bayesian inference of ancestral dates on bacterial phylogenetic trees
https://xavierdidelot.github.io/BactDating
MIT License
80 stars 15 forks source link

Extract isolation dates from tip labels #54

Closed amymariecampbell closed 2 years ago

amymariecampbell commented 2 years ago

Hi there,

My isolation dates are contained within my sample names- is there a way to extract these instead of having to create a list in the right order?

My tip labels are in the format XXXXX_yyyy-m-dd_XXXX.

Thanks!

xavierdidelot commented 2 years ago

Yes it's definitely possible to extract the dates from your labels. First you need to extract the year, month and day using something like regexpr. Then you need to convert this into a decimal year either using a formula like decimalyear=year+(month-1)/12+(day-1)/365 or using decimal_date from the lubridate package.