> library(ggtree)
Registered S3 method overwritten by 'treeio':
method from
root.phylo ape
ggtree v2.4.0 For help: https://yulab-smu.github.io/treedata-book/
If you use ggtree in published research, please cite the most appropriate paper(s):
- Guangchuang Yu. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics, 2020, 69:e96. doi:10.1002/cpbi.96
- 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
- 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
> library(treeio)
treeio v1.14.0 For help: https://yulab-smu.github.io/treedata-book/
If you use treeio in published research, please cite:
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
> treetext = "(((((((((((((Pseudechis_porphyriacus:18.6[&&NHX:S=0.0],Pseudechis_australis:18.6[&&NHX:S=0.0])Node14:0[&&NHX:S=0.99858],Oxyuranus_scutellatus:18.6[&&NHX:S=0.0])Node13:9[&&NHX:S=0.0],(Notechis_scutatus:9.58011[&&NHX:S=0.0],Austrelaps_superbus:9.58011[&&NHX:S=0.0])Node15:18.0199[&&NHX:S=0.0])Node12:0[&&NHX:S=0.0],((Drysdalia_coronoides:16.8136[&&NHX:S=0.0],Tropidechis_carinatus:16.8136[&&NHX:S=0.0])Node17:3.58639[&&NHX:S=0.0],Demansia_vestigiata:20.4[&&NHX:S=1.01894])Node16:7.2[&&NHX:S=0.0])Node11:5.11006[&&NHX:S=0.9363],Bungarus_candidus:32.7101[&&NHX:S=0.0])Node10:2.28994[&&NHX:S=0.0],((Naja_kaouthia:13.6149[&&NHX:S=0.0],Naja_atra:13.6149[&&NHX:S=0.00018])Node19:21.3851[&&NHX:S=0.01668],Ophiophagus_hannah:35[&&NHX:S=0.0])Node18:0[&&NHX:S=0.22436])Node9:0[&&NHX:S=0.77398],Hydrophis_elegans:35[&&NHX:S=0.0])Node8:11.4[&&NHX:S=2.02488],Leioheterodon_madagascariensis:46.4[&&NHX:S=0.15232])Node7:4.99311[&&NHX:S=0.0],(((Trimorphodon_biscutatus:37.078[&&NHX:S=0.9997],Dispholidus_typus:37.078[&&NHX:S=0.3146])Node22:10.522[&&NHX:S=0.0],Thamnophis_sirtalis:47.6[&&NHX:S=0.40902])Node21:0[&&NHX:S=0.0],(Philodryas_olfersii:33.4144[&&NHX:S=0.0],Erythrolamprus_poecilogyrus:33.4144[&&NHX:S=0.92616])Node23:14.1856[&&NHX:S=0.9886])Node20:3.79311[&&NHX:S=0.0])Node6:2.64135[&&NHX:S=0.0],(Cerberus_rynchops:21.6599[&&NHX:S=0.0],Pseudoferania_polylepis:21.6599[&&NHX:S=0.0])Node24:32.3745[&&NHX:S=0.92132])Node5:7.70362[&&NHX:S=0.0],((((((((((((Crotalus_adamanteus:6.62685[&&NHX:S=0.01158],Crotalus_oreganus:6.62685[&&NHX:S=0.01308])Node36:1.30638[&&NHX:S=0.0],Crotalus_atrox:7.93323[&&NHX:S=0.0])Node35:2.78789[&&NHX:S=0.0],Crotalus_horridus:10.7211[&&NHX:S=0.00018])Node34:1.76023[&&NHX:S=0.0],Sistrurus_catenatus:12.4813[&&NHX:S=0.00018])Node33:4.48308[&&NHX:S=0.0],Agkistrodon_piscivorus:16.9644[&&NHX:S=0.0])Node32:1.83013[&&NHX:S=0.0],Gloydius_blomhoffii:18.7946[&&NHX:S=0.01244])Node31:4.71982[&&NHX:S=0.0],Cerrophidion_godmani:23.5144[&&NHX:S=0.0])Node30:5.00284[&&NHX:S=0.0],(Trimeresurus_gracilis:27.4244[&&NHX:S=1.9792],Trimeresurus_stejnegeri:27.4244[&&NHX:S=0.0])Node37:1.09278[&&NHX:S=0.0])Node29:0.997358[&&NHX:S=0.0],((Protobothrops_flavoviridis:11.4324[&&NHX:S=0.0],Protobothrops_jerdonii:11.4324[&&NHX:S=0.0])Node39:15.634[&&NHX:S=0.0],Bothriechis_schlegelii:27.0664[&&NHX:S=0.0])Node38:2.44818[&&NHX:S=0.0])Node28:9.28542[&&NHX:S=0.0],Deinagkistrodon_acutus:38.8[&&NHX:S=0.00554])Node27:0[&&NHX:S=0.99944],Azemiops_feae:38.8[&&NHX:S=0.0])Node26:3.44041[&&NHX:S=0.00434],(((Vipera_nikolskii:1.79421[&&NHX:S=0.0],Vipera_berus:1.79421[&&NHX:S=0.0])Node42:15.6876[&&NHX:S=0.0],Daboia_russelii:17.4818[&&NHX:S=0.00018])Node41:18.3836[&&NHX:S=0.00142],Atheris_nitschei:35.8654[&&NHX:S=0.00572])Node40:6.37503[&&NHX:S=0.01222])Node25:19.4977[&&NHX:S=0.7494])Node4:29.0619[&&NHX:S=1.01654],Python_sebae:90.8[&&NHX:S=0.2437])Node3:76.3242[&&NHX:S=1.56558],((((((Varanus_gouldii:9.51234[&&NHX:S=0.00018],Varanus_panoptes:9.51234[&&NHX:S=0.0])Node48:8.49911[&&NHX:S=0.0],Varanus_mertensi:18.0115[&&NHX:S=0.0])Node47:7.23287[&&NHX:S=0.0],Varanus_komodoensis:25.2443[&&NHX:S=0.00018])Node46:7.34712[&&NHX:S=0.02314],((Varanus_acanthurus:21.2387[&&NHX:S=0.386],Varanus_gilleni:21.2387[&&NHX:S=0.0])Node50:3.96576[&&NHX:S=0.00018],Varanus_scalaris:25.2045[&&NHX:S=0.0])Node49:7.38697[&&NHX:S=0.9833])Node45:98.543[&&NHX:S=1.09066],((Gerrhonotus_infernalis:61.5[&&NHX:S=0.71362],Celestus_haetianus:61.5[&&NHX:S=2.45308])Node52:43.0535[&&NHX:S=0.02242],(Heloderma_suspectum:21.6925[&&NHX:S=0.0],Heloderma_horridum:21.6925[&&NHX:S=0.0])Node53:82.861[&&NHX:S=0.38274])Node51:26.5809[&&NHX:S=0.0])Node44:34.0946[&&NHX:S=1.16122],Anolis_carolinensis:165.229[&&NHX:S=0.31326])Node43:1.89509[&&NHX:S=0.4398]);"
> tree <- read.nhx(textConnection(treetext))
Error in `$<-.data.frame`(`*tmp*`, "node", value = c(1L, 2L, 66L, 3L, :
replacement has 105 rows, data has 104
> ggtree(tree) + geom_tiplab() +
+ geom_label(aes(x=branch, label=S), fill='lightgreen') +
+ geom_text(aes(label=S), hjust=-.5)
Error in rootnode.phylo(tr) : multiple roots found...
此外: Warning message:
In fortify.phylo(model, data, layout = layout, yscale = yscale, :
'edge.length' contains NA values...
## setting 'edge.length' to NULL automatically when plotting the tree...
Prerequisites
Describe you issue
Ask in right place
R reported an error when I tried to read the nhx file:
my code:
And the error message: