r - 如何让 plot.cophylo 忽略缺失值(NA)?
问题描述
我想绘制一个 cophylo 对象,但是其中一个分支有一个缺失值,因此 cophylo 没有正确绘制。
如何更改值或绘制没有分支长度的树?
解决方案
我无法重现该示例,并且该cophylo()
函数似乎可以很好地处理丢失的数据。
library(phytools)
#> Loading required package: ape
#> Loading required package: maps
set.seed(12345)
tr1<-pbtree(n=22,tip.label=c(1:22))
tr2<-pbtree(n=10,tip.label=c(1:10))
obj<-cophylo(tr1,tr2)
#> Rotating nodes to optimize matching...
#> Done.
plot(obj)
编辑
问题是关于缺少分支长度。首先,这对我来说似乎很可疑,因为缺少分支长度似乎没有意义。但是,现在可以重现该问题。也许您的 NA 实际上是值 0?
# Now with missing value --> Indeed it doesn't plot
tr1$edge.length[2] <- NA
obj<-cophylo(tr1,tr2)
#> Rotating nodes to optimize matching...
#> Done.
plot(obj)
# Replace NA value with 0? (I am not sure if this makes sense)
tr1$edge.length[2] <- 0
obj<-cophylo(tr1,tr2)
#> Rotating nodes to optimize matching...
#> Done.
plot(obj)
编辑 2
问题在于阅读 Newick 文件。特别是,OP 在名称中使用了不允许的字符(例如':')。
由reprex 包(v0.3.0)于 2020 年 10 月 26 日创建
推荐阅读
- javascript - 从嵌入对象 DiscordJS 中删除 1 个元素
- jquery - 带有jquery的动态形式的ckeditor问题
- monitoring - Splunk 面板显示特定时间范围的图表
- javascript - NetworkError:无法在“XMLHttpRequest”上执行“发送”:加载失败,wcf-mssql-L4 开关
- excel - 如何将特定工作表作为 csv 附加到电子邮件中?
- reactjs - 无法使用 React AceEditor 编辑文本
- c# - 以编程方式选择 TabControl 中的现有 TabPage 会显示一个空白页
- html - 如何让超链接跳转到同一页面的指定位置?
- excel - 在“新”文件->另存为用户界面上将默认设置为 xlsm,用于特定模板
- r - 多列的中位数开始 Start_With 相同的字母?