[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EEVVD5MTBB35PM8831YPCE":3,"skill-same:01M7EEVVD5MTBB35PM8831YPCE":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EEVVD5MTBB35PM8831YPCE","bio-phylo-tree-io",null,"Read, write, and convert phylogenetic tree files with Biopython Bio.Phylo, and choose an annotation-preserving parser (treeio, DendroPy) when metadata matters. Covers why a tree file is a lossy serialization, why format conversion silently drops BEAST\u002FMrBayes node annotations (posteriors, HPD intervals, rates), the Newick support-vs-label ambiguity that mislabels bootstrap values, and the Nexus TRANSLATE and rooted\u002Funrooted traps. Use when parsing Newick, Nexus, NHX, phyloXML, or NeXML, converting between formats, handling posterior tree sets, or moving annotated BEAST trees without losing the credible intervals. Routes annotation-critical reads to DendroPy or treeio and orthology\u002Falignment context to sibling skills.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-phylo-tree-io\ndescription: Read, write, and convert phylogenetic tree files with Biopython Bio.Phylo, and choose an annotation-preserving parser (treeio, DendroPy) when metadata matters. Covers why a tree file is a lossy serialization, why format conversion silently drops BEAST\u002FMrBayes node annotations (posteriors, HPD intervals, rates), the Newick support-vs-label ambiguity that mislabels bootstrap values, and the Nexus TRANSLATE and rooted\u002Funrooted traps. Use when parsing Newick, Nexus, NHX, phyloXML, or NeXML, converting between formats, handling posterior tree sets, or moving annotated BEAST trees without losing the credible intervals. Routes annotation-critical reads to DendroPy or treeio and orthology\u002Falignment context to sibling skills.\ntool_type: python\nprimary_tool: Bio.Phylo\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"phylogenetics\u002Ftree-io\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: BioPython 1.83+. Annotation-preserving alternatives: DendroPy 5+ (Python), treeio 1.26+ \u002F ape 5.8+ (R).\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- Python: `pip show biopython` then `help(module.function)` to check signatures\n- R: `packageVersion('treeio')` then `?read.beast` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nBio.Phylo stores a Newick `[&...]` bracket as opaque `.comment` text and does NOT parse BEAST key-values; DendroPy `extract_comment_metadata=True` and treeio `read.beast` do.\n\n# Tree I\u002FO -- A Tree File Is a Lossy Serialization\n\n**\"Read and convert my tree files\"** -> Parse a tree into an in-memory object and re-serialize it, knowing which annotations each format and parser preserves.\n- Python: `Phylo.read('tree.nwk', 'newick')`, `Phylo.convert(...)` (Bio.Phylo)\n- Annotation-critical: `dendropy.Tree.get(..., extract_comment_metadata=True)` or treeio `read.beast()`\n\nScope: reading, writing, converting, and inspecting tree files, and selecting a parser that keeps the annotations the analysis needs. Rooting, pruning, collapsing -> tree-manipulation. Plotting and mapping annotations onto branches -> tree-visualization. Producing BEAST\u002FMrBayes annotated trees -> bayesian-inference, divergence-dating. Taxon-name sanitization shares the whitespace traps in sequence-io\u002Fread-sequences.\n\n## The Single Most Important Modern Insight\n\nA tree file is a lossy serialization of a richer in-memory object. The biologist cares about the topology plus its annotations -- branch supports, posterior probabilities, 95% HPD intervals on node heights, per-branch rates, divergence dates, taxon metadata -- and formats differ enormously in which of these they can hold, while parsers differ in which they actually read back. Three load-bearing facts:\n\n1. **Conversion is a silent data-destroying operation.** Reading a BEAST MCC tree and writing plain Newick produces a topologically identical tree that plots fine, but the HPD intervals, clade posteriors, and per-branch rates are gone and unrecoverable without re-running a multi-day MCMC. The loss is invisible until a reviewer asks where the credible intervals went.\n2. **The tool, not the format string, decides whether `[&...]` metadata survives.** In Python the naive default (Bio.Phylo) drops BEAST key-values; in R the naive default (`ape::read.nexus`) drops them; the tools built to preserve them are DendroPy (`extract_comment_metadata=True`) and treeio (`read.beast`). Route annotated trees through those.\n3. **In plain Newick a bare number has no fixed meaning.** In `(A,B)95:0.3` the `95` could be a bootstrap, a posterior, an internal clade name, or a second branch length. Only the tool that wrote the file knows; a parser that guesses wrong turns supports into names silently. IQ-TREE overloads the slot further, writing `SH-aLRT\u002FUFBoot` (e.g. `87.5\u002F98`), which a single-value parser truncates or chokes on.\n\n## Tool Taxonomy\n\n| Tool (lang) | BEAST `[&...]` | NHX | phyloXML richness | When |\n|-------------|----------------|-----|-------------------|------|\n| treeio (R) | YES, structured (`read.beast`\u002F`read.mrbayes`\u002F`read.iqtree`) | YES | via tidytree\u002Fggtree | the default whenever annotations matter; feeds ggtree |\n| DendroPy (Py) | YES, structured (`.annotations`) | YES | no | Python work needing metadata, posterior sets, tree distances, conversion with annotations |\n| ETE3\u002FETE4 (Py) | partial (custom features) | YES, native | no | reconciliation, NHX round-trips, programmatic node features |\n| Bio.Phylo (Py) | NO key-value parse (opaque `.comment`) | no | YES, richest | general pipelines, conversion among its 5 formats, phyloXML annotation |\n| ape (R) | NO (drops `[&...]`) | no | no | fast topology\u002Fbranch-length analysis; pair with treeio for annotated files |\n\nReferences: Bio.Phylo Talevich 2012; DendroPy Sukumaran 2010; ETE3 Huerta-Cepas 2016; ape Paradis 2019; treeio Wang 2020.\n\nOne-line decision rule: if the file came from BEAST, MrBayes, or RevBayes or carries `[&...]`\u002F`&&NHX` that matters, read it with treeio (R) or DendroPy (Py); otherwise Bio.Phylo (Py) or ape (R) is fine. Never route a BEAST MCC tree through `Bio.Phylo` or `ape::read.nexus` when the HPDs are needed.\n\n## Format Capability (What Each Format Can Hold)\n\n| Capability | Newick | NHX | Nexus (BEAST-annotated) | phyloXML | NeXML |\n|------------|--------|-----|-------------------------|----------|-------|\n| Topology + branch lengths | yes | yes | yes | yes | yes |\n| One support value | ambiguous slot | `B=` tag | comment key | typed `\u003Cconfidence>` | typed meta |\n| Multiple supports per node | no (single slot) | tags | comment keys | yes (n elements) | yes |\n| Posterior \u002F HPD intervals | no | no | yes (`_95%_HPD={}`) | via property | via meta |\n| Per-branch rates \u002F dates | no | tags | yes | yes | yes |\n| Taxonomy (NCBI id\u002Frank) | no | `S=`\u002F`T=` | no | yes, typed | yes |\n| Schema-validated | no | no | loose | yes (XSD) | yes (XSD) |\n\nNewick\u002FNHX are compact and grep-able; phyloXML\u002FNeXML are verbose XML (often 5-20x larger) but typed and validatable -- prefer XML for archiving\u002Fexchange where machine-checkable semantics matter, Newick\u002FNexus for pipeline interchange. BEAST\u002FFigTree metadata rides inside a Nexus (or Newick) `[&...]` comment, so \"it is a Nexus file\" says nothing about whether annotations survive -- only the parser does.\n\n## Reading, Writing, and Converting (Bio.Phylo)\n\n**Goal:** Move trees between formats and inspect them without assuming a single tree or losing annotations.\n\n**Approach:** Use `Phylo.read` for exactly one tree and `Phylo.parse` for many (posterior sets); use `Phylo.convert` only among formats of equal or greater capability; check `.confidence` vs `.name` to confirm support was read into the right slot.\n\n```python\nfrom Bio import Phylo\n\ntree = Phylo.read('tree.nwk', 'newick')          # exactly one tree; raises if 0 or >1\nposterior = list(Phylo.parse('run.trees', 'nexus'))   # many trees: posterior\u002Fbootstrap set\nPhylo.write(tree, 'tree.xml', 'phyloxml')        # phyloXML is Bio.Phylo's richest format\n\nPhylo.convert('tree.nex', 'nexus', 'tree.nwk', 'newick')   # WARNING: Newick cannot hold [&...]; annotations dropped\n\nfor clade in tree.get_nonterminals():\n    print(clade.confidence, clade.name)          # confirm the support landed in .confidence, not .name\n```\n\nSupported format strings: `newick`, `nexus`, `phyloxml`, `nexml`, `cdao`. Colors and branch widths persist only in phyloXML.\n\n## Preserve BEAST\u002FMrBayes Annotations Before Down-Converting\n\n**Goal:** Keep posteriors, HPD intervals, and rates when a downstream tool wants plain Newick.\n\n**Approach:** Read with an annotation-aware parser, extract the numbers into a side table that travels with the analysis, and only then write a stripped topology -- never down-convert first.\n\n```python\nimport dendropy\n\ntree = dendropy.Tree.get(path='mcc.tree', schema='nexus', extract_comment_metadata=True)\nfor node in tree:\n    if node.annotations.get_value('posterior') is not None:\n        post = node.annotations.get_value('posterior')\n        hpd = node.annotations.get_value('height_95%_HPD')   # raw BEAST key; treeio typically exposes it as height_0.95_HPD (exact name varies by source program and version -- introspect the columns)\n        # persist post\u002Fhpd to a side table keyed by the clade before any conversion\ntree.write(path='topology.nwk', schema='newick', suppress_annotations=True)   # intentional, after extraction\n```\n\nIn R the equivalent is treeio `read.beast('mcc.tree')` then `get.data()` \u002F `as_tibble()`, feeding ggtree (tree-visualization); `write.beast()` re-serializes with annotations intact.\n\n## Per-Method Failure Modes\n\n### BEAST\u002FMrBayes MCC to Plain Newick Erases the Credible Intervals\n**Trigger:** `Phylo.convert`, `ape::read.nexus` + `write.tree`, or any \"just give me the topology\" step on an annotated tree.\n**Mechanism:** The HPDs, posteriors, and rates live only in the `[&...]` comments, which plain Newick cannot hold and stripping parsers discard.\n**Symptom:** The output plots fine but the credible intervals are gone, irrecoverable without re-running the MCMC.\n**Fix:** Read with treeio `read.beast` or DendroPy `extract_comment_metadata=True`; extract the numbers to a side table; keep the original `.tree` as the source of truth.\n\n### Support Value Read as a Node Name (or Truncated)\n**Trigger:** Parsing a tree whose internal-node slot holds a bootstrap, a posterior, a clade name, or IQ-TREE's `SH-aLRT\u002FUFBoot` dual value.\n**Mechanism:** The Newick grammar gives one slot for all of these; the parser must be told which it is, and a single-value reader truncates the `\u002F`-delimited dual support.\n**Symptom:** Supports appear as `.name` strings, or only one of two IQ-TREE values survives, or the parse errors on `\u002F`.\n**Fix:** Know what wrote the file; in Bio.Phylo inspect `.confidence` vs `.name`; in treeio use `read.iqtree`\u002F`read.raxml`, which split dual support correctly.\n\n### Whitespace, Underscore, or Non-ASCII Taxon Names\n**Trigger:** Tip names with spaces, parentheses, commas, or accented characters; reliance on the Newick underscore-space convention.\n**Mechanism:** Naive CLI tools split unquoted spaces, and underscore-to-space auto-conversion silently desyncs tip labels from a metadata join key.\n**Symptom:** Downstream tools error or a metadata merge matches nothing.\n**Fix:** Sanitize to `[A-Za-z0-9_.]`, single-quote when spaces are unavoidable, and round-trip-test the labels against the metadata table before any join.\n\n### Nexus TRANSLATE-Table Desync and Rooted\u002FUnrooted Confusion\n**Trigger:** Hand-editing or merging Nexus tree blocks; assuming topology shape implies rootedness.\n**Mechanism:** The integer-to-name TRANSLATE map can decouple from the tree and silently relabel tips; Newick does not flag rootedness (a basal trifurcation conventionally signals unrooted, but tools disagree), while Nexus carries an explicit `[&R]`\u002F`[&U]`.\n**Symptom:** Tips are mislabeled after a merge, or a rooting-sensitive analysis runs on the wrong assumption without erroring.\n**Fix:** Parse with a translate-aware reader (treeio\u002FDendroPy\u002Fape apply it); verify tip-label sets match across merged trees; set rootedness explicitly rather than trusting topology shape.\n\n## Quantitative and Practical Notes\n\n| Item | Guidance | Why |\n|------|----------|-----|\n| Support-value scales | bootstrap\u002FUFBoot in [0,100], posterior in [0,1], SH-aLRT in [0,100] | a number is meaningless without knowing which test produced it; preserve provenance, not just the value |\n| Multi-tree files | use `Phylo.parse` \u002F DendroPy `TreeList` \u002F treeio `read.beast`; check object length | a single-tree reader on a `.trees` posterior returns only the first or errors |\n| Round-trip test | read -> write -> read and diff the annotations, not just the topology | topology almost always survives and gives false confidence |\n| Posterior set vs MCC | `.trees` is the full posterior; `.tree`\u002F`.mcc` is the single annotated summary | `read.beast` on a full posterior is huge; usually the MCC is wanted |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| HPD bars missing after conversion | converted a BEAST tree to Newick | extract annotations with treeio\u002FDendroPy first |\n| `Phylo.read` raises on a `.trees` file | multiple trees in the file | use `Phylo.parse` and iterate |\n| Bootstrap values show up as taxon names | node-label slot read as `.name` | set\u002Finspect confidence parsing; use a software-specific reader |\n| Metadata join matches nothing | underscore\u002Fspace relabeling of tips | sanitize and round-trip-test labels before joining |\n| Parser errors on `[` | strict parser chokes on FigTree comment | strip comments only after extracting needed metadata |\n\n## References\n\nCock PJA, Antao T, Chang JT, et al. 2009. Biopython: freely available Python tools for computational molecular biology and bioinformatics. *Bioinformatics* 25(11):1422-1423.\nTalevich E, Invergo BM, Cock PJA, Chapman BA. 2012. Bio.Phylo: a unified toolkit for processing, analyzing and visualizing phylogenetic trees in Biopython. *BMC Bioinformatics* 13:209.\nSukumaran J, Holder MT. 2010. DendroPy: a Python library for phylogenetic computing. *Bioinformatics* 26(12):1569-1571.\nHuerta-Cepas J, Serra F, Bork P. 2016. ETE 3: reconstruction, analysis, and visualization of phylogenomic data. *Molecular Biology and Evolution* 33(6):1635-1638.\nParadis E, Schliep K. 2019. ape 5.0: an environment for modern phylogenetics and evolutionary analyses in R. *Bioinformatics* 35(3):526-528.\nWang L-G, Lam TT-Y, Xu S, et al. 2020. Treeio: an R package for phylogenetic tree input and output with richly annotated and associated data. *Molecular Biology and Evolution* 37(2):599-603.\nMaddison DR, Swofford DL, Maddison WP. 1997. NEXUS: an extensible file format for systematic information. *Systematic Biology* 46(4):590-621.\nHan MV, Zmasek CM. 2009. phyloXML: XML for evolutionary biology and comparative genomics. *BMC Bioinformatics* 10:356.\nVos RA, Balhoff JP, Caravas JA, et al. 2012. NeXML: rich, extensible, and verifiable representation of comparative data and metadata. *Systematic Biology* 61(4):675-689.\n\n## Related Skills\n\n- tree-manipulation - rooting, pruning, and collapsing where rooted\u002Funrooted and polytomy choices bite\n- tree-visualization - ggtree and ETE consume the annotations preserved here\n- bayesian-inference - produces the BEAST\u002FMrBayes annotated trees whose metadata must survive\n- divergence-dating - produces MCC trees with HPD intervals on node ages\n- sequence-io\u002Fread-sequences - taxon-name sanitization shares the whitespace and non-ASCII traps\n","## Version Compatibility\n\nReference examples tested with: BioPython 1.83+. Annotation-preserving alternatives: DendroPy 5+ (Python), treeio 1.26+ \u002F ape 5.8+ (R).\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- Python: `pip show biopython` then `help(module.function)` to check signatures\n- R: `packageVersion('treeio')` then `?read.beast` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nBio.Phylo stores a Newick `[&...]` bracket as opaque `.comment` text and does NOT parse BEAST key-values; DendroPy `extract_comment_metadata=True` and treeio `read.beast` do.\n\n# Tree I\u002FO -- A Tree File Is a Lossy Serialization\n\n**\"Read and convert my tree files\"** -> Parse a tree into an in-memory object and re-serialize it, knowing which annotations each format and parser preserves.\n- Python: `Phylo.read('tree.nwk', 'newick')`, `Phylo.convert(...)` (Bio.Phylo)\n- Annotation-critical: `dendropy.Tree.get(..., extract_comment_metadata=True)` or treeio `read.beast()`\n\nScope: reading, writing, converting, and inspecting tree files, and selecting a parser that keeps the annotations the analysis needs. Rooting, pruning, collapsing -> tree-manipulation. Plotting and mapping annotations onto branches -> tree-visualization. Producing BEAST\u002FMrBayes annotated trees -> bayesian-inference, divergence-dating. Taxon-name sanitization shares the whitespace traps in sequence-io\u002Fread-sequences.\n\n## The Single Most Important Modern Insight\n\nA tree file is a lossy serialization of a richer in-memory object. The biologist cares about the topology plus its annotations -- branch supports, posterior probabilities, 95% HPD intervals on node heights, per-branch rates, divergence dates, taxon metadata -- and formats differ enormously in which of these they can hold, while parsers differ in which they actually read back. Three load-bearing facts:\n\n1. **Conversion is a silent data-destroying operation.** Reading a BEAST MCC tree and writing plain Newick produces a topologically identical tree that plots fine, but the HPD intervals, clade posteriors, and per-branch rates are gone and unrecoverable without re-running a multi-day MCMC. The loss is invisible until a reviewer asks where the credible intervals went.\n2. **The tool, not the format string, decides whether `[&...]` metadata survives.** In Python the naive default (Bio.Phylo) drops BEAST key-values; in R the naive default (`ape::read.nexus`) drops them; the tools built to preserve them are DendroPy (`extract_comment_metadata=True`) and treeio (`read.beast`). Route annotated trees through those.\n3. **In plain Newick a bare number has no fixed meaning.** In `(A,B)95:0.3` the `95` could be a bootstrap, a posterior, an internal clade name, or a second branch length. Only the tool that wrote the file knows; a parser that guesses wrong turns supports into names silently. IQ-TREE overloads the slot further, writing `SH-aLRT\u002FUFBoot` (e.g. `87.5\u002F98`), which a single-value parser truncates or chokes on.\n\n## Tool Taxonomy\n\n| Tool (lang) | BEAST `[&...]` | NHX | phyloXML richness | When |\n|-------------|----------------|-----|-------------------|------|\n| treeio (R) | YES, structured (`read.beast`\u002F`read.mrbayes`\u002F`read.iqtree`) | YES | via tidytree\u002Fggtree | the default whenever annotations matter; feeds ggtree |\n| DendroPy (Py) | YES, structured (`.annotations`) | YES | no | Python work needing metadata, posterior sets, tree distances, conversion with annotations |\n| ETE3\u002FETE4 (Py) | partial (custom features) | YES, native | no | reconciliation, NHX round-trips, programmatic node features |\n| Bio.Phylo (Py) | NO key-value parse (opaque `.comment`) | no | YES, richest | general pipelines, conversion among its 5 formats, phyloXML annotation |\n| ape (R) | NO (drops `[&...]`) | no | no | fast topology\u002Fbranch-length analysis; pair with treeio for annotated files |\n\nReferences: Bio.Phylo Talevich 2012; DendroPy Sukumaran 2010; ETE3 Huerta-Cepas 2016; ape Paradis 2019; treeio Wang 2020.\n\nOne-line decision rule: if the file came from BEAST, MrBayes, or RevBayes or carries `[&...]`\u002F`&&NHX` that matters, read it with treeio (R) or DendroPy (Py); otherwise Bio.Phylo (Py) or ape (R) is fine. Never route a BEAST MCC tree through `Bio.Phylo` or `ape::read.nexus` when the HPDs are needed.\n\n## Format Capability (What Each Format Can Hold)\n\n| Capability | Newick | NHX | Nexus (BEAST-annotated) | phyloXML | NeXML |\n|------------|--------|-----|-------------------------|----------|-------|\n| Topology + branch lengths | yes | yes | yes | yes | yes |\n| One support value | ambiguous slot | `B=` tag | comment key | typed `\u003Cconfidence>` | typed meta |\n| Multiple supports per node | no (single slot) | tags | comment keys | yes (n elements) | yes |\n| Posterior \u002F HPD intervals | no | no | yes (`_95%_HPD={}`) | via property | via meta |\n| Per-branch rates \u002F dates | no | tags | yes | yes | yes |\n| Taxonomy (NCBI id\u002Frank) | no | `S=`\u002F`T=` | no | yes, typed | yes |\n| Schema-validated | no | no | loose | yes (XSD) | yes (XSD) |\n\nNewick\u002FNHX are compact and grep-able; phyloXML\u002FNeXML are verbose XML (often 5-20x larger) but typed and validatable -- prefer XML for archiving\u002Fexchange where machine-checkable semantics matter, Newick\u002FNexus for pipeline interchange. BEAST\u002FFigTree metadata rides inside a Nexus (or Newick) `[&...]` comment, so \"it is a Nexus file\" says nothing about whether annotations survive -- only the parser does.\n\n## Reading, Writing, and Converting (Bio.Phylo)\n\n**Goal:** Move trees between formats and inspect them without assuming a single tree or losing annotations.\n\n**Approach:** Use `Phylo.read` for exactly one tree and `Phylo.parse` for many (posterior sets); use `Phylo.convert` only among formats of equal or greater capability; check `.confidence` vs `.name` to confirm support was read into the right slot.\n\n```python\nfrom Bio import Phylo\n\ntree = Phylo.read('tree.nwk', 'newick')          # exactly one tree; raises if 0 or >1\nposterior = list(Phylo.parse('run.trees', 'nexus'))   # many trees: posterior\u002Fbootstrap set\nPhylo.write(tree, 'tree.xml', 'phyloxml')        # phyloXML is Bio.Phylo's richest format\n\nPhylo.convert('tree.nex', 'nexus', 'tree.nwk', 'newick')   # WARNING: Newick cannot hold [&...]; annotations dropped\n\nfor clade in tree.get_nonterminals():\n    print(clade.confidence, clade.name)          # confirm the support landed in .confidence, not .name\n```\n\nSupported format strings: `newick`, `nexus`, `phyloxml`, `nexml`, `cdao`. Colors and branch widths persist only in phyloXML.\n\n## Preserve BEAST\u002FMrBayes Annotations Before Down-Converting\n\n**Goal:** Keep posteriors, HPD intervals, and rates when a downstream tool wants plain Newick.\n\n**Approach:** Read with an annotation-aware parser, extract the numbers into a side table that travels with the analysis, and only then write a stripped topology -- never down-convert first.\n\n```python\nimport dendropy\n\ntree = dendropy.Tree.get(path='mcc.tree', schema='nexus', extract_comment_metadata=True)\nfor node in tree:\n    if node.annotations.get_value('posterior') is not None:\n        post = node.annotations.get_value('posterior')\n        hpd = node.annotations.get_value('height_95%_HPD')   # raw BEAST key; treeio typically exposes it as height_0.95_HPD (exact name varies by source program and version -- introspect the columns)\n        # persist post\u002Fhpd to a side table keyed by the clade before any conversion\ntree.write(path='topology.nwk', schema='newick', suppress_annotations=True)   # intentional, after extraction\n```\n\nIn R the equivalent is treeio `read.beast('mcc.tree')` then `get.data()` \u002F `as_tibble()`, feeding ggtree (tree-visualization); `write.beast()` re-serializes with annotations intact.\n\n## Per-Method Failure Modes\n\n### BEAST\u002FMrBayes MCC to Plain Newick Erases the Credible Intervals\n**Trigger:** `Phylo.convert`, `ape::read.nexus` + `write.tree`, or any \"just give me the topology\" step on an annotated tree.\n**Mechanism:** The HPDs, posteriors, and rates live only in the `[&...]` comments, which plain Newick cannot hold and stripping parsers discard.\n**Symptom:** The output plots fine but the credible intervals are gone, irrecoverable without re-running the MCMC.\n**Fix:** Read with treeio `read.beast` or DendroPy `extract_comment_metadata=True`; extract the numbers to a side table; keep the original `.tree` as the source of truth.\n\n### Support Value Read as a Node Name (or Truncated)\n**Trigger:** Parsing a tree whose internal-node slot holds a bootstrap, a posterior, a clade name, or IQ-TREE's `SH-aLRT\u002FUFBoot` dual value.\n**Mechanism:** The Newick grammar gives one slot for all of these; the parser must be told which it is, and a single-value reader truncates the `\u002F`-delimited dual support.\n**Symptom:** Supports appear as `.name` strings, or only one of two IQ-TREE values survives, or the parse errors on `\u002F`.\n**Fix:** Know what wrote the file; in Bio.Phylo inspect `.confidence` vs `.name`; in treeio use `read.iqtree`\u002F`read.raxml`, which split dual support correctly.\n\n### Whitespace, Underscore, or Non-ASCII Taxon Names\n**Trigger:** Tip names with spaces, parentheses, commas, or accented characters; reliance on the Newick underscore-space convention.\n**Mechanism:** Naive CLI tools split unquoted spaces, and underscore-to-space auto-conversion silently desyncs tip labels from a metadata join key.\n**Symptom:** Downstream tools error or a metadata merge matches nothing.\n**Fix:** Sanitize to `[A-Za-z0-9_.]`, single-quote when spaces are unavoidable, and round-trip-test the labels against the metadata table before any join.\n\n### Nexus TRANSLATE-Table Desync and Rooted\u002FUnrooted Confusion\n**Trigger:** Hand-editing or merging Nexus tree blocks; assuming topology shape implies rootedness.\n**Mechanism:** The integer-to-name TRANSLATE map can decouple from the tree and silently relabel tips; Newick does not flag rootedness (a basal trifurcation conventionally signals unrooted, but tools disagree), while Nexus carries an explicit `[&R]`\u002F`[&U]`.\n**Symptom:** Tips are mislabeled after a merge, or a rooting-sensitive analysis runs on the wrong assumption without erroring.\n**Fix:** Parse with a translate-aware reader (treeio\u002FDendroPy\u002Fape apply it); verify tip-label sets match across merged trees; set rootedness explicitly rather than trusting topology shape.\n\n## Quantitative and Practical Notes\n\n| Item | Guidance | Why |\n|------|----------|-----|\n| Support-value scales | bootstrap\u002FUFBoot in [0,100], posterior in [0,1], SH-aLRT in [0,100] | a number is meaningless without knowing which test produced it; preserve provenance, not just the value |\n| Multi-tree files | use `Phylo.parse` \u002F DendroPy `TreeList` \u002F treeio `read.beast`; check object length | a single-tree reader on a `.trees` posterior returns only the first or errors |\n| Round-trip test | read -> write -> read and diff the annotations, not just the topology | topology almost always survives and gives false confidence |\n| Posterior set vs MCC | `.trees` is the full posterior; `.tree`\u002F`.mcc` is the single annotated summary | `read.beast` on a full posterior is huge; usually the MCC is wanted |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| HPD bars missing after conversion | converted a BEAST tree to Newick | extract annotations with treeio\u002FDendroPy first |\n| `Phylo.read` raises on a `.trees` file | multiple trees in the file | use `Phylo.parse` and iterate |\n| Bootstrap values show up as taxon names | node-label slot read as `.name` | set\u002Finspect confidence parsing; use a software-specific reader |\n| Metadata join matches nothing | underscore\u002Fspace relabeling of tips | sanitize and round-trip-test labels before joining |\n| Parser errors on `[` | strict parser chokes on FigTree comment | strip comments only after extracting needed metadata |\n\n## References\n\nCock PJA, Antao T, Chang JT, et al. 2009. Biopython: freely available Python tools for computational molecular biology and bioinformatics. *Bioinformatics* 25(11):1422-1423.\nTalevich E, Invergo BM, Cock PJA, Chapman BA. 2012. Bio.Phylo: a unified toolkit for processing, analyzing and visualizing phylogenetic trees in Biopython. *BMC Bioinformatics* 13:209.\nSukumaran J, Holder MT. 2010. DendroPy: a Python library for phylogenetic computing. *Bioinformatics* 26(12):1569-1571.\nHuerta-Cepas J, Serra F, Bork P. 2016. ETE 3: reconstruction, analysis, and visualization of phylogenomic data. *Molecular Biology and Evolution* 33(6):1635-1638.\nParadis E, Schliep K. 2019. ape 5.0: an environment for modern phylogenetics and evolutionary analyses in R. *Bioinformatics* 35(3):526-528.\nWang L-G, Lam TT-Y, Xu S, et al. 2020. Treeio: an R package for phylogenetic tree input and output with richly annotated and associated data. *Molecular Biology and Evolution* 37(2):599-603.\nMaddison DR, Swofford DL, Maddison WP. 1997. NEXUS: an extensible file format for systematic information. *Systematic Biology* 46(4):590-621.\nHan MV, Zmasek CM. 2009. phyloXML: XML for evolutionary biology and comparative genomics. *BMC Bioinformatics* 10:356.\nVos RA, Balhoff JP, Caravas JA, et al. 2012. NeXML: rich, extensible, and verifiable representation of comparative data and metadata. *Systematic Biology* 61(4):675-689.\n\n## Related Skills\n\n- tree-manipulation - rooting, pruning, and collapsing where rooted\u002Funrooted and polytomy choices bite\n- tree-visualization - ggtree and ETE consume the annotations preserved here\n- bayesian-inference - produces the BEAST\u002FMrBayes annotated trees whose metadata must survive\n- divergence-dating - produces MCC trees with HPD intervals on node ages\n- sequence-io\u002Fread-sequences - taxon-name sanitization shares the whitespace and non-ASCII traps\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","python","2026-09-20","phylogenetics\u002Ftree-io\u002FSKILL.md","Bio.Phylo","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-phylo-tree-io","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-phylo-tree-io",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-phylo-tree-io",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-phylo-tree-io","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002FSKILL.md",true,[50,56,60,64],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fconvert_formats.py","SCRIPT","脚本",949,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002Fexamples\u002Fconvert_formats.py",{"path":57,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":58,"sourceHtmlUrl":59},"examples\u002Fparse_multiple_trees.py",457,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002Fexamples\u002Fparse_multiple_trees.py",{"path":61,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":62,"sourceHtmlUrl":63},"examples\u002Fread_newick.py",518,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002Fexamples\u002Fread_newick.py",{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"usage-guide.md","REFERENCE","参考文档",4299,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-phylo-tree-io\u002Fusage-guide.md",[71,79,86,93,100,107],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":78},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":78},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":78},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":78},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":78},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":78},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]