我正在尝试绘制系统发育树,但每次我尝试绘制它时,都会引发以下错误:
Error in as.graphicsAnnot(legend) : argument "legend" is missing, with no default
这是一个MWE:
library(ape)
library(phangorn)
tr <- read.tree(text = "(((L2,L3),L4),L1);")
df <- data.frame(L1 = c(0,0,1,0,0,0,1,1,1,1,0,0,0,0,1), L2 =
c(0,1,1,0,1,1,0,1,1,0,1,1,0,1,1),L3 = c(1,1,1,0,0,0,1,1,1,0,0,0,1,1,1),
L4=c(0,0,1,1,0,0,0,0,1,1,0,0,0,0,1))
phydat <- as.phyDat(df,type="USER",levels=c(1,0),names=names(df))
anc.tree <- pratchet(phydat) #ratchet search
anc.tree <- optim.parsimony(anc.tree,phydat) #NNI optimization
anc.tree <-root(anc.tree,outgroup = "L1", resolve.root = TRUE) #roots the tree
anc.tree <- acctran(anc.tree,phydat) #adds branch lengths
anc.acctran <- ancestral.pars(anc.tree,phydat, "ACCTRAN")
以下调用plotAnc()
引发了上面关于缺少图例的错误:
plotAnc(anc.tree,anc.acctran,1)
我之前尝试调用以下函数plotAnc()
:
legend("bottomright", "foo")
我仍然收到有关图例的错误消息。我究竟做错了什么?