Supported Taxonomy Label Formats

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 10,
  fig.height = 7
)

Overview

Rclade automatically detects and parses four taxonomy label formats:

| Format | Separator | Prefix | Example | |--------|-----------|--------|---------| | GTDB | ; | __ | d__Bacteria;p__Proteobacteria | | Silva | ; | none | Bacteria;Proteobacteria | | NCBI | ; | none | cellular organisms;Bacteria | | Custom rank | _ + code | none | species_d_Bacteria_p_Proteobacteria |

Automatic Detection

library(Rclade)

# Load example data
data(example_tree)

# Auto-detection works in most cases
p <- plot_timetree(example_tree, rank = "phylum",
                   taxonomy_format = "auto",
                   add_timescale = FALSE)

Detection applies conservative "clear majority" rules: GTDB requires a [dpcofgsk]__ prefix-match score >= 0.6 and a semicolon-delimiter majority; embedded requires a _[dpcofgsk]_ match score >= 0.6; NCBI/Silva first require a semicolon majority and then compare prefix scores. Ambiguous labels fall back to "unknown". Note that accession-prefixed embedded labels with double-underscore separators (e.g. GCA_xxx_d__Archaea_p__Nanoarchaeota) are correctly detected as embedded (not GTDB) and are parsed by all three delimiter modes; for label schemes with extra intermediate ranks (e.g. a superphylum field), use taxonomy_format = "custom_regex" with explicit per-rank patterns.

Quality Report

Check how well your labels can be parsed before visualization:

labels <- example_tree$tip.label
summarize_taxonomy_quality(labels, format = "GTDB")

Manual Format Specification

If auto-detection fails, specify the format explicitly:

# GTDB format
p <- plot_timetree(example_tree, rank = "phylum",
                   taxonomy_format = "GTDB",
                   add_timescale = FALSE)
print(p)

NCBI Format Handling

NCBI taxonomy uses position-based rank mapping. Note that this may produce systematic rank offsets in non-standard lineages (e.g., viruses where Riboviria is a realm, not a domain). For critical applications, consider using GTDB or Silva format, or providing custom_patterns.

# NCBI format (requires NCBI-labeled tree)
p <- plot_timetree(ncbi_tree, rank = "phylum",
                   taxonomy_format = "NCBI",
                   add_timescale = FALSE)

Custom Regex Patterns

For non-standard formats:

p <- plot_timetree(tree, rank = "phylum",
                   add_timescale = FALSE,
                   taxonomy_format = "custom_regex",
                   custom_patterns = list(
                     domain = "Domain:([^|]+)",
                     phylum = "Phylum:([^|]+)"
                   ))

Embedded Format Parsing Strategies

For embedded (Format A) labels, Rclade supports three delimiter matching strategies:

| Mode | Description | Best for | |------|-------------|----------| | reverse (default) | Match ranks from right to left | Labels where taxon names contain underscores | | greedy | Match ranks from left to right using character-class boundaries | Simple labels with no underscores in names | | segment | Extract content between delimiters | Preserving underscores within values |

# Default reverse mode
p <- plot_timetree(tree, rank = "phylum",
                   add_timescale = FALSE,
                   taxonomy_format = "custom_rank",
                   taxonomy_delimiter_mode = "reverse")

# Segment mode for labels with underscores in taxon names
p <- plot_timetree(tree, rank = "phylum",
                   add_timescale = FALSE,
                   taxonomy_format = "custom_rank",
                   taxonomy_delimiter_mode = "segment")

Custom Taxonomy Levels

You can extend or override the default rank codes and delimiters with taxonomy_levels. This is useful for non-standard ranks such as kingdom (k) or subspecies (ss).

For embedded (Format A) labels, provide a list of rank codes and their prefixes:

p <- plot_timetree(tree, rank = "phylum",
                   add_timescale = FALSE,
                   taxonomy_format = "custom_rank",
                   taxonomy_levels = list(
                     codes = c("k", "d", "p", "c", "o", "f", "g", "s", "ss"),
                     names = c("_k_", "_d_", "_p_", "_c_",
                               "_o_", "_f_", "_g_", "_s_", "_ss_")
                   ))

The codes vector defines the short rank codes, and names defines the delimiters used in the labels. The same taxonomy_levels object is propagated through highlighting, monophyly checks, special identifier resolution, and external taxonomy file merging.

References & Acknowledgments

Rclade supports taxonomy formats from several databases. If you use data from these sources in published research, please cite them appropriately:

Rclade also builds on the ggtree and deeptime R packages:



Try the Rclade package in your browser

Any scripts or data that you put into this service are public.

Rclade documentation built on Sept. 26, 2026, 5:07 p.m.