R ggtree:如何用 ggtree 标记单个树尖类似于用 geom_cladelabel 标记节点
R ggtree: How to label single tree tip with ggtree similar to labeling nodes with geom_cladelabel
我在使用 ggtree 标记树中的单个提示时遇到问题。我正在尝试使用 geom_hilight 和 geom_cladelabel 突出显示和标记树中的节点。这似乎适用于具有超过 1 个树尖的节点,但是当我尝试标记单个树尖时,我收到一条警告消息并且树尖没有被标记。
示例:
library(dplyr)
library(ggtree)
library(dplyr)
library(ggtree)
#Create tree
set.seed(123)
tree <- rtree(30)
ggtree(tree)
#Highlight and label clade
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
如您所见,我可以使用 geom_hilight 突出显示节点 38 和 3。我还用文本 "Clade 2" 和 geom_cladelabel 标记了节点 38。
但是,当我尝试用 geom_cladelabel 标记节点 3 时,我收到一条警告消息:
#Highlight and label single tip
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=3, label="clade 1", align=T,
color='black', fontsize=4) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
Warning messages:
1: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
2: In min(y) : no non-missing arguments to min; returning Inf
3: In max(y) : no non-missing arguments to max; returning -Inf
4: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
5: In min(y) : no non-missing arguments to min; returning Inf
6: In max(y) : no non-missing arguments to max; returning -Inf
出于某种原因,来自进化枝标签的线最终覆盖了整棵树:
有没有一种方法可以像 clade_geomlabel 对常规节点所做的那样标记单个提示?
感谢任何帮助。
这不是真正的答案,但希望能帮助您解决问题,因为我没有得到错误。请参阅下面的代码、情节和会话信息。似乎错误来自 clade_functions.R。我首先要尝试的是检查 tidyr 和 tidytree 包,这部分似乎严重依赖于此。
library(dplyr)
library(ggtree)
#Create tree
set.seed(123)
tree <- rtree(30)
ggtree(tree)
ggtree(tree) + geom_text(aes(label=node)) +
geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=3, label="clade 1", align=T,
color='black', fontsize=2) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=2)
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[2] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[2] stats graphics grDevices utils datasets methods base
other attached packages:
[2] ggtree_1.16.6 dplyr_0.8.3
loaded via a namespace (and not attached):
[2] Rcpp_1.0.2 magrittr_1.5 tidyselect_0.2.5
[4] munsell_0.5.0 colorspace_1.4-1 ape_5.3
[7] lattice_0.20-38 R6_2.4.0 rlang_0.4.1
[10] parallel_3.6.1 grid_3.6.1 nlme_3.1-140
[13] gtable_0.3.0 lazyeval_0.2.2 assertthat_0.2.1
[16] lifecycle_0.1.0 tibble_2.1.3 crayon_1.3.4
[19] treeio_1.8.2 BiocManager_1.30.10 purrr_0.3.3
[22] ggplot2_3.2.1 tidyr_1.0.0 vctrs_0.2.0
[25] zeallot_0.1.0 tidytree_0.3.2 glue_1.3.1
[28] labeling_0.3 compiler_3.6.1 pillar_1.4.2
[31] backports_1.1.5 rvcheck_0.1.5 scales_1.0.0
[34] jsonlite_1.6 pkgconfig_2.0.3
我在使用 ggtree 标记树中的单个提示时遇到问题。我正在尝试使用 geom_hilight 和 geom_cladelabel 突出显示和标记树中的节点。这似乎适用于具有超过 1 个树尖的节点,但是当我尝试标记单个树尖时,我收到一条警告消息并且树尖没有被标记。
示例:
library(dplyr)
library(ggtree)
library(dplyr)
library(ggtree)
#Create tree
set.seed(123)
tree <- rtree(30)
ggtree(tree)
#Highlight and label clade
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
如您所见,我可以使用 geom_hilight 突出显示节点 38 和 3。我还用文本 "Clade 2" 和 geom_cladelabel 标记了节点 38。
但是,当我尝试用 geom_cladelabel 标记节点 3 时,我收到一条警告消息:
#Highlight and label single tip
ggtree(tree) + geom_text(aes(label=node)) + geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=3, label="clade 1", align=T,
color='black', fontsize=4) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=4)
Warning messages:
1: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
2: In min(y) : no non-missing arguments to min; returning Inf
3: In max(y) : no non-missing arguments to max; returning -Inf
4: In max(sp.df$x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
5: In min(y) : no non-missing arguments to min; returning Inf
6: In max(y) : no non-missing arguments to max; returning -Inf
出于某种原因,来自进化枝标签的线最终覆盖了整棵树:
有没有一种方法可以像 clade_geomlabel 对常规节点所做的那样标记单个提示?
感谢任何帮助。
这不是真正的答案,但希望能帮助您解决问题,因为我没有得到错误。请参阅下面的代码、情节和会话信息。似乎错误来自 clade_functions.R。我首先要尝试的是检查 tidyr 和 tidytree 包,这部分似乎严重依赖于此。
library(dplyr)
library(ggtree)
#Create tree
set.seed(123)
tree <- rtree(30)
ggtree(tree)
ggtree(tree) + geom_text(aes(label=node)) +
geom_tiplab(size=3, offset=0.1) +
geom_hilight(node=3, fill="steelblue", alpha=0.5) +
geom_hilight(node=38, fill="pink", alpha=0.5) +
geom_cladelabel(node=3, label="clade 1", align=T,
color='black', fontsize=2) +
geom_cladelabel(node=38, label="clade 2", align=T,
color='black', fontsize=2)
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[2] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[2] stats graphics grDevices utils datasets methods base
other attached packages:
[2] ggtree_1.16.6 dplyr_0.8.3
loaded via a namespace (and not attached):
[2] Rcpp_1.0.2 magrittr_1.5 tidyselect_0.2.5
[4] munsell_0.5.0 colorspace_1.4-1 ape_5.3
[7] lattice_0.20-38 R6_2.4.0 rlang_0.4.1
[10] parallel_3.6.1 grid_3.6.1 nlme_3.1-140
[13] gtable_0.3.0 lazyeval_0.2.2 assertthat_0.2.1
[16] lifecycle_0.1.0 tibble_2.1.3 crayon_1.3.4
[19] treeio_1.8.2 BiocManager_1.30.10 purrr_0.3.3
[22] ggplot2_3.2.1 tidyr_1.0.0 vctrs_0.2.0
[25] zeallot_0.1.0 tidytree_0.3.2 glue_1.3.1
[28] labeling_0.3 compiler_3.6.1 pillar_1.4.2
[31] backports_1.1.5 rvcheck_0.1.5 scales_1.0.0
[34] jsonlite_1.6 pkgconfig_2.0.3