liamrevell / phytools

GNU General Public License v3.0
207 stars 56 forks source link

"subscript out of bounds" in ancestral state estimation using phytools #95

Closed avvypaks closed 3 years ago

avvypaks commented 3 years ago

Hi, I am using "http://www.phytools.org/Cordoba2017/ex/8/Anc-states-discrete.html" this script for ancestral state estimation using phytools. Now, even with the sample files, I am getting error:

Error in [<-(*tmp*, x == seq[i], i, value = 1) : subscript out of bounds

in the code : tiplabels(pie=to.matrix(feed.mode[eel.tree$tip.label], levels(feed.mode)),piecol=cols,cex=0.3)

Can you help me with this error?

liamrevell commented 3 years ago

Hi @avvypaks. My guess is that the input data are not being treated as a factor -- so levels(feed.mode) is nonsensical. Try running feed.mode<-as.factor(feed.mode) and then the rest as written & see if that solves your problem.