YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
833 stars 173 forks source link

clone the plot environment before assigning layout #516

Closed xiangpin closed 2 years ago

xiangpin commented 2 years ago

original

> library(ggtree)
ggtree v3.4.1 For help: https://yulab-smu.top/treedata-book/

If you use the ggtree package suite in published research, please cite
the appropriate paper(s):

Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam.
ggtree: an R package for visualization and annotation of phylogenetic
trees with their covariates and other associated data. Methods in
Ecology and Evolution. 2017, 8(1):28-36. doi:10.1111/2041-210X.12628

S Xu, Z Dai, P Guo, X Fu, S Liu, L Zhou, W Tang, T Feng, M Chen, L
Zhan, T Wu, E Hu, Y Jiang, X Bo, G Yu. ggtreeExtra: Compact
visualization of richly annotated phylogenetic data. Molecular Biology
and Evolution. 2021, 38(9):4039-4042. doi: 10.1093/molbev/msab166

Guangchuang Yu. Using ggtree to visualize data on tree-like structures.
Current Protocols in Bioinformatics. 2020, 69:e96. doi:10.1002/cpbi.96

> set.seed(123)
> tr <- rtree(66)
> p <- ggtree(tr)
> f <- p + layout_circular()
Scale for 'y' is already present. Adding another scale for 'y', which will
replace the existing scale.
> p$plot_env$layout
[1] "circular"
> f$plot_env$layout
[1] "circular"
> plot_list(p + geom_tiplab(), f + geom_tiplab())

xx

The p should be rectangular

This request

> library(ggtree)
ggtree v3.5.1.901 For help:
https://yulab-smu.top/treedata-book/

If you use the ggtree package suite in published research, please cite
the appropriate paper(s):

Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam.
ggtree: an R package for visualization and annotation of phylogenetic
trees with their covariates and other associated data. Methods in
Ecology and Evolution. 2017, 8(1):28-36. doi:10.1111/2041-210X.12628

Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods
for mapping and visualizing associated data on phylogeny using ggtree.
Molecular Biology and Evolution. 2018, 35(12):3041-3043.
doi:10.1093/molbev/msy194

LG Wang, TTY Lam, S Xu, Z Dai, L Zhou, T Feng, P Guo, CW Dunn, BR
Jones, T Bradley, H Zhu, Y Guan, Y Jiang, G Yu. treeio: an R package
for phylogenetic tree input and output with richly annotated and
associated data. Molecular Biology and Evolution. 2020, 37(2):599-603.
doi: 10.1093/molbev/msz240
> set.seed(123)
> tr <- rtree(66)
> p <- ggtree(tr)
> f <- p + layout_circular()
Scale for 'y' is already present. Adding another scale for 'y', which will
replace the existing scale.
> get('layout', p$plot_env)
[1] "rectangular"
> get('layout', f$plot_env)
[1] "circular"
> plot_list(p+geom_tiplab(), f+geom_tiplab())

xx1