xavierdidelot / BactDating

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

Error in if (log(runif(1)) < l2 - l + dgamma(mu2, shape = 0.001, scale = 1000, : missing value where TRUE/FALSE needed #67

Closed varunshamanna closed 7 months ago

varunshamanna commented 8 months ago

Hi,

I was trying to run BactDating on my Klebsiella tree and am getting the error.

I generated core-genome alignment using panaroo and snp-sites to get only the variants' alignment. Then I generated the iqtree using this command iqtree -s core_gene_alignment.variants_only.fas -m GTR+G -alrt 1000 -bb 1000 -nm 200 -nt AUTO -ntmax 40 -czb

Here are the contents from my Rscript where I am trying to run the Bactdating

t=read.tree('~/Downloads/core_gene_alignment.variants_only.fas.treefile')
t1 <- midpoint_root(t)
sum(t1$edge.length)
t1$edge.length=t1$edge.length*37158

#write the node ids to get the dates in same order
ids <-  t1$tip.label
write.csv(ids,"~/Downloads/ids_180.csv")

d=read.csv("~/Downloads/dates_180.csv",header = FALSE)
d1 <- as.vector(t(d))

#find the root to tip analysis to find MRCA
rttip =roottotip(t1,d1)

#build the time tree
res=bactdate(t1,d1)

and I get this error Error in if (log(runif(1)) < l2 - l + dgamma(mu2, shape = 0.001, scale = 1000, : missing value where TRUE/FALSE needed

Please help me out.

xavierdidelot commented 7 months ago

There are several problems that can trigger this message. You should make sure that your input tree has no branches of negative length, and also no polytomies.