R:ape/phylobase:无法将超度量、二叉树转换为 hclust 对象(警告消息)

发布于 2024-10-07 06:03:04 字数 1385 浏览 2 评论 0原文

我使用 ape 函数和 ape 包的 read.tree 函数在 R 中导入了 ClustalW2 树。我使用 chronopl 函数估计分子年龄,从而生成超量度二叉树。我想从中创建树状图对象中的 R 版本。

这棵树绘制得很好,是一个真正的系统对象。但是,我在尝试转换它时遇到了问题:

最小工作示例:

require(ape)
test.tree <- read.tree(file = "testree.phylip", text = NULL, tree.names = NULL, skip = 0,
    comment.char = "#", keep.multi = FALSE)

test.tree.nu <- chronopl(test.tree, 0, age.min = 1, age.max = NULL,
node = "root", S = 1, tol = 1e-8,
CV = FALSE, eval.max = 500, iter.max = 500)

is.ultrametric(test.tree.nu)
is.binary.tree(test.tree.nu)
treeclust <- as.hclust.phylo(test.tree.nu)

生成的树“看起来”很好, 我进行测试以确保该树不是超度量和二元的,并希望将其转换为 hclust 对象,最终使其成为树状图对象。

> is.binary.tree(test.tree.nu)
[1] TRUE
> is.ultrametric(test.tree.nu)
[1] TRUE

在尝试从树中创建 hclust 对象后,我收到一个错误:

> tree.phylo <- as.hclust.phylo(test.tree.nu)
Error in if (tmp <= n) -tmp else nm[tmp] : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In nm[inode] <- 1:N :
  number of items to replace is not a multiple of replacement length

我意识到这是一个非常详细的问题,也许与某些包特别相关的此类问题最好在其他地方提出,但我希望有人能够帮我。

非常感谢所有帮助,

问候,

文件下载

Phylip 文件可以在此处下载 http://www.box.net/shared/rnbdk973ja

I've imported a ClustalW2 tree in R using the ape function and read.tree function of the ape package. I estimate molecular ages using the chronopl function, resulting in a ultrametric, binary tree. From which I want to create a R build in dendrogram object.

The tree plots fine, and is a real phylo object. However i'm running into problems when trying to convert it:

Minimal Working Example:

require(ape)
test.tree <- read.tree(file = "testree.phylip", text = NULL, tree.names = NULL, skip = 0,
    comment.char = "#", keep.multi = FALSE)

test.tree.nu <- chronopl(test.tree, 0, age.min = 1, age.max = NULL,
node = "root", S = 1, tol = 1e-8,
CV = FALSE, eval.max = 500, iter.max = 500)

is.ultrametric(test.tree.nu)
is.binary.tree(test.tree.nu)
treeclust <- as.hclust.phylo(test.tree.nu)

The resulting tree "looks" fine,
I test to make sure the tree is not ultrametric and binary, and want to convert it into a hclust object, to make eventually a dendrogram object of it.

> is.binary.tree(test.tree.nu)
[1] TRUE
> is.ultrametric(test.tree.nu)
[1] TRUE

After trying to make a hclust object out of the tree, I get an error:

> tree.phylo <- as.hclust.phylo(test.tree.nu)
Error in if (tmp <= n) -tmp else nm[tmp] : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In nm[inode] <- 1:N :
  number of items to replace is not a multiple of replacement length

I realize this is a very detailed question, and perhaps such questions which are specifically related to certain packages are better asked somewhere else, but I hope someone is able to help me.

All help is much appreciated,

Regards,

File download

The Phylip file can be downloaded here
http://www.box.net/shared/rnbdk973ja

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥有 2024-10-14 06:03:04

我可以在 Linux 上的 R 2.12.1 beta (2010-12-07 r53808) 下使用 ape 2.6-2 版本重现此内容,但您的代码可以在 ape 2.5-3 版本中运行。

这表明程序包中已出现错误,您应该将该问题告知开发人员以寻求专家建议。维护者 Emmanuel Paradis 的电子邮件地址位于 ape 的 CRAN 包上

I can reproduce this with version 2.6-2 of ape under R 2.12.1 beta (2010-12-07 r53808) on Linux, but your code works in version 2.5-3 of ape.

This would suggest a bug has crept into the package and you should inform the developers of the problem to ask for expert advice. The email address of the maintainer, Emmanuel Paradis, is on the CRAN package for ape

穿透光 2024-10-14 06:03:04

看起来问题是 chronopl 返回一棵树,它要么是无根的,要么是具有多分叉的根(取决于它的解释方式)。另外 as.hclust.phylo 也有无用的错误消息。

这:

modded.tree <- drop.tip(test.tree.nu,c(
'An16g06590','An02g12505','An11g00390','An14g01130'))

删除从根部下降的三个进化枝之一的所有提示,因此

is.ultrametric(modded.tree)
is.binary.tree(modded.tree)
is.rooted(modded.tree)

所有提示都返回 TRUE,您可以这样做

treeclust <- as.hclust.phylo(modded.tree)

。尽管我认为您确实想要一个代表多分叉树的 hclust 对象,并且尽管 hclust 对象可以处理这些对象,但 as.hclust.phylo (来自包“ape”)由于某种原因不适用于多分叉。如果您知道一种将 newick 文件导入 hclust 对象的方法,这可能是一种前进的方法 - ade 有 write.tree() 来生成 newick 文件。

looks like the problem is that chronopl returns a tree which is either unrooted, or has a multifurcating root (depending on how it's interpreted). Also as.hclust.phylo has/had unhelpful error messages.

This:

modded.tree <- drop.tip(test.tree.nu,c(
'An16g06590','An02g12505','An11g00390','An14g01130'))

removes all tips from one of the three clades descending from the root, thus

is.ultrametric(modded.tree)
is.binary.tree(modded.tree)
is.rooted(modded.tree)

all return TRUE, and you can do

treeclust <- as.hclust.phylo(modded.tree)

. Though I think you really want an hclust object representing the multifurcating tree, and though hclust objects can handle those, as.hclust.phylo (from package 'ape') doesn't work on multifurcations for some reason. If you know a way to import newick files into hclust objects, that might be a way forward - ade has write.tree() to generate newick files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文