首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在phytools中使用plotBranchbyTrait()时,'use.edge.length = FALSE‘似乎不起作用

在phytools中使用plotBranchbyTrait()时,'use.edge.length = FALSE‘似乎不起作用
EN

Stack Overflow用户
提问于 2018-06-22 20:54:12
回答 1查看 395关注 0票数 2

我正在尝试创建一个系统发展史,其中我编码的分支长度是用颜色而不是长度表示的。所以我希望分支长度相等。

下面是我的代码:

代码语言:javascript
复制
plotBranchbyTrait(tree.scaled, tree.scaled$edge.length, mode=c("edges"),palette="rainbow", use.edge.length = FALSE, node.depth = 2)

我的理解是,use.edge.length = FALSE应该使分支长度相等,如果我使用plot.phylo()对树进行编码,它就会这样做。但是,当我使用plotBranchbyTrait()时,树仍然显示分支长度。有人知道怎么解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2018-06-25 13:28:13

不幸的是,在plotBranchbyTrait函数中,可选参数(...)不会直接传递给plot.phylo。解决这个问题的一种不太好的方法是直接在R中修改主体,添加一个硬编码的use.edge.length = FALSE选项。

您可以通过创建一个新函数并使用body(foo)[[line_of_interest]] <- substitute(my_new_line <- that_does_something)修改它来完成此操作。下面的示例应该可以工作:

代码语言:javascript
复制
## Back up the function
plotBranchbyTrait_no_edge_length <- phytools::plotBranchbyTrait

## The line to modify:
body(plotBranchbyTrait_no_edge_length)[[34]]
# xx <- plot.phylo(tree, type = type, show.tip.label = show.tip.label, 
#    show.node.label = show.node.label, edge.color = colors, edge.width = edge.width, 
#    edge.lty = edge.lty, font = font, cex = cex, adj = adj, srt = srt, 
#    no.margin = no.margin, root.edge = root.edge, label.offset = label.offset, 
#    underscore = underscore, x.lim = x.lim, y.lim = y.lim, direction = direction, 
#    lab4ut = lab4ut, tip.color = tip.color, plot = plot, rotate.tree = rotate.tree, 
#    open.angle = open.angle, lend = 2, new = FALSE)


## Modify the line 34 by adding `use.edge.length = FALSE`
body(plotBranchbyTrait_no_edge_length)[[34]] <- substitute( xx <- plot.phylo(use.edge.length = FALSE, tree, type = type, show.tip.label = show.tip.label, show.node.label = show.node.label, edge.color = colors, edge.width = edge.width,  edge.lty = edge.lty, font = font, cex = cex, adj = adj, srt = srt, no.margin = no.margin, root.edge = root.edge, label.offset = label.offset, underscore = underscore, x.lim = x.lim, y.lim = y.lim, direction = direction, lab4ut = lab4ut, tip.color = tip.color, plot = plot, rotate.tree = rotate.tree, open.angle = open.angle, lend = 2, new = FALSE) )

## Testing whether it worked
library(phytools)
tree <- pbtree(n=50)
x <- fastBM(tree)
## With use.edge.length = TRUE (default)
plotBranchbyTrait(tree, x, mode = "tips", edge.width = 4, prompt = FALSE)

## With use.edge.length = FALSE
plotBranchbyTrait_no_edge_length(tree, x, mode = "tips", edge.width = 4, prompt = FALSE)

您可以找到有关如何修改函数here的更多信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50988405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档