有没有办法获得“子树”来自 hclust ? (右)
我希望从 hclust 对象创建一个“子树”。
例如,假设我有以下对象:
a <- list() # initialize empty object
a$merge <- matrix(c(-1, -2,
-3, -4,
1, 2,
-5,-6,
3,4), nc=2, byrow=TRUE )
a$height <- c(1, 1.5, 3,4,4.5) # define merge heights
a$order <- 1:6 # order of leaves(trivial if hand-entered)
a$labels <- 1:6# LETTERS[1:4] # labels of leaves
class(a) <- "hclust" # make it an hclust object
plot(a) # look at the result
现在我希望从中提取以下子树:
a <- list() # initialize empty object
a$merge <- matrix(c(-1, -2,
-3, -4,
1, 2
), nc=2, byrow=TRUE )
a$height <- c(1, 1.5, 3) # define merge heights
a$order <- 1:4 # order of leaves(trivial if hand-entered)
a$labels <- 1:4# LETTERS[1:4] # labels of leaves
class(a) <- "hclust" # make it an hclust object
plot(a) # look at the result
我如何访问它?
(我知道 cutree 可以获取子树的对象,但不能创建实际的 hclust 对象)
感谢您的帮助,
Tal
I wish to create a "subtree" from an hclust object.
For example, let's say I have the following object:
a <- list() # initialize empty object
a$merge <- matrix(c(-1, -2,
-3, -4,
1, 2,
-5,-6,
3,4), nc=2, byrow=TRUE )
a$height <- c(1, 1.5, 3,4,4.5) # define merge heights
a$order <- 1:6 # order of leaves(trivial if hand-entered)
a$labels <- 1:6# LETTERS[1:4] # labels of leaves
class(a) <- "hclust" # make it an hclust object
plot(a) # look at the result
Now I wish the extract from it the following subtree:
a <- list() # initialize empty object
a$merge <- matrix(c(-1, -2,
-3, -4,
1, 2
), nc=2, byrow=TRUE )
a$height <- c(1, 1.5, 3) # define merge heights
a$order <- 1:4 # order of leaves(trivial if hand-entered)
a$labels <- 1:4# LETTERS[1:4] # labels of leaves
class(a) <- "hclust" # make it an hclust object
plot(a) # look at the result
How could I access it?
(I know that cutree could get me the objects of the sub tree, but not create an actual hclust object)
Thanks for any help,
Tal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否是您要寻找的,但您可以
Not sure this is what you're looking for, but you could
如果你有距离矩阵,那么你可能会做类似的事情:
If you have the distance matrix, then you might do something similar to this: