treeio icon indicating copy to clipboard operation
treeio copied to clipboard

as.treedata sequence length

Open antoine4ucsd opened this issue 2 years ago • 1 comments

hello thank you for your nice package I am trying to use it in order to plot my tree along with aminoacid sub (with ggtree). My input are a nt alignment of 130 sequences and its phylo. the alignement contains some gaps.

My code

sampletree=read.tree(mytree)
tre=midpoint.root(sampletree)
tipseq <- read.phyDat("myfasta.fasta",format="fasta")
fit <- pml(tre, tipseq, k=4)
fit <- optim.pml(fit, optNni=FALSE, optBf=T, optQ=T,
                 optInv=T, optGamma=T, optEdge=TRUE,
                 optRooted=FALSE, model = "GTR")

pmltree <- treeio::as.treedata(fit)
ggtree(pmltree) + geom_text(aes(x=branch, label=AA_subs, vjust=-.5))

but I get this error with treeio::as.treedata(fit):

Error in getSubsLabel(seqs, label[pp[i]], label[i], translate, removeGap) : 
  seqA should have equal length to seqB

any suggestions? thank you ++

antoine4ucsd avatar Dec 14 '22 16:12 antoine4ucsd

you should provide example data to reproduce this issue.

GuangchuangYu avatar Jun 30 '23 15:06 GuangchuangYu