Getting node name using tip name from a nexus tree
0
0
Entering edit mode
4.1 years ago
Mac ▴ 20

hi everyone,

I imported an phylogenetic tree (nexus file), an output of treetime. I used the "ape::read.nexus("file.nexus")" function to import. After importing I wanted to get the node names associated with every tip. I used the following funtion:

timetree$node.label[timetree$tip.label=="tip_name_1"]

..where tip_name_1 is the name of the tip that i would like to extract the node name for. It gave me a tip name, but when I checked on the actual tree in Figtree, it was the wrong node. At first I was not sure if the problem was during the import of the nexus file or if the method above is wrong. I used the phytools funtion "get.sisters", and it extracts the tip names on neighboring nodes, and this seems to be working accurately, and we could conclude that the importing is working fine. I have also tried the "get.Descendants() function with no success.

I am looking for an alternative method of getting the node names associated with the tips. I do not mind if the method is not R.

R • 2.1k views
ADD COMMENT
0
Entering edit mode

Hi, could you provide some more details?

When you load the tree, what information do you see on the Environment window of Rstudio?

What is the value of each of these:

length(timetree$tip.label)

which(timetree$tip.label=="tip_name_1")

I believe you need to treat leaf (the ones with tip.label value) vs non-leaf nodes differently.

ADD REPLY
0
Entering edit mode

Hi Fatima. length(timetree$tip.label) is 5500 which(timetree$tip.label=="tip_name_1") is 2615

ADD REPLY
0
Entering edit mode

Have you tried working with treeio R package? When I was trying to work with phylogenetic trees, I used treeio, and it worked well.

ADD REPLY

Login before adding your answer.

Traffic: 2595 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6