简体   繁体   English

R ape包中的subtrees()-如何在子树中标记内部节点?

[英]subtrees() in R ape package - how are internal nodes labeled in subtree?

I'm working with the ape package in R. I'm wanting a list of every possible subtree from a phylogenetic tree. 我正在使用R中的ape包。我想要一个phylogenetic树中每个可能的subtree的列表。 I'm then wanting to iterate through the list of subtrees and get the root of every subtree. 然后,我想遍历子树列表并获取每个子树的根。 My question is, is the first internal node listed for each subtree the root of that subtree? 我的问题是,为每个子树列出的第一个内部节点是否是该子树的根?

An example might illustrate my question better. 一个例子也许可以更好地说明我的问题。 I created a random tree with 12 tips, then extract the subtrees. 我用12个技巧创建了一个随机树,然后提取子树。 I've copied the output for subtree 1. R then lists a couple of things including Node labels: 13, 14, ... for each subtree. 我已经复制了子树1的输出。R然后列出了一些东西,包括Node labels: 13, 14, ...每个子树Node labels: 13, 14, ... Is the first node listed in Node labels (in this case node 13) always the root of the subtree? 节点标签中列出的第一个节点(在本例中为节点13)是否始终是子树的根?

phy = rtree(12)

st = subtrees(phy)

>st[[1]]

> st

[[1]]

Phylogenetic tree with 12 tips and 11 internal nodes.

Tip labels:
    t12, t2, t10, t1, t9, t4, ...

Node labels:
    13, 14, 15, 16, 17, 18, ...

Rooted; includes branch lengths.

That seems to be the case. 似乎是这样。 To verify, you can visualize the tree by converting it to a data.tree structure: 为了进行验证,您可以通过将树转换为data.tree结构来使其可视化:

library(data.tree)
tr <- as.Node(phy)
print(tr)

This will show as: 这将显示为:

                        levelName
1  13                            
2   ¦--t7                        
3   °--14                        
4       ¦--15                    
5       ¦   ¦--t5                
6       ¦   °--t6                
7       °--16                    
8           ¦--17                
9           ¦   ¦--18            
10          ¦   ¦   ¦--19        
11          ¦   ¦   ¦   ¦--20    
12          ¦   ¦   ¦   ¦   ¦--t2
13          ¦   ¦   ¦   ¦   °--t9
14          ¦   ¦   ¦   °--t12   
15          ¦   ¦   °--t4        
16          ¦   °--21            
17          ¦       ¦--22        
18          ¦       ¦   ¦--t3    
19          ¦       ¦   °--t1    
20          ¦       °--23        
21          ¦           ¦--t10   
22          ¦           °--t11   
23          °--t8                

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM