Aggregate and visualize sylph metagenomic profiles in R. sylph2lab picks up where the sylph functions of sra2lab (sylph_runs(), sylph_stream(), sylph_local()) leave off.
Documentation, with a worked vignette for each function: https://bjklab.github.io/sylph2lab/.
Functions
| Function | What it does |
|---|---|
sylph_aggregate() |
Reads the per-sample *_profiling.tsv files into one tibble (one row per sample and genome) and joins sample metadata (e.g. an sra2lab run table) and, optionally, GTDB taxonomy. |
sylph_timeline() |
Cohort sampling timeline: one row per subject, one point per sample, on subject-day, study-day or calendar-date axes, coloured and optionally split into panels by sampling site or a subject feature (e.g. treatment arm). |
sylph_heatmap() |
Samples x taxa geom_tile() heatmap at any rank, raw, log10 or CLR-transformed, with optional clustering and panels by group. |
sylph_taxon_plot() |
Focused plot of one taxon’s abundance (raw or CLR): per group, per-subject trajectories, and first-to-last change. sylph_taxon_abundance() returns the values behind it. |
All plots are ordinary ggplot2 objects, so they can be extended with + and saved with ggsave().
Example
The package ships sylph profiles for 18 runs of BioProject PRJNA1556220, the BioProject’s run table, and the GTDB r232 taxonomy rows for the example genomes.
library(sylph2lab)
profiles <- sylph_aggregate(
sylph_example("profiles"), # e.g. "data/sylph"
metadata = sylph_example("runs"), # e.g. "data/PRJNA1556220_runs.csv"
taxonomy = sylph_example("taxonomy")
# e.g. c("bac120_taxonomy_r232.tsv.gz", "ar53_taxonomy_r232.tsv.gz")
)
sylph_timeline(profiles, subject = "host_subject_id",
date = "collection_date", site = "isolation_source")
sylph_heatmap(profiles, rank = "species", top_n = 30,
group = "isolation_source", transform = "clr")
sylph_taxon_plot(profiles, "f__Enterobacteriaceae", rank = "gtdb_taxonomy",
taxon_label = "Enterobacteriaceae",
subject = "host_subject_id", time = "collection_date",
clr = TRUE, type = "both")Vignettes
Each function has a vignette, worked through on the example data, with guidance on downloading the sylph database and the matching GTDB taxonomy:
-
vignette("sylph-aggregate", package = "sylph2lab"): combining profiles with metadata and taxonomy -
vignette("sylph-timeline", package = "sylph2lab"): cohort sampling timelines -
vignette("sylph-heatmap", package = "sylph2lab"): abundance heatmaps -
vignette("sylph-taxon-plot", package = "sylph2lab"): one taxon, with or without CLR
Install with remotes::install_github("bjklab/sylph2lab", build_vignettes = TRUE) to have them available locally.
A note on CLR
sylph reports only the genomes it detects, so a sample’s composition is completed with zeros for genomes detected in other samples, and zeros are replaced by a pseudocount (by default half the smallest non-zero abundance) before the centred log-ratio is taken. CLR values therefore depend on the set of samples and on the pseudocount; see ?sylph_taxon_abundance.