YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

as.treedata sequence length #91

Open antoine4ucsd opened 1 year ago

antoine4ucsd commented 1 year ago

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 ++

GuangchuangYu commented 1 year ago

you should provide example data to reproduce this issue.