Plot taxon-level results on the GTDB phylogeny. gtdb3h makes tree figures for metagenomic studies profiled with sylph against a GTDB database, picking up where sylph2lab (sylph_aggregate()) leaves off.
gtdb3h does not fit models. It prepares the GTDB tree for a phylogenetic model fitted elsewhere (for example with brms), and plots that model’s output, such as a posterior contrast per taxon, on the tree.
Documentation, with worked vignettes: https://bjklab.github.io/gtdb3h/.
Functions
| Function | What it does |
|---|---|
gtdb_tree_download(), gtdb_tree_url()
|
Downloads the GTDB bacterial (bac120) and archaeal (ar53) trees of a release, e.g. bac120_r232.tree.gz, from https://data.gtdb.ecogenomic.org/releases/. |
gtdb_tree_read() |
Reads the trees, removes the RS_/GB_ accession prefixes so tips match sylph’s accessions, and joins the domains into one tree (gtdb_tree_combine()). gtdb_node_labels() splits GTDB’s support:taxa node labels. |
gtdb_tree_prune() |
Keeps the genomes in your data, keeping the GTDB clade names of removed nodes. |
gtdb_tip_taxonomy() |
Each tip’s GTDB lineage (domain to genus), read from the tree. |
gtdb_tree_vcv() |
The phylogenetic correlation matrix, for (1 \| gr(accession, cov = A)) in brms or similar. |
gtdb_summarise_draws() |
One row per taxon (median, credible interval, probability above a threshold) from posterior draws. |
gtdb_tree_plot() |
Unrooted, rectangular or circular tree with tips filled by a taxon-level estimate; taxa above or below a threshold (by estimate or credible interval) outlined and labelled, and GTDB clades named. gtdb_tree_graph() returns the graph behind it, for custom ggraph figures. |
All plots are ordinary ggplot2 objects, so they can be extended with + and saved with ggsave().
Use the GTDB release of your sylph database
The tree must come from the same GTDB release as the sylph database the profiles were made with: release 232 for gtdb-r232-c200-dbv2.syl2db, release 220 for gtdb-r220-c200-dbv1.syldb. Then every genome sylph detects is a tip of the tree.
library(gtdb3h)
trees <- gtdb_tree_download(232, dest_dir = "~/projects/gtdb")Example
The package ships the GTDB r232 trees pruned to the 560 genomes detected in the sylph2lab example profiles (BioProject PRJNA1556220), those detections, and simulated posterior draws of a taxon-level effect.
library(gtdb3h)
tree <- gtdb_tree_read(gtdb_example("tree")) # e.g. gtdb_tree_read(trees)
detections <- read.csv(gtdb_example("detections")) # e.g. sylph2lab::sylph_aggregate(...)
tree <- gtdb_tree_prune(tree, detections)
# for a phylogenetic model fitted elsewhere
A <- gtdb_tree_vcv(tree)
# the model's posterior draws, one row per draw and taxon
draws <- read.csv(gtdb_example("draws"))
estimates <- gtdb_summarise_draws(draws, value = "effect")
gtdb_tree_plot(tree, estimates, highlight = "above", threshold = 0.2,
clade_rank = "phylum",
fill_label = "Increase in taxon<br>loss probability")Vignettes
-
vignette("gtdb-tree", package = "gtdb3h"): getting, reading and pruning the GTDB trees -
vignette("gtdb-tree-plot", package = "gtdb3h"): plotting taxon-level estimates on the tree -
vignette("gtdb-workflow", package = "gtdb3h"): from sylph profiles to a phylogenetic model figure
Install with remotes::install_github("bjklab/gtdb3h", build_vignettes = TRUE) to have them available locally.