xavierdidelot / BactDating

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

Incorrect dimensions #42

Closed furqan915 closed 3 years ago

furqan915 commented 3 years ago

Hi, I am new to this work. I am trying to perform a core genome analysis of some bacterial strains. I have built a tree using Iqtree with GTR+G3 model. Now I need to use bacdating to date my tree. I have used following commands

sum(tree$edge.length) # answer was less than 1 so I ran the following command
# L = number of sites used to build the tree; can be found in the iqtree file
tree$edge.length=tree$edge.length*2951462
aero_d <- as.data.frame(aero$collection_date)
aero_d
colnames(aero_d) <- NULL
res=bactdate(tree,aero_d)

but the last command returns an error

Error in cor(date, ys, use = "complete.obs") : incompatible dimensions

Please help me in this regard Thanks

xavierdidelot commented 3 years ago

The second argument date to bactdate needs to be a vector, not a data frame. If there is no names(date) then this vector is assumed to be in the same order as tree$tip.label. If there are names(date) then they need to be the same as the tree$tip.label but do not need to be in the same order.