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.
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:
I believe you need to treat leaf (the ones with tip.label value) vs non-leaf nodes differently.
Hi Fatima. length(timetree$tip.label) is 5500 which(timetree$tip.label=="tip_name_1") is 2615
Have you tried working with treeio R package? When I was trying to work with phylogenetic trees, I used treeio, and it worked well.