Reputation: 189
I would like to draw only one point on the fist node, and then draw another one in the first tip. So far I could draw points but only all of them at once and I cannot find the way to draw it separately. What I have so far:
library(ape)
t3 = '((a:1,b:1):1,(c:1.5,d:0.5):0.5):1;'
plot(read.tree(text = t3),root.edge=T)
nodelabels(pch=21, col="black", adj=1, bg='blue', cex=2)
any help is appreciated
Upvotes: 1
Views: 526
Reputation: 11
You can define to which node you want to plot with the "node" argument within the nodelabels function, and the same is true for tiplabels function but with "tip" argument. So:
library(ape)
t3 = '((a:1,b:1):1,(c:1.5,d:0.5):0.5):1;'
tree <- read.tree(text = t3)
first_node <- length(tree$tip.label)+1
plot(tree, root.edge=T)
nodelabels(node = first_node, pch=21, col="black", bg='blue', cex=2)
tiplabels(tip = 1, pch=21, col="black", bg='blue', cex=2)
Upvotes: 1
Reputation: 6222
This isn't the exact answer, but it should help. I got this by looking at the code for nodelabels
function.
library(ape)
t3 = '((a:1,b:1):1,(c:1.5,d:0.5):0.5):1;'
plot(read.tree(text = t3),root.edge=T)
lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
node <- (lastPP$Ntip + 1):length(lastPP$xx)
XX <- lastPP$xx[node]
YY <- lastPP$yy[node]
BOTHlabels(text="", node, XX[1], YY[1], adj = c(0.5, 0.5),
frame = "rect", pch = 21, thermo = NULL, pie = NULL,
piecol = NULL, col = "blue", bg = "blue",
horiz = FALSE, width = NULL, height = NULL, cex=2)
The XX's and YY's gives the nodes. Here, I'm using only the first one. What you have to do for tips is similar, too. Have a look at the code for tiplabels
.
Upvotes: 1