我可以从系统树中获取所有提示标签,也可以从某个节点获取所有后代节点,但是我无法获取属于某个节点的提示标签。
#for a random tree x
x <- rtree(10, tip.label = LETTERS[1:10])
#get all tip labels by asking for tree information
> x
Phylogenetic tree with 10 tips and 9 internal nodes.
Tip labels:
H, G, D, B, I, C, ...
Rooted; includes branch lengths.
#descendant nodes from a node
test <- phytools::getDescendants(x, node=5, curr=NULL)
#the package ggphylo seemed to have the answer to my problem, but it is no longer supported (last updates were in 2012)
ggphylo::tree.as.data.frame(x)
(我认为转换为数据帧是最简单的方法,但是如果您知道从节点获取后代提示的另一种方法,那么我会接受所有可能的解决方案)
答案 0 :(得分:0)
您是否在寻找边缘表(即显示每个尖端与节点之间连接的表)?您可以使用以下方法直接在phylo
对象中访问它:
## The edge table
x$edge
您可以在following SO question中找到更出色的可视化视图。
答案 1 :(得分:0)
compute.mr
包中的函数phytools
将系统发育学转换为其矩阵表示形式,这可能正是您所需要的。
x <- rtree(10, tip.label = LETTERS[1:10])
phytools::compute.mr(x, type = "matrix")
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
# H "1" "1" "1" "0" "0" "0" "0" "0"
# E "1" "1" "1" "0" "0" "0" "0" "0"
# C "1" "1" "0" "1" "1" "0" "0" "0"
# I "1" "1" "0" "1" "1" "0" "0" "0"
# J "1" "1" "0" "1" "0" "0" "0" "0"
# F "1" "0" "0" "0" "0" "1" "0" "0"
# A "1" "0" "0" "0" "0" "1" "0" "0"
# D "0" "0" "0" "0" "0" "0" "1" "0"
# G "0" "0" "0" "0" "0" "0" "1" "1"
# B "0" "0" "0" "0" "0" "0" "1" "1"
答案 2 :(得分:0)
谢谢您的建议。 我找到了一个正在寻找答案的同事。 ape包中的prop.part函数可以很好地概述每个节点的所有提示。结果是列表而不是数据框,但是可以解决问题。 list_all_tips <-c(prop.part(tree,check.labels = TRUE))