xavierdidelot / TransPhylo

Reconstruction of transmission trees using genomic data
http://xavierdidelot.github.io/TransPhylo/
GNU General Public License v2.0
60 stars 22 forks source link

Error message when running inferTTree #1

Closed wilssh closed 7 years ago

wilssh commented 7 years ago

Xavier,

When running inferTTree on the maximum clade credibility tree you supplied from Genomic Infectious Disease Epi..., I encounter the following error:

> tb_ttree <- inferTTree(tb_ptree, ws.shape = 1.1, ws.scale = 2.5, w.shape = 1.3, w.scale = 10/3)
[1] "errorThere"
[1] "errorThere"
[1] "errorThere"
Error in if (ex[cur] == 1) { : argument is of length zero

Do you know what is causing this? I tried diving into the code for inferTTree and the other functions it calls, but so far I've been unable to figure out where it's breaking. I've included the tree and the R code below to reproduce the error.

TransPhylo inferTTree Error.zip

Thanks, Shane

xavierdidelot commented 7 years ago

Hi Shane,

Sorry for the delayed answer, I'm just back from holiday. The "errorThere" message means there is something wrong with the input ptree.

You used as.numeric to convert the date of the last sample but this returns 14914 which is not right. If instead you use for example Date2decimal from the ggtree package then you get 2010.833 which is correct (since this should be the date in decimal year format).

There is also something wrong with your tb_phylo, although I'm not sure exactly what the problem is with this. What I did is to convert the nexus file into the attached newick file and then I generate the tb_phylo using tb_phylo=read.tree('tb.nwk') and all works fine.

I hope this solves all problems on your side, but don't hesitate to reopen this issue if you're still having problems.

Best wishes, Xavier

tb.nwk.zip