YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

fix a bug in read.nhx when the string of metadata contains the character and numeric simultaneously #97

Closed xiangpin closed 1 year ago

xiangpin commented 1 year ago

Description

when the string of metadata contains the character and numeric simultaneously in nhx format tree file. The related metadata will not be processed well.

Related Issue

96

Example

> library(ggtree)
ggtree v3.8.0 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

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
> library(ggplot2)
> library(treeio)
treeio v1.23.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):

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

Guangchuang Yu.  Data Integration, Manipulation and Visualization of
Phylogenetic Trees (1st edition). Chapman and Hall/CRC. 2022,
doi:10.1201/9781003279242

G Yu. Data Integration, Manipulation and Visualization of Phylogenetic
Trees (1st ed.). Chapman and Hall/CRC. 2022. ISBN: 9781032233574
>
> treetext = "((((T0201:11.5[&&NHX],T0104:4.5[&&NHX]):1[&&NHX],
  T0103:5.5[&&NHX]):0.5[&&NHX], T0106:3[&&NHX], T0107:2[&&NHX]):1[&&NHX],
  T0102:7[&&NHX], (T0302:3[&&NHX],T0301:4[&&NHX]):1[&&NHX:S=GRIN2A Loss])[&&NHX];"
>
> tree <- read.nhx(textConnection(treetext))
> ggtree(tree, layout='ellipse') + geom_tiplab() +
  geom_label(aes(x=branch, label=S), fill='lightgreen')

捕获