xavierdidelot / BactDating

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

Extracting node height and CI #35

Closed GonzaloYebra closed 4 years ago

GonzaloYebra commented 4 years ago

Dear Xavier,

Thanks for a great tool and your helpful comments.

Sorry if you've explained this somewhere else, but I was wondering if there's an "easy" way to check dates and CIs of internal nodes apart from the root. Visualising in FigTree the exported tree in nexus format you can check the dates but, as I understand it, the shown height_0.95_HPD and length_0.95_HPD are numbers meant to be interpreted by ggplot or similar. Is there any way of transforming this CI back into dates?

Thanks in advance for your help,

Gonzalo

xavierdidelot commented 4 years ago

Hi Gonzalo,

The easiest way to do this is to look at res$CI where res is the output from bactdate. This is a matrix containing the 95% credible intervals on dating of all nodes in the tree. The rows of this matrix correspond to the indexes of the res$tree which is a phylo object (from the ape package) representing the best estimate of the dated phylogeny. To use this you need a bit of familiarity with the way phylo objects work, but this is easier than making sense of the ggplot of FigTree outputs.

Best wishes, Xavier

GonzaloYebra commented 4 years ago

Hi Xavier,

It makes sense, thanks! Just for other people's sake, I'm doing it now using getMRCA() to find out the node number of the common node to a group of tips, and then finding the row corresponding to that number in the res$CI matrix.

Best wishes, Gonzalo

maesaar commented 4 years ago

@GonzaloYebra check the issue #29 if it is what you needed.

GonzaloYebra commented 4 years ago

Thanks @mmaesaar , I seem to have missed that issue, very useful information as well.