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 to BactDating #65

Closed STChoudhury closed 11 months ago

STChoudhury commented 11 months ago

Hello I am trying to make a time calibrated tree using 206 samples. I have the sampling date for most and missing for some. I am trying to follow this webpage, https://xavierdidelot.github.io/BactDating/articles/yourData.html

But I am getting an error when i try:

res=bactdate(t,d)

The error I am getting is: Error in if (var(date, na.rm = T) == 0 && is.na(rate)) { : missing value where TRUE/FALSE needed

I am very new to bactdating. It would be greatly appreciated if you could help me move forward.

Thank you.

xavierdidelot commented 11 months ago

Since you have sampling dates for most and missing a few, your best option is probably to have d being a named vector including some NAs for the missing values. Check that d is indeed a vector, if you type class(d) you should get numeric. Also check that the names in names(d) are the same as in t$tip.label. For example you could do setdiff(t$tip.label,names(d)) to see if there are any leaves of the tree not in the vector of dates d.

STChoudhury commented 11 months ago

Hello, Thank you so much. I finally have a time calibrated tree. I have two more questions, in my tree, the tips are all labelled. How can I remove them from the plot? And can I save the plot as a newick file so that I can open it in iTOL?

Thank you.

xavierdidelot commented 11 months ago

Great! If you used res=bactdate(...) then you can use plot(res) to plot the tree with labels or plot(res,show.tip.label=F) to plot the tree without the labels. You can export the tree in Newick format using write.tree(res$tree,'filename.nwk')