Summary

This report analyses genomic data generated by other researchers and originally described in the Virological.org post. There is no intention to publish these analyses. Instead, this report provides complementary analyses to help understand the ongoing Bundibugyo ebolavirus (BDBV) outbreak.

Data download and curation

The sequence alignment and associated metadata were downloaded from Pathoplexus on 9 July 2026. The original post describes 139 sequences sampled between 2 May 2026 and 23 June 2026; however, 149 sequences were available on Pathoplexus at the time of download.

Before analysis, we performed several curation steps, largely following the recommendations in the original post:

  1. Removed sequence PP_00764QW because of evidence of ADAR editing.
  2. Trimmed the alignment to 18,900 nt to remove sequencing artefacts at the 3’ end (introduced by sequence PP_006XHL9.3, which was retained).
  3. Masked the first 65 nt and last 432 nt, as these positions were covered in only a small number of sequences.

To make the analyses as comparable as possible with the original report, we downloaded the corresponding Pathoplexus SeqSet and matched sequence identifiers. This yielded 127 matching sequences, indicating that the datasets are unfortunately not identical. In addition, sequence PP_00711T3 failed the IQ-TREE composition test and was removed prior to downstream analyses.

Alignment and tree reconstruction

Following curation, the Pathoplexus alignment was aligned to the NC_014373 2007 BDBV reference genome using MAFFT with the --keeplength and --add options. A maximum-likelihood (ML) phylogeny was then reconstructed using IQ-TREE 2 with ModelFinder, which selected the K3Pu+F substitution model (-m MFP -B 1000 --bnni -alrt 1000).

Quality-control checks using Raccoon (aln-qc and tree-qc) did not identify any issues requiring further action.

All subsequent analyses were based on this ML tree and included:

  • data loading and tree rooting;
  • molecular clock dating using multiple models in treedater and BactDating;
  • identification and removal of temporal outliers using treedater and DiagnoDating;
  • molecular clock model comparison and selection;
  • root-to-tip regression;
  • estimation of uncertainty in evolutionary rates and node dates;
  • estimation of effective population size through time; and
  • reconstruction of geographic transitions using maximum parsimony.

1. Load libraries

library(here)
library(ape)
library(phytools)
library(glue)
library(dplyr)
library(treedater) # devtools::install_github(...)
library(lubridate)
library(ggtree) # from Bioconductor
library(ggplot2)
library(DiagnoDating, quietly = TRUE)
library(pomp)

2. Load tree & metadata

2.1 Tree & alignment settings

set.seed(9876)

TR_DIR <- "results/2026_07_09_5pm"
tr <- read.tree(glue("{TR_DIR}/bdbv.treefile"))
tr
## 
## Phylogenetic tree with 127 tips and 125 internal nodes.
## 
## Tip labels:
##   NC_014373, PP_006XHKB.2, PP_00764EH.1, PP_00765UM.1, PP_0076617.1, PP_00765M1.1, ...
## Node labels:
##   , 0/72, 75/73, 0/21, 0/4, 0/7, ...
## 
## Unrooted; includes branch length(s).
# Alignment length after masking:
aln_len <- 18900 - 65 - 432

2.2 Metadata

DATA_DIR <- "data/2026_07_09_5pm/"
F_NAME <- "ebola-bdbv_metadata_2026-07-09T1550.tsv"

md <- read.csv(glue("{DATA_DIR}/{F_NAME}"), sep = "\t")

#colnames(md)
table(md$geoLocAdmin2)
## 
##                       ARU         Arua        BAMBU        Bunia        BUNIA  Bunya Congo 
##            1            1            3            2           14           36            2 
##          DRC         Gety        Hoima      Kampala        Katwa         KILO      Komanda 
##            2            2            1            5            1            2            1 
##         LITA      MAMBASA      MANGALA    Mongbwalu    MONGBWALU     MONGWALU     MUNGWALU 
##            4            1            1            2            1            2            4 
##         NIZI Not provided      Ntoroko     NYAKUNDE    Nyankunde    NYANKUNDE        RIMBA 
##            9            2            1            2            2            1            1 
##     Rwampara     RWAMPARA         SOTA      unknown       Wakiso 
##           11           27            1            1            3

2.3 Match metadata to tree tips

length(intersect(tr$tip.label, md$accessionVersion))
## [1] 126
md_match <- md %>%
  filter(accessionVersion %in% tr$tip.label) %>%
  dplyr::slice(match(tr$tip.label, accessionVersion))

md_match$sampleCollectionDate <- as.Date(md_match$sampleCollectionDate)
md_match$num_date <- decimal_date(md_match$sampleCollectionDate)

# Named vector of sample times
sts <- md_match$num_date
names(sts) <- md_match$accessionVersion

3. Root tree & drop outgroup

.rootanddrop <- function(tr0) {
  tr_rooted <- root(tr0, outgroup = "NC_014373", resolve.root = TRUE)
  drop.tip(tr_rooted, tip = "NC_014373")
}

tr <- .rootanddrop(tr)

3.1 Root & subsample bootstrap trees

nboot <- 200
btres <- read.tree(glue("{TR_DIR}/bdbv.ufboot"))
btres <- btres[sample.int(length(btres), size = nboot, replace = FALSE)]
btres <- lapply(btres, .rootanddrop)

4. Initial clock dating (strict)

td0 <- dater(
  tr, sts, s = aln_len,
  clock = "strict",
  meanRateLimits = c(0.0005, 0.002),
  numStartConditions = 20, quiet = FALSE,
  ncpu = 4
)
## Note: Initial guess of substitution rate not provided. Will attempt to guess starting conditions. Provide initial guesses of the rate using *omega0* parameter. 
## Note: Minimum temporal branch length  (*minblen*) set to 0.000113068058273516. Increase *minblen* in the event of convergence failures. 
## Tree is rooted. Not estimating root position.
## Initial guesses of substitution rate: 8.78437382887111e-06,2.10974324671581e-05,3.48291496089972e-05,5.95540891219653e-05,6.35892509370373e-05,8.32221642627345e-05,0.000100560829622948,0.000106040694262712,0.000128178033814052,0.000133670741449473,0.000149774752289877,0.000163939494996624,0.000170951430309609,0.000191814317753028,0.00019204430936788,0.000212459617011739,0.000218460878004584,0.000232976884136016,0.000243214384353623,0.000243538769524812,0.000253451884571231,0.000267544709784504,0.000273969151695508,0.000290688977526408,0.000294614450954219,0.000313142330729711,0.000315477338397638,0.00033504734541521,0.00033665401641737,0.000356526323507719,0.000358250734893195,0.000377687031619072,0.000380388074444535,0.000398627045443617,0.000403206604444512,0.000419437199456908,0.000426874679585282,0.000429820841437541,0.000440204483418174,0.00045159961909825,0.000461014637431465,0.000477644394878376,0.000481954651256011,0.000503115359367364,0.000505353655634688,0.000524594337459873,0.000535196399789737,0.000546499352145372,0.00056784031510974,0.000568952705348674,0.000592096973090578,0.000604291547302476,0.00061610291335027,0.000641180804870498,0.000646185326156106,0.000667597373507202,0.000695702187878458,0.000696481952247756,0.000725970941425609,0.000759080853252135,0.000761537642182704,0.000796052431938045,0.000838544250407924,0.000860276515502149,0.000889558867948174,0.000955543237054781,0.00105569162175096,0.00122945913758186,0.0014301443779574
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005538747           0 2026.183 -250.3063
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1             0.00061125           0 2026.203 -249.9776
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007188471           0 2026.222 -250.2246
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 0         0           0.0005945648           0 2026.184 -250.266
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006781569           0 2026.217 -249.9833
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 2         2           0.0007753669           0 2026.24 -251.465
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005945648           0 2026.192 -250.0323
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006781569           0 2026.217 -249.9833
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 2         2           0.0007753669           0 2026.24 -251.465
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005897992           0 2026.196 -250.0536
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006781569           0 2026.215 -249.9699
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 2         2           0.0007753669           0 2026.24 -251.465
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006352549           0 2026.201 -249.9637
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007188471           0 2026.229 -250.4141
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006323524           0 2026.208 -249.9291
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007188471           0 2026.228 -250.3708
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006339887           0 2026.209 -249.9276
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007188471           0 2026.228 -250.3945
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006781569           0 2026.216 -249.9745
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 1         1           0.0007753669           0 2026.24 -251.465
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0007188471           0 2026.22 -250.2419
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008134118           0 2026.249 -251.9879
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007188471           0 2026.223 -250.2319
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008134118           0 2026.249 -251.9879
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0007188471           0 2026.23 -250.5201
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008134118           0 2026.249 -251.9879
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007343893           0 2026.232 -250.6092
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008134118           0 2026.252 -252.4934
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007659935           0 2026.237 -251.1446
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.000854102           0 2026.258 -255.3773
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007917293           0 2026.244 -252.0332
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008947921           0 2026.263 -267.8198
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007924749           0 2026.244 -252.0618
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008947921           0 2026.263 -267.7991
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0008134118           0 2026.25 -252.1248
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008947921           0 2026.266 -267.2933
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.000854102           0 2026.257 -254.3846
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.000947133           0 2026.272 -266.4799
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 0         0            0.000854102           0 2026.257 -254.701
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.000947133           0 2026.272 -266.4799
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0008947921           0 2026.263 -267.7014
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0009984486           0 2026.278 -265.5533
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 2         2            0.001072949           0 2026.29 -262.4176
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 3         3            0.001132032           0 2026.297 -262.493
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 0         0           0.0009261882           0 2026.27 -266.764
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001032259           0 2026.282 -262.6961
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001138228           0 2026.293 -262.4368
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.001222884           0 2026.302 -262.8114
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0009552358           0 2026.273 -266.3751
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001032259           0 2026.285 -262.5424
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001138228           0 2026.293 -262.4368
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.001222884           0 2026.302 -262.8114
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0009921389           0 2026.277 -265.8954
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 1         1            0.001072949           0 2026.289 -262.422
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 2         2            0.001132032           0 2026.297 -262.493
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.001032259           0 2026.285 -262.5416
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001138228           0 2026.293 -262.4368
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001222884           0 2026.302 -262.8114
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.001117727           0 2026.295 -262.4479
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001207773           0 2026.301 -262.6852
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 0         0            0.001300926           0 2026.309 -263.761
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001321338           0 2026.313 -265.1138
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0            0.001427051           0 2026.32 -268.9745
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1            0.001427051           0 2026.32 -268.9066
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 2         2            0.001427051           0 2026.32 -268.9066
## ---

5. Outlier Removal

.otips <- function(td) {
  ot <- outlierTips(td)
  ot[ot$q < 0.05, "taxon"]
}

ot <- .otips(td0)
## [1] taxon         q             p             loglik        rates         branch.length
## <0 rows> (or 0-length row.names)
td1 <- td0
tr1 <- tr

while (length(ot) > 0) {
  tr1 <- drop.tip(tr1, ot)
  td1 <- dater(
    tr1, sts, s = aln_len,
    clock = "strict",
    meanRateLimits = c(0.0005, 0.002),
    numStartConditions = 20, quiet = TRUE, #FALSE
    ncpu = 4
  )
  ot <- .otips(td1)
}

# Tips removed as outliers (empty = none removed)
print(setdiff(td0$tip.label, td1$tip.label))
## character(0)

6. Clock model selection

6.1 Relaxed clock test

rct <- relaxedClockTest(
  tr1, sts, aln_len,
  meanRateLimits = c(0.0005, 0.002),
  quiet = FALSE, ncpu = 8, nreps=5000,
  overrideTempConstraint = FALSE
) 
Best clock model:  strict 
Null distribution of rate coefficient of variation: 0.000571629763668337 0.000823308918992667 
Returning best treedater fit

6.2 Fit uncorrelated & additive relaxed clocks

# Uncorrelated
td1u <- dater(
  tr1, sts, s = aln_len,
  clock = "uncorrelated",
  meanRateLimits = c(0.0005, 0.002),
  numStartConditions = 20, quiet = FALSE,
  ncpu = 4
)
## Note: Initial guess of substitution rate not provided. Will attempt to guess starting conditions. Provide initial guesses of the rate using *omega0* parameter. 
## Note: Minimum temporal branch length  (*minblen*) set to 0.000113068058273516. Increase *minblen* in the event of convergence failures. 
## Tree is rooted. Not estimating root position.
## Initial guesses of substitution rate: 8.78437382887111e-06,2.10974324671581e-05,3.48291496089972e-05,5.95540891219653e-05,6.35892509370373e-05,8.32221642627345e-05,0.000100560829622948,0.000106040694262712,0.000128178033814052,0.000133670741449473,0.000149774752289877,0.000163939494996624,0.000170951430309609,0.000191814317753028,0.00019204430936788,0.000212459617011739,0.000218460878004584,0.000232976884136016,0.000243214384353623,0.000243538769524812,0.000253451884571231,0.000267544709784504,0.000273969151695508,0.000290688977526408,0.000294614450954219,0.000313142330729711,0.000315477338397638,0.00033504734541521,0.00033665401641737,0.000356526323507719,0.000358250734893195,0.000377687031619072,0.000380388074444535,0.000398627045443617,0.000403206604444512,0.000419437199456908,0.000426874679585282,0.000429820841437541,0.000440204483418174,0.00045159961909825,0.000461014637431465,0.000477644394878376,0.000481954651256011,0.000503115359367364,0.000505353655634688,0.000524594337459873,0.000535196399789737,0.000546499352145372,0.00056784031510974,0.000568952705348674,0.000592096973090578,0.000604291547302476,0.00061610291335027,0.000641180804870498,0.000646185326156106,0.000667597373507202,0.000695702187878458,0.000696481952247756,0.000725970941425609,0.000759080853252135,0.000761537642182704,0.000796052431938045,0.000838544250407924,0.000860276515502149,0.000889558867948174,0.000955543237054781,0.00105569162175096,0.00122945913758186,0.0014301443779574
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005731879 0.000764234 2026.183 -250.2167
## ---
##   iteration median_unadjusted_rate  coef_of_var   tmrca    logLik
## 1         1             0.00064961 0.0007643622 2026.21 -249.7674
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2           0.0007328031 0.0007655647 2026.232 -250.4957
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0005756279 0.0007642188 2026.184 -250.1946
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0006522707 0.0007643826 2026.211 -249.7709
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 2         2           0.0007354868 0.0007656001 2026.233 -250.549
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0005969614 0.0007642467 2026.192 -250.0403
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.000675452 0.0007646026 2026.217 -249.8502
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2           0.0007607806 0.0007662177 2026.239 -251.1522
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006086334 0.0007641923 2026.196 -249.9797
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006882238 0.000764775 2026.221 -249.9342
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2           0.0007744424 0.0007665453 2026.242 -251.5276
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006210301 0.0007642169 2026.201 -249.9346
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0007016724 0.0007649729 2026.224 -250.0576
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006441685 0.0007645137 2026.208 -249.9072
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0007267853 0.0007654274 2026.231 -250.3939
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006456698 0.0007643475 2026.209 -249.9079
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 1         1           0.0007286093 0.0007654863 2026.231 -250.421
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006709528 0.0007645765 2026.216 -249.9765
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0007559276 0.0007660971 2026.238 -251.0183
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0006840748 0.000764715 2026.22 -250.0577
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0007701224 0.0007664548 2026.241 -251.4064
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0006972778 0.0007650131 2026.223 -250.1688
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0007841526 0.0007667919 2026.244 -251.8307
## ---
##   iteration median_unadjusted_rate  coef_of_var   tmrca    logLik
## 0         0           0.0007243777 0.0007654017 2026.23 -250.5237
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1           0.0008128394 0.000767637 2026.25 -251.6877
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0007299148 0.0007655252 2026.232 -250.6165
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008189686 0.000767865 2026.251 -251.8669
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0            0.000752868 0.0007661004 2026.237 -251.1327
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0008431515 0.0007687494 2026.255 -253.2142
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0007835183 0.0007668922 2026.244 -252.0349
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 1         1            0.000875018 0.0007700215 2026.261 -258.997
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0007842351 0.0007668815 2026.244 -252.0636
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0008756575 0.0007700404 2026.261 -259.3241
## ---
##   iteration median_unadjusted_rate  coef_of_var   tmrca    logLik
## 0         0           0.0008157851 0.0007677879 2026.25 -252.1329
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0009075343 0.0007713951 2026.266 -267.1426
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0           0.0008506461 0.0007690633 2026.257 -254.3927
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0009420115 0.0007730499 2026.272 -266.4645
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca  logLik
## 0         0           0.0008529272 0.0007692949 2026.257 -254.71
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 1         1           0.0009441418 0.0007731525 2026.272 -266.425
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0008888063 0.000770618 2026.263 -267.7073
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1           0.0009791894 0.0007750951 2026.277 -265.8377
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2            0.001063412 0.0007808841 2026.288 -262.3817
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 3         3            0.001139818 0.0007873094 2026.296 -262.3823
## ---
##   iteration median_unadjusted_rate  coef_of_var   tmrca    logLik
## 0         0           0.0009311267 0.0007725655 2026.27 -266.7694
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001018917 0.0007776935 2026.282 -262.5778
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2            0.001099531 0.0007837635 2026.292 -262.3301
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 3         3             0.00117182 0.0007903553 2026.299 -262.5061
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0009522163 0.000774952 2026.273 -266.3828
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001038501 0.0007790532 2026.285 -262.4744
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2            0.001117526 0.0007853125 2026.293 -262.3392
## ---
##   iteration median_unadjusted_rate  coef_of_var  tmrca    logLik
## 3         3            0.001187861 0.0007919645 2026.3 -262.5997
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 0         0           0.0009806246 0.0007754399 2026.277 -265.894
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001064807 0.0007809938 2026.288 -262.3782
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2            0.001140936 0.0007874086 2026.296 -262.3858
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca   logLik
## 0         0            0.001042603 0.0007793579 2026.285 -262.539
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001121152 0.0007856284 2026.294 -262.3439
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 2         2            0.001190781 0.0007922571 2026.301 -262.6209
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0            0.001133934 0.0007872315 2026.295 -262.4347
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001202316 0.0007934568 2026.302 -262.7016
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 0         0            0.001283731 0.0008026324 2026.309 -263.7513
## ---
##   iteration median_unadjusted_rate  coef_of_var    tmrca    logLik
## 1         1            0.001325979 0.0008079653 2026.312 -264.6144
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 0         0            0.001411919  0.02170761 2026.32 -268.942
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001388365 0.006547859 2026.317 -264.7113
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001390134 0.007328805 2026.317 -266.2935
## ---
# Additive
td1a <- dater(
  tr1, sts, s  = aln_len,
  clock = "additive",
  meanRateLimits = c(0.0005, 0.002),
  numStartConditions = 20, quiet = FALSE,
  ncpu = 4
)
## Note: Initial guess of substitution rate not provided. Will attempt to guess starting conditions. Provide initial guesses of the rate using *omega0* parameter. 
## Note: Minimum temporal branch length  (*minblen*) set to 0.000113068058273516. Increase *minblen* in the event of convergence failures. 
## Tree is rooted. Not estimating root position.
## Initial guesses of substitution rate: 8.78437382887111e-06,2.10974324671581e-05,3.48291496089972e-05,5.95540891219653e-05,6.35892509370373e-05,8.32221642627345e-05,0.000100560829622948,0.000106040694262712,0.000128178033814052,0.000133670741449473,0.000149774752289877,0.000163939494996624,0.000170951430309609,0.000191814317753028,0.00019204430936788,0.000212459617011739,0.000218460878004584,0.000232976884136016,0.000243214384353623,0.000243538769524812,0.000253451884571231,0.000267544709784504,0.000273969151695508,0.000290688977526408,0.000294614450954219,0.000313142330729711,0.000315477338397638,0.00033504734541521,0.00033665401641737,0.000356526323507719,0.000358250734893195,0.000377687031619072,0.000380388074444535,0.000398627045443617,0.000403206604444512,0.000419437199456908,0.000426874679585282,0.000429820841437541,0.000440204483418174,0.00045159961909825,0.000461014637431465,0.000477644394878376,0.000481954651256011,0.000503115359367364,0.000505353655634688,0.000524594337459873,0.000535196399789737,0.000546499352145372,0.00056784031510974,0.000568952705348674,0.000592096973090578,0.000604291547302476,0.00061610291335027,0.000641180804870498,0.000646185326156106,0.000667597373507202,0.000695702187878458,0.000696481952247756,0.000725970941425609,0.000759080853252135,0.000761537642182704,0.000796052431938045,0.000838544250407924,0.000860276515502149,0.000889558867948174,0.000955543237054781,0.00105569162175096,0.00122945913758186,0.0014301443779574
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005583953    1.570066 2026.183 -246.9103
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0005767855    1.581553 2026.191 -227.3095
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006279856     1.56981 2026.197 -215.9803
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3             0.00069378    1.505978 2026.219 -233.3396
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005606796    1.567861 2026.184 -246.8881
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0005789026    1.580841 2026.192 -227.3309
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006304578    1.569246 2026.198 -216.0123
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 3         3           0.0006962335    1.505457 2026.22 -233.3454
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0005820487    1.559554 2026.192 -246.7278
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0005983807    1.575048 2026.199 -227.5241
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006512584    1.563082 2026.205 -216.3318
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 3         3           0.0007184638    1.508072 2026.226 -231.454
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.000593577    1.558075 2026.196 -246.6597
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 1         1           0.0006089372    1.572175 2026.203 -227.643
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006627035    1.558795 2026.208 -216.5043
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0007295882    1.503794 2026.229 -230.8309
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.000606044    1.556149 2026.201 -246.6029
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006201045    1.568686 2026.207 -227.7813
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006739912    1.553534 2026.212 -216.6193
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.000740591    1.501256 2026.232 -230.7582
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006310145    1.550719 2026.208 -246.5417
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006412396    1.561148 2026.214 -228.0796
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0006959696    1.543334 2026.218 -216.9546
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0007617754    1.494947 2026.239 -230.9677
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006321665    1.550348 2026.209 -246.5403
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006421635    1.560713 2026.214 -228.0984
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.000697167     1.54293 2026.219 -216.9757
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0007627956    1.494897 2026.239 -230.9826
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006562348     1.54099 2026.216 -246.5499
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1           0.0006629785    1.550318 2026.22 -228.4602
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007193705    1.534067 2026.225 -217.4908
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.000786337    1.497435 2026.245 -230.1934
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca   logLik
## 0         0           0.0006697826    1.538399 2026.22 -246.589
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006735493    1.542834 2026.223 -228.6385
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007305439     1.53133 2026.228 -217.8029
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008000602    1.491453 2026.248 -228.8147
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0006825208    1.535028 2026.223 -246.6504
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0006839531    1.533809 2026.226 -228.8226
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007411675    1.527879 2026.231 -218.1051
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 3         3           0.0008102931    1.492854 2026.25 -227.8614
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0007084907    1.521162 2026.23 -246.8636
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007034723    1.512255 2026.232 -229.2767
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007610055    1.515848 2026.236 -218.8603
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3             0.00082724    1.482699 2026.254 -226.3881
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 0         0            0.000713642    1.515578 2026.232 -246.921
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007074596    1.507681 2026.233 -229.3668
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007647351    1.512355 2026.237 -219.0362
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008293433    1.481172 2026.255 -226.0569
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007353497    1.508125 2026.237 -247.2495
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 1         1           0.0007238433     1.50001 2026.237 -230.019
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007829905    1.496333 2026.242 -220.3366
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008368724    1.484502 2026.256 -221.7861
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007638349    1.487772 2026.244 -247.7818
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007436382     1.48558 2026.242 -230.7685
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008030708    1.488478 2026.247 -221.8122
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008452839    1.468155 2026.257 -221.7965
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 4         4           0.0008594788    1.423715 2026.259 -225.2646
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0007645613    1.487434 2026.244 -247.7976
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007439894    1.484993 2026.242 -230.7793
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008035841    1.488298 2026.247 -221.8331
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008458576    1.467824 2026.257 -221.8035
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 4         4           0.0008599199    1.422988 2026.259 -225.351
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0007945721     1.48625 2026.25 -247.1975
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.000763483    1.476384 2026.246 -229.5637
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008205876    1.471985 2026.251 -221.2462
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 3         3           0.0008641046    1.441349 2026.26 -224.3587
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0008275834    1.482294 2026.257 -247.8567
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1           0.0007826791    1.464636 2026.25 -229.8691
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008311912    1.457036 2026.252 -220.3647
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0009004177    1.414999 2026.266 -234.8521
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0008298833    1.483791 2026.257 -247.9738
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1           0.0007837513    1.464051 2026.25 -230.0067
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008289549    1.456181 2026.252 -220.2072
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008984789     1.41435 2026.266 -234.8509
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0           0.0008624159    1.482651 2026.263 -253.1798
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0007942326    1.451934 2026.254 -236.9301
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007690721    1.432882 2026.242 -222.9232
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008422814    1.398691 2026.256 -232.0906
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0           0.0009030917    1.479411 2026.27 -252.4192
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 1         1           0.0008281007    1.449699 2026.26 -236.8071
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0007987498    1.423911 2026.248 -223.0723
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 3         3           0.0008731675    1.385163 2026.261 -235.603
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 0         0           0.0009231952    1.476118 2026.273 -252.117
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008442119    1.448701 2026.263 -236.8151
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008125887    1.417806 2026.251 -223.2181
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0008865791     1.38581 2026.263 -235.3673
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.000951682    1.458468 2026.277 -251.7361
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0008680402     1.44394 2026.267 -236.7556
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008324714    1.417951 2026.255 -223.2785
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0009046607    1.389258 2026.267 -234.9915
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0              0.0010117    1.455176 2026.285 -249.9257
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1           0.0009195575    1.444604 2026.275 -235.8182
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0008819716     1.41706 2026.264 -223.6722
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3           0.0009518081    1.392531 2026.274 -235.2508
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.001107362    1.473467 2026.295 -250.0642
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 1         1           0.0009927199    1.449201 2026.284 -236.248
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2           0.0009455984    1.424094 2026.274 -224.7943
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.001012213    1.388084 2026.283 -235.4909
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 0         0            0.001278249    1.463864 2026.309 -251.6814
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 1         1            0.001137755    1.430467 2026.297 -237.8536
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001072232    1.403821 2026.289 -226.5224
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.001131749    1.365227 2026.298 -237.8453
## ---
##   iteration median_unadjusted_rate coef_of_var   tmrca    logLik
## 0         0            0.001510592    1.441471 2026.32 -257.0325
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca   logLik
## 1         1             0.00132251    1.405782 2026.309 -243.011
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 2         2            0.001213682    1.377289 2026.301 -232.4475
## ---
##   iteration median_unadjusted_rate coef_of_var    tmrca    logLik
## 3         3            0.001307307    1.332704 2026.309 -242.4073
## ---
## 
## NOTE: The estimated coefficient of variation of clock rates is high (>1). Sometimes this indicates a poor fit and/or a problem with the data.
##      
## 
## The following steps may help to fix or alleviate common problems:
## * Check that the vector of sample times is correctly named and that the units are correct.
## * If passing a rooted tree, make sure that the root position was chosen correctly, or estimate the root position by passing an unrooted tree (e.g. pass ape::unroot(tree))
## * The root position may be poorly estimated. Try increasing the _searchRoot_ parameter in order to test more lineages as potential root positions.
## * The model may be fitted by a relaxed or strict molecular clock. Try changing the _clock_ parameter
## * A poor fit may be due to a small number of lineages with unusual / outlying branch lengths which can occur due to sequencing error or poor alignment. Try the *outlierTips* command to identify and remove these lineages.
## * Check that there is adequate variance in sample times in order to estimate a molecular clock by doing a root-to-tip regression. Try the *rootToTipRegressionPlot* command. If the clock rate can not be reliably estimated, you can fix the value to a range using the _meanRateLimits_ option which would estimate a time tree given the previous estimate of clock rates.
# Compare log-likelihoods: uncorrelated vs additive
c(td1u$loglik, td1a$loglik)
## [1] -249.7674 -215.9803
td1a
## 
## NOTE: The estimated coefficient of variation of clock rates is high (>1). Sometimes this indicates a poor fit and/or a problem with the data.
##      
## 
## The following steps may help to fix or alleviate common problems:
## * Check that the vector of sample times is correctly named and that the units are correct.
## * If passing a rooted tree, make sure that the root position was chosen correctly, or estimate the root position by passing an unrooted tree (e.g. pass ape::unroot(tree))
## * The root position may be poorly estimated. Try increasing the _searchRoot_ parameter in order to test more lineages as potential root positions.
## * The model may be fitted by a relaxed or strict molecular clock. Try changing the _clock_ parameter
## * A poor fit may be due to a small number of lineages with unusual / outlying branch lengths which can occur due to sequencing error or poor alignment. Try the *outlierTips* command to identify and remove these lineages.
## * Check that there is adequate variance in sample times in order to estimate a molecular clock by doing a root-to-tip regression. Try the *rootToTipRegressionPlot* command. If the clock rate can not be reliably estimated, you can fix the value to a range using the _meanRateLimits_ option which would estimate a time tree given the previous estimate of clock rates.
## 
## Phylogenetic tree with 126 tips and 125 internal nodes.
## 
## Tip labels:
##   PP_006XHKB.2, PP_00764EH.1, PP_00765UM.1, PP_0076617.1, PP_00765M1.1, PP_0076SYS.1, ...
## Node labels:
##   , 0/72, 75/73, 0/21, 0/4, 0/7, ...
## 
## Rooted; includes branch length(s).
## 
##  Time of common ancestor 
## 2026.19675611284 
## 
##  Time to common ancestor (before most recent sample) 
## 0.277216489901548 
## 
##  Weighted mean substitution rate (adjusted by branch lengths) 
## 0.000662201855705779 
## 
##  Unadjusted mean substitution rate 
## 0.000627985792733175 
## 
##  Clock model  
## additive 
## 
##  Coefficient of variation of rates 
## 1.56980990588145

6.3 Inspect best-fit model (strict)

# Time tree plot
plot(td1, show.tip.label = F)
axisPhylo(root.time = td1$timeOf, backward = FALSE)

# Summary
td1
## 
## Phylogenetic tree with 126 tips and 125 internal nodes.
## 
## Tip labels:
##   PP_006XHKB.2, PP_00764EH.1, PP_00765UM.1, PP_0076617.1, PP_00765M1.1, PP_0076SYS.1, ...
## Node labels:
##   , 0/72, 75/73, 0/21, 0/4, 0/7, ...
## 
## Rooted; includes branch length(s).
## 
##  Time of common ancestor 
## 2026.20852968182 
## 
##  Time to common ancestor (before most recent sample) 
## 0.265442920918304 
## 
##  Weighted mean substitution rate (adjusted by branch lengths) 
## 0.000633988705841585 
## 
##  Unadjusted mean substitution rate 
## 0.000633988705841585 
## 
##  Clock model  
## strict 
## 
##  Coefficient of variation of rates 
## 0
# MRCA date
date_decimal(td1$timeOfMRCA)
## [1] "2026-03-18 02:43:12 UTC"

6.4 Root-to-tip regression

rootToTipRegressionPlot(td1)

## Root-to-tip mean rate: 0.000243214384353623 
## Root-to-tip p value: 0.447464470486757 
## Root-to-tip R squared (variance explained): 0.0046616579901538 
## Returning fitted linear model.

7. Bootstrap for confidence intervals (from iqtree ufboot distribution)

# Bootstrap
btd <- treedater::boot(
  td1, btres,
  ncpu = 8,
  overrideTempConstraint = FALSE, quiet = TRUE
)
## Running in quiet mode. To print progress, set quiet=FALSE.
btd
##                            pseudo ML        2.5 %       97.5 %
## Time of common ancestor 2.026209e+03 2.026089e+03 2.026291e+03
## Mean substitution rate  6.339887e-04 3.357899e-04 1.343159e-03
## 
##  For more detailed output, $trees provides a list of each fit to each simulation
# Bootstrap CI on MRCA date
date_decimal(btd$timeOf)
##                      2.5%                     97.5% 
## "2026-02-02 13:02:11 UTC" "2026-04-17 01:34:46 UTC"

8. BactDating

trbd1 <- tr1
trbd1$edge.length <- trbd1$edge.length * aln_len

bd1a <- bactdate(
  trbd1, sts[tr1$tip.label],
  initMu = aln_len * td1$mean.rate,
  model = "arc", showProgress = FALSE # TRUE
)

bd1a
## Phylogenetic tree dated using BactDating
## 
## Phylogenetic tree with 126 tips and 125 internal nodes.
## 
## Tip labels:
##   PP_006XHKB.2, PP_00764EH.1, PP_00765UM.1, PP_0076617.1, PP_00765M1.1, PP_0076SYS.1, ...
## Node labels:
##   , 0/72, 75/73, 0/21, 0/4, 0/7, ...
## 
## Rooted; includes branch length(s).
## Probability of root branch=0.49
## likelihood=-2.62e+02 [-2.75e+02;-2.49e+02]
## prior=-2.28e+02 [-2.59e+02;-2.00e+02]
## mu=1.29e+01 [9.45e+00;1.67e+01]
## sigma=3.09e-01 [1.66e-02;6.20e-01]
## alpha=2.31e+00 [1.72e+00;3.10e+00]
## Root date=2025.86 [2025.63;2026.06]
## Root date for most likely root=2025.86 [2025.64;2026.05]

Note: The estimated mean rate from BactDating is consistent with treedater, but the inferred root date is unusually early.


9. DiagnoDating

9.1 Root-to-tip (DiagnoDating)

NEEDS DiagnoDating >= 0.9.1, ie the fix-treedater-units branch (PR #1), which is where the additive clock, the seqlen argument and matching of named dates were fixed. Before that, treedater results always came back as model=‘poisson’ with relax=0:

devtools::install_github('xavierdidelot/DiagnoDating', ref = 'fix-treedater-units')
roottotip(tr1, sts)

## $rate
##         date 
## 0.0002432144 
## 
## $ori
## (Intercept) 
##    2025.296 
## 
## $pvalue
## [1] 0.2215

DiagnoDating, like BactDating, wants branch lengths in substitutions rather than per site, so rescale the tree. seqlen then tells treedater how to convert back, and omega0 and meanRateLimits stay in treedater’s own units of substitutions per site per year.

trdd <- tr1
trdd$edge.length <- trdd$edge.length * aln_len

9.2 Run & diagnose

ddtd <- runDating( trdd, sts[ tr1$tip.label ], algo = 'treedater', keepRoot = TRUE, 
                   seqlen = aln_len, clock = 'strict', omega0 = td1$mean.rate, meanRateLimits = td1$mean.rate*c(1,1+1e-6) ) #
ddtd
## Result from treedater, model poisson, clock rate 11.67, relaxation parameter 0.00, root date 2026.23
plotLikBranches(ddtd)

plotResid(ddtd)

# Anderson-Darling normality test on residuals
testResid(ddtd)
## 
##  Anderson-Darling test of goodness-of-fit
##  Null hypothesis: Normal distribution
##  with parameters mean = 0.000, sd = 1.000
## 
## data:  n
## An = 2.4185, p-value = 0.05473

10. Profile likelihood for the clock rate

ratetologlik <- function(omega){
    capture.output( x <- sapply( btres, function(tr) dater(tr, sts, s=aln_len,  clock="strict", omega0 = omega, meanRateLimits = omega*c(.98,1.02), quiet=TRUE, ncpu=1)$loglik ) )
    x |> pomp::logmeanexp()
}

omegas <- seq( 0.0001, 0.002, length.out = 30)
llprof <- unlist( parallel::mclapply( omegas, ratetologlik, mc.cores=8 ) )
source( 'scripts/profplot-02b.R')
prpl <- profplot( omegas, llprof )
prpl


11. Effective population size (mlesky)

library(mlesky)
range_tr <- max(sts) - td1$timeOfMRCA
range_tr_weeks <- ceiling(range_tr * 52.1775)
range_tr_weeks
## [1] 14
mlsk <- mlskygrid(td1, sampleTimes=sts, res=NULL, tau=NULL, tau_lower=0.001, tau_upper=100, 
                  ncross=10, ncpu=4, quiet=F, model=2)
plot(mlsk, logy=T)

mlsk$res
mlsk$tau 
mlsk_pboot <- mlesky::parboot(mlsk, nrep=1000, ncpu=8, dd=F)
# regular bootstrap NEEDS mlesky >= 0.1.9: # devtools::install_github('emvolz-phylodynamics/mlesky')
# bmlsk <- mlesky::boot( mlsk, btd$trees, ncpu = 8, sampleTimes = sts )
plot(mlsk_pboot, logy=T, ggplot=T)


12. Ancestral state estimation with tree figure

library(phangorn)

collapse_dated <- function(td, aln_len, min_subs = 0.5) {
    phy  <- as.phylo(td)
    subs <- td$intree$edge.length * aln_len              # substitutions per edge (aligned to phy$edge)
    nd   <- node.depth.edgelength(phy)                   # node heights (time) from root
    tmp  <- phy; tmp$edge.length <- subs
    topo <- di2multi(tmp, tol = min_subs)                # collapse by substitutions
    Ntt  <- Ntip(topo); dts <- numeric(Ntt + topo$Nnode) # re-time from the original treedater dates
    dts[1:Ntt] <- (td$timeOfMRCA + nd[1:Ntip(phy)])[match(topo$tip.label, phy$tip.label)]
    desc <- Descendants(topo, (Ntt+1):(Ntt+topo$Nnode), "tips")
    for (i in seq_along(desc)) {
        tips <- topo$tip.label[desc[[i]]]
        mn   <- if (length(tips)==Ntip(phy)) Ntip(phy)+1 else getMRCA(phy, tips)
        dts[Ntt+i] <- td$timeOfMRCA + nd[mn]
    }
    topo$edge.length <- dts[topo$edge[,2]] - dts[topo$edge[,1]]
    topo$root.time   <- td$timeOfMRCA
    topo
}
.norm <- function(x){ x <- toupper(trimws(x)); x[x=="" | x=="NOT PROVIDED"] <- "UNKNOWN"
    dplyr::recode(x, "MONGWALU"="MONGBWALU","MUNGWALU"="MONGBWALU","NYAKUNDE"="NYANKUNDE") }
# shared locality set + palette (both trees have identical tips, so colours are comparable)
loc0 <- .norm(md_match$geoLocAdmin2[ match(as.phylo(td1)$tip.label, md_match$accessionVersion) ])
top5 <- names(sort(table(loc0), decreasing=TRUE))[1:5]
LEV  <- c(top5, "Other")
pal  <- setNames(c("#0072B2","#D55E00","#009E73","#E69F00","#CC79A7","grey72"), LEV)
mrsd <- as.Date(date_decimal(max(sts))); ci <- btd$timeOfMRCA_CI; break_gr <- 2026.35
mb <- decimal_date(seq(as.Date("2026-01-01"), as.Date("2026-08-01"), by="month"))
ml <- format(seq(as.Date("2026-01-01"), as.Date("2026-08-01"), by="month"), "%b %Y")

geo_tree_fig <- function(tree, root_date, title) {
    phy <- as.phylo(tree); nt <- Ntip(phy)
    loc <- .norm(md_match$geoLocAdmin2[ match(phy$tip.label, md_match$accessionVersion) ])
    loc[!loc %in% top5] <- "Other"
    dat <- phangorn::phyDat(as.matrix(data.frame(s=loc, row.names=phy$tip.label)), type="USER", levels=LEV)
    mat <- do.call(rbind, lapply(phangorn::ancestral.pars(phy, dat, "MPR"), function(z) z[1,])); colnames(mat) <- LEV
    map  <- LEV[apply(mat,1,which.max)]; conf <- apply(mat,1,max)
    ntrans <- sum(map[phy$edge[,1]] != map[phy$edge[,2]])
    lab <- rep(NA_character_, nt+phy$Nnode)               # UFBoot labels, only on collapsed trees
    if (!is.binary(phy)) {
        ufb <- as.numeric(sub(".*/", "", tr1$node.label))
        for (n in (nt+1):(nt+phy$Nnode)) {
            tips <- phy$tip.label[ unlist(phangorn::Descendants(phy, n, "tips")) ]
            mn <- if (length(tips)==nt) Ntip(tr1)+1 else getMRCA(tr1, tips)
            if (!is.null(mn) && !is.na(mn)) lab[n] <- as.character(round(ufb[mn - Ntip(tr1)]))
        }
    }
    nodedf <- data.frame(node=1:(nt+phy$Nnode), state=factor(map,levels=LEV), conf=conf, lab=lab)
    pg <- ggtree(tree, mrsd=mrsd, size=0.5) %<+% nodedf + aes(color=state)
    # ggtree rounds mrsd to whole days, shifting its x-axis; off re-aligns absolute-date annotations
    rootx <- pg$data$x[pg$data$node == nt+1]; rooty <- pg$data$y[pg$data$node == nt+1]
    off <- rootx - root_date; cih <- 0.4   # half-height of the thin TMRCA CI band, in tip-row units
    pg$layers <- c(annotate("rect", xmin=ci[1]+off, xmax=ci[2]+off, ymin=rooty-cih, ymax=rooty+cih, fill="grey30", alpha=0.45), pg$layers)  # thin TMRCA 95% CI band at the root, behind the tree
    pg +
        geom_vline(xintercept=break_gr+off, linetype="dashed", color="grey55", linewidth=0.4) +
        # annotate("label", x=break_gr+off, y=nt*0.965, label="growth-rate\nchange 2026.35", size=2.7,
        #          color="grey40", hjust=-0.04, vjust=1, lineheight=0.9, fill="white", alpha=0.7) +
        annotate("point", x=rootx, y=rooty, shape=18, size=2.8, color="grey20") +
        annotate("text", x=mean(ci)+off, y=rooty+cih+nt*0.02, label="TMRCA 95% CI", size=2.6, color="grey35", vjust=0) +
        geom_nodepoint(aes(color=state, size=conf), alpha=0.85) +
        geom_nodelab(aes(label=lab), geom="label", size=1.9, vjust=-0.6, color="grey20",
                     fill="white", label.size=0, label.padding=unit(0.04,"lines"), na.rm=TRUE) +
        geom_tippoint(aes(fill=state), shape=21, size=2, stroke=0.25, color="white") +
        scale_color_manual(values=pal, guide="none") +
        scale_fill_manual(values=pal, name="geoLocAdmin2") +
        scale_size_continuous(range=c(0.6,3), guide="none") +
        scale_x_continuous(breaks=mb+off, labels=ml, limits=c(min(ci[1]+off, rootx)-0.02, max(sts)+off+0.02)) +
        labs(title=title,
             subtitle=glue("{nt} genomes | {phy$Nnode} internal nodes | MRCA {format(as.Date(date_decimal(root_date)),'%d %b %Y')} ")) +
        theme_tree2() +
        theme(plot.title=element_text(face="bold",size=12), plot.subtitle=element_text(size=8.5,color="grey40"),
              axis.text.x=element_text(size=9,color="grey40"), legend.position=c(0.12,0.75),
              legend.background=element_rect(fill="white",color="grey85"), legend.key.size=unit(0.9,"lines"))
}

td1_collapsed <- collapse_dated(td1, aln_len, min_subs = 0.5)
pg_coll <- geo_tree_fig(td1_collapsed, td1_collapsed$root.time, "")
print(pg_coll)