-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Description
hi there,
I'd like to show in tree in equal_angle layout, and use geom_tippoint to annotate certain tips. I have several annotations I want to show, so I have several geom_tippoint layers and I'm trying to move each new set further out from the branch tip.
That works fine when the tree layout is rectangular or circular, but when I use equal_angle the outer annotations aren't aligned with the branches. There's a reprex below.
Is there are different way to do this that I'm missing? Or is the code not working as intended for this?
Thanks very much!
Janet Young
Fred Hutchinson Cancer Center
library(ggplot2)
library(ggtree)
#> ggtree v4.0.1 Learn more at https://yulab-smu.top/contribution-tree-data/
#>
#> Please cite:
#>
#> Shuangbin Xu, Lin Li, Xiao Luo, Meijun Chen, Wenli Tang, Li Zhan, Zehan
#> Dai, Tommy T. Lam, Yi Guan, Guangchuang Yu. Ggtree: A serialized data
#> object for visualization of a phylogenetic tree and annotation data.
#> iMeta 2022, 1(4):e56. doi:10.1002/imt2.56
nwk_file <- system.file("extdata/sample.nwk", package="treeio")
nwk_tree <- read.tree( nwk_file )
## rectangular - looks good
p1 <- nwk_tree %>%
ggtree(layout = "rectangular") +
geom_tippoint(size=0.75) +
geom_tippoint(aes(x=x+3), size=0.5, color="blue") +
labs(title="rectangular")
## circular - looks good
p2 <- nwk_tree %>%
ggtree(layout="circular") +
geom_tippoint(size=0.75) +
geom_tippoint(aes(x=x+5), size=0.5, color="blue") +
labs(title="circular")
## equal_angle - the blue and red points aren't lined up with the branches - I try adding or multiplying but neither looks right
p3 <- nwk_tree %>%
ggtree(layout="equal_angle") +
geom_tippoint(size=0.75) +
geom_tippoint(aes(x=x+5), size=0.5, color="blue", alpha=0.5) +
geom_tippoint(aes(x=x*1.1), size=0.5, color="red", alpha=0.5) +
labs(title="equal_angle")
p1 + p2 + p3
## p2 (the circular layout) generates the warnings - they already reported here https://github.com/YuLab-SMU/ggtree/issues/683
#> Warning: Unknown or uninitialised column: `subgroup`.
#> Unknown or uninitialised column: `subgroup`.
#> Unknown or uninitialised column: `subgroup`.
#> Unknown or uninitialised column: `subgroup`.sessionInfo()
#> R version 4.5.2 (2025-10-31)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS Tahoe 26.1
#>
#> Matrix products: default
#> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> time zone: America/Los_Angeles
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ggtree_4.0.1 ggplot2_4.0.1
#>
#> loaded via a namespace (and not attached):
#> [1] yulab.utils_0.2.2 rappdirs_0.3.3 generics_0.1.4
#> [4] tidyr_1.3.1 fontLiberation_0.1.0 ggplotify_0.1.3
#> [7] lattice_0.22-7 digest_0.6.39 magrittr_2.0.4
#> [10] evaluate_1.0.5 grid_4.5.2 RColorBrewer_1.1-3
#> [13] fastmap_1.2.0 jsonlite_2.0.0 ape_5.8-1
#> [16] purrr_1.2.0 aplot_0.2.9 scales_1.4.0
#> [19] fontBitstreamVera_0.1.1 lazyeval_0.2.2 cli_3.6.5
#> [22] rlang_1.1.6 fontquiver_0.2.1 tidytree_0.4.6
#> [25] reprex_2.1.1 withr_3.0.2 yaml_2.3.11
#> [28] gdtools_0.4.4 tools_4.5.2 parallel_4.5.2
#> [31] dplyr_1.1.4 vctrs_0.6.5 R6_2.6.1
#> [34] gridGraphics_0.5-1 lifecycle_1.0.4 htmlwidgets_1.6.4
#> [37] fs_1.6.6 ggfun_0.2.0 treeio_1.34.0
#> [40] pkgconfig_2.0.3 pillar_1.11.1 gtable_0.3.6
#> [43] glue_1.8.0 Rcpp_1.1.0 systemfonts_1.3.1
#> [46] xfun_0.54 tibble_3.3.0 tidyselect_1.2.1
#> [49] rstudioapi_0.17.1 ggiraph_0.9.2 knitr_1.50
#> [52] farver_2.1.2 htmltools_0.5.8.1 nlme_3.1-168
#> [55] patchwork_1.3.2 labeling_0.4.3 rmarkdown_2.30
#> [58] compiler_4.5.2 S7_0.2.1Created on 2025-12-03 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels
