export bactdating object to tree
clydeandforth opened this issue · 2 comments
Hi James,
Yes you can do this with BactDating. When you run the bactdate command you will need to fix the substitution rate using the arguments "initMu=mu,updateMu=F". The value mu you set it to should be expressed for the whole 6 genes alignment, not per site. If you know the clock rate per site, you should multiply this by the sum of the lengths of the 6 genes to get the correct value of mu. You will also need to use the argument "date=rep(N,2019)" where N is your number of genomes, to specify that all genomes have the same date.
Best wishes,
Xavier
Originally posted by @xavierdidelot in #20 (comment)
Hi Xavier,
That worked well thanks:
d=rep(2019, 26)
res=bactdate(t,d, initMu=0.0022, updateMu=F,nbIts=1e5, updateRoot=T)
I would like to export 'res' to ggtree or some other tree aesthetics program. I tried this:
res2<-as.treedata.resBactDating(res)
ggtree(res2) + geom_point(aes(shape=isTip, color=isTip), size=5) +
geom_tiplab(size=5, color="purple")
Error: data
must be a data frame, or other object coercible by fortify()
, not a list
&&
tree3<-write.beast(res)
#NEXUS
[R-package treeio, Tue Nov 19 14:19:22 2019]
Error in UseMethod("Ntip") :
no applicable method for 'Ntip' applied to an object of class "resBactDating"
&&
tree2<-as.treedata(res)
tree3<-write.beast(tree2)
#NEXUS
[R-package treeio, Tue Nov 19 14:19:27 2019]
Error in UseMethod("Ntip") :
no applicable method for 'Ntip' applied to an object of class "list"
Is there a way around this?
Thanks,
James
Hi James,
I think what you need is:
res2<-as.treedata.resBactDating(res)
res3<-methods::new('treedata',phylo=res2[[1]],data=dplyr::tbl_df(as.data.frame(res2[[2]])))
ggtree(res3)
Best wishes,
Xavier