Skip to contents

Reads one or more GTDB tree files (Newick, plain or gzip-compressed) and tidies their labels:

  • Tips are GTDB accessions such as RS_GCF_003697165.2. The RS_ or GB_ prefix is removed, so the tips match the accession column of sylph2lab::sylph_aggregate() (GCF_003697165.2).

  • Internal nodes are labelled with their bootstrap support and, where a GTDB taxon starts, its name, e.g. '100:f__Enterobacteriaceae' or '99.0:c__Bacilli; o__Lactobacillales'. The quotes are removed; gtdb_node_labels() splits them into support and taxa.

Internal nodes with a single child (which the full GTDB trees do not have, but trees pruned elsewhere with their clade names kept may) are removed as in gtdb_tree_prune(), keeping their clade names.

Usage

gtdb_tree_read(file, combine = TRUE, root_edge = 1)

Arguments

file

Path(s) to GTDB tree files, e.g. the result of gtdb_tree_download().

combine

If TRUE and there is more than one file, join the trees into one; otherwise return a list of trees.

root_edge

Passed to gtdb_tree_combine().

Value

A tree (an ape "phylo" object), or with combine = FALSE and several files a list of trees named by file.

Details

With more than one file and combine = TRUE (the default), the trees are joined into one by gtdb_tree_combine(), so bacteria and archaea can be plotted together.

The full bacterial tree has about 190,000 tips (release 232); prune it to the genomes in your data with gtdb_tree_prune() before plotting.

Examples

tree <- gtdb_tree_read(gtdb_example("tree"))
tree
#> 
#> Phylogenetic tree with 560 tips and 560 internal nodes.
#> 
#> Tip labels:
#>   GCF_037023725.1, GCF_900105835.1, GCF_001042985.1, GCF_001457615.1, GCF_001598695.1, GCF_002925905.1, ...
#> Node labels:
#>   , 7:d__Bacteria, 1, 0, 100:p__Pseudomonadota, 97:c__Gammaproteobacteria, ...
#> 
#> Rooted; includes branch length(s).
head(tree$tip.label)
#> [1] "GCF_037023725.1" "GCF_900105835.1" "GCF_001042985.1" "GCF_001457615.1"
#> [5] "GCF_001598695.1" "GCF_002925905.1"
head(gtdb_node_labels(tree))
#> # A tibble: 6 × 6
#>    node label                       support taxa                   taxon   rank 
#>   <int> <chr>                         <dbl> <chr>                  <chr>   <chr>
#> 1   561 ""                               NA NA                     NA      NA   
#> 2   562 "7:d__Bacteria"                   7 d__Bacteria            Bacter… doma…
#> 3   563 "1"                               1 NA                     NA      NA   
#> 4   564 "0"                               0 NA                     NA      NA   
#> 5   565 "100:p__Pseudomonadota"         100 p__Pseudomonadota      Pseudo… phyl…
#> 6   566 "97:c__Gammaproteobacteria"      97 c__Gammaproteobacteria Gammap… class