Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
';use.edge.length=FALSE';不';在phytools中使用plotBranchbyTrait()时,它似乎不起作用_R_Tree_Branch_Phylogeny - Fatal编程技术网

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

';use.edge.length=FALSE';不';在phytools中使用plotBranchbyTrait()时,它似乎不起作用,r,tree,branch,phylogeny,R,Tree,Branch,Phylogeny,我试图建立一个系统学,我编码的分支长度用颜色而不是长度来表示。所以我希望分支长度相等 这是我的密码: 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(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()
时,树仍然显示分支长度。有人知道如何解决这个问题吗?

不幸的是,可选参数
(…)
没有直接传递到
plotBranchbyTrait
函数中的
plot.phylo
。一种非优雅的修复方法是直接在R中修改主体,添加硬编码的
use.edge.length=FALSE
选项

您可以通过创建一个新函数并使用
body(foo)[[line\u of\u interest]]修改它来实现这一点
## 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)