- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 Interactive Tree of Life web-based tool (iTOL) 制作一棵树(簇)。作为输入文件(或字符串),此工具使用 Newick format,这是一种使用括号和逗号表示边长的图论树的方法。除此之外,可能还支持其他信息,例如集群节点的 引导值 。
例如,这里我使用 clusterGeneration
包为聚类分析创建了数据集:
library(clusterGeneration)
set.seed(1)
tmp1 <- genRandomClust(numClust=3, sepVal=0.3, numNonNoisy=5,
numNoisy=3, numOutlier=5, numReplicate=2, fileName="chk1")
data <- tmp1$datList[[2]]
pvclust
包通过 bootstrap 执行集群分析并评估对集群节点的支持:
set.seed(2)
y <- pvclust(data=data,method.hclust="average",method.dist="correlation",nboot=100)
plot(y)
ape
包:
library(ape)
yy<-as.phylo(y$hclust)
write.tree(yy,digits=2)
write.tree
函数将以 Newick 格式打印树:
(round(y$edges,2)*100)[,1:2]
yy$edge.length
write.tree
函数在调试后是如何工作的。但是,我注意到它在内部调用函数 .write.tree2
并且我无法理解如何有效地更改原始代码并在 Newick 文件中的适当位置获取引导值。最佳答案
这是适合您的一种解决方案:类 phylo
的对象有一个名为 node.label
的可用插槽这适本地为您提供了节点的标签。您可以使用它来存储引导值。正如您在 .write.tree2
的代码中看到的那样,将在您的 Newick 文件中的适当位置写入。 :
> .write.tree2
function (phy, digits = 10, tree.prefix = "")
{
brl <- !is.null(phy$edge.length)
nodelab <- !is.null(phy$node.label)
...
if (is.null(phy$root.edge)) {
cp(")")
if (nodelab)
cp(phy$node.label[1])
cp(";")
}
else {
cp(")")
if (nodelab)
cp(phy$node.label[1])
cp(":")
cp(sprintf(f.d, phy$root.edge))
cp(";")
}
...
hclust
的对象转换期间获取该信息。到类
phylo
的对象.
as.phylo.hclust
,有一个向量包含节点索引的正确顺序相对于前一个
hclust
目的:
> as.phylo.hclust
function (x, ...)
{
N <- dim(x$merge)[1]
edge <- matrix(0L, 2 * N, 2)
edge.length <- numeric(2 * N)
node <- integer(N) #<-This one
...
as.phylo.hclust
与
nodenames
参数只要与
hclust
中的节点顺序相同即可对象(在您的示例中就是这种情况,因为
pvclust
在内部保持一致的顺序,即 hclust 中节点的顺序与您选择 bootstrap 的表中的顺序相同):
# NB: in the following function definition I only modified the commented lines
as.phylo.hclust.with.nodenames <- function (x, nodenames, ...) #We add a nodenames argument
{
N <- dim(x$merge)[1]
edge <- matrix(0L, 2 * N, 2)
edge.length <- numeric(2 * N)
node <- integer(N)
node[N] <- N + 2L
cur.nod <- N + 3L
j <- 1L
for (i in N:1) {
edge[j:(j + 1), 1] <- node[i]
for (l in 1:2) {
k <- j + l - 1L
y <- x$merge[i, l]
if (y > 0) {
edge[k, 2] <- node[y] <- cur.nod
cur.nod <- cur.nod + 1L
edge.length[k] <- x$height[i] - x$height[y]
}
else {
edge[k, 2] <- -y
edge.length[k] <- x$height[i]
}
}
j <- j + 2L
}
if (is.null(x$labels))
x$labels <- as.character(1:(N + 1))
node.lab <- nodenames[order(node)] #Here we define our node labels
obj <- list(edge = edge, edge.length = edge.length/2, tip.label = x$labels,
Nnode = N, node.label = node.lab) #And you put them in the final object
class(obj) <- "phylo"
reorder(obj)
}
bootstraps <- (round(y$edges,2)*100)[,1:2]
yy<-as.phylo.hclust.with.nodenames(y$hclust, nodenames=bootstraps[,2])
write.tree(yy,tree.names=TRUE,digits=2)
[1] "((x5:0.27,x8:0.27)100:0.24,((x7:0.25,(x4:0.14,(x1:0.13,x3:0.13)61:0.014)99:0.11)100:0.23,(x2:0.46,x6:0.46)56:0.022)61:0.027)100;"
#See the bootstraps ^^^ here for instance
plot(yy,show.node.label=TRUE) #To show that the order is correct
plot(y) #To compare with (here I used the yellow value)
关于r - 如何在 R 中以 NEWICK 格式附加集群(树)节点的引导值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22749634/
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我通过读取 FASTA 文件创建了一个距离矩阵,现在我被要求编写一个函数来生成 newick 字符串格式的系统发育树。该函数将采用一个参数作为距离矩阵。你能帮我一些代码开始吗? 格式示例: 打印(up
如何将 scipy 生成的树状图保存到 Newick format 中? 最佳答案 您需要链接矩阵 Z,它是 scipy 树状图函数的输入,并将其转换为 Newick 格式。此外,您需要一个包含叶子名
如何为给定外群的一组物种生成所有可能的 Newick 树排列? 对于那些不知道 Newick 树格式是什么的人,可以在以下位置找到很好的描述: https://en.wikipedia.org/wik
有谁知道我可以用来轻松解析 Newick 文件的优秀 Java 库吗?或者如果您有一些经过测试的源代码我可以使用? 我想读取 newick 文件:http://en.wikipedia.org/wik
我有一个像这样的字符串: (A\2009_2009-01-04:0.2,(A\name2\human\2007_2007:0.3,A\chicken\ird16\2016_20016:0.4)A\na
我在 networkx 中创建了一个图并获取了它的 bfs 树。 G = nx.Graph() # build a graph tree = nx.bfs_tree(G, '1') 现在我想把树保存在
所以我有一个 csv 文件,其中每一行代表以下形式的分层数据:'门','类','目','科','属','种','亚种','unique_gi' 我想将其转换为经典 Newick tree format
我正在为我正在从事的项目构建一个语法来使用 ParseKit 解析 Newick 树,我已经走到这一步了。它基于此处的语法:http://en.wikipedia.org/wiki/Newick_fo
我在 python 中有一个列表,其中包含一个项目,它是以 Newick 格式编写的树,如下所示: ['(BMNH833953:0.16529463651919140688,(((BMNH833883
我在将二叉树转换为 newick 格式时遇到问题。这种格式的完整解释可以找到: http://code.google.com/p/mrsrf/wiki/NewickTree newick 格式的示例如
我想将 newick 的树转换为像 graphml 这样的格式,我可以用 cytoscape 打开它。 所以,我有一个文件“small.newick”,其中包含: ((raccoon:1,bear:6
我有一组基因,它们已根据 DNA 序列进行比对和聚类,并且我在 Newick 树表示中有这组基因 (https://en.wikipedia.org/wiki/Newick_format)。有谁知道如
我正在尝试使用 boost::spirit 库解析 Newick 语法(定义为 here)。 我已经制作了自己的解析器,可以正确识别语法。这是代码: #define BOOST_SPIRIT_DEBU
我想使用 Interactive Tree of Life web-based tool (iTOL) 制作一棵树(簇)。作为输入文件(或字符串),此工具使用 Newick format,这是一种使用
我正在尝试弄清楚如何读取许多动物物种的 Newick 文件,但我一直无法找到一种“逻辑方法/过程”来用简单的编程语言对 Newick 字符串进行排序。我可以阅读 C#、AS、JS、GLSL 和 HLS
我有一个通过运行创建的向量列表: import hcluster import numpy as np from ete2 import Tree vecs = [np.array(i) for i
我是一名优秀的程序员,十分优秀!