Aggregate and visualize fmh-funprofiler KEGG Orthology (KO) profiles in R. funprofiler2lab picks up where the funprofiler functions of sra2lab (funprofiler_runs(), funprofiler_stream(), funprofiler_local()) leave off. It is the functional counterpart of sylph2lab, for taxonomic profiles.
Documentation, with a worked vignette for each function: https://bjklab.github.io/funprofiler2lab/.
Functions
| Function | What it does |
|---|---|
funprofiler_aggregate() |
Reads the per-sample *_ko_profiles.csv files into one tibble (one row per sample and KO, with each profile’s k and scaled) and joins sample metadata (e.g. an sra2lab run table) and, optionally, KEGG KO names and pathways. |
funprofiler_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). The same function as sylph2lab::sylph_timeline(). |
funprofiler_heatmap() |
Samples x functions geom_tile() heatmap of KOs, KEGG pathways, pathway classes or categories, raw, log10 or CLR-transformed, with optional clustering and panels by group. |
funprofiler_feature_plot() |
Focused plot of one KO’s or pathway’s abundance (raw or CLR): per group, per-subject trajectories, and first-to-last change. funprofiler_feature_abundance() returns the values behind it. |
funprofiler_kegg() downloads (once) and reads the KEGG Orthology hierarchy used for KO names and pathways. All plots are ordinary ggplot2 objects, so they can be extended with + and saved with ggsave().
Example
The package ships KO profiles for 18 runs of BioProject PRJNA1556220 (the runs of the sylph2lab example data) and the BioProject’s run table. KEGG data may not be redistributed, so the annotation is downloaded from the KEGG REST API (free for academic use).
library(funprofiler2lab)
profiles <- funprofiler_aggregate(
funprofiler_example("profiles"), # e.g. "data/funprofiler"
metadata = funprofiler_example("runs"), # e.g. "data/PRJNA1556220_runs.csv"
kegg = funprofiler_kegg("data/kegg/ko00001.keg") # downloaded on first use
)
funprofiler_timeline(profiles, subject = "host_subject_id",
date = "collection_date", site = "isolation_source")
funprofiler_heatmap(profiles, feature = "pathway", top_n = 30,
group = "isolation_source", transform = "log10",
show_unassigned = FALSE)
funprofiler_feature_plot(profiles, "beta-Lactam resistance",
level = "pathway", 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 the KO database, the KEGG hierarchy and the run metadata:
-
vignette("funprofiler-aggregate", package = "funprofiler2lab"): combining profiles with metadata and KEGG annotation -
vignette("funprofiler-timeline", package = "funprofiler2lab"): cohort sampling timelines -
vignette("funprofiler-heatmap", package = "funprofiler2lab"): KO and pathway heatmaps -
vignette("funprofiler-feature-plot", package = "funprofiler2lab"): one KO or pathway, with or without CLR
Install with remotes::install_github("bjklab/funprofiler2lab", build_vignettes = TRUE) to have them available locally.
Notes on abundances and CLR
funprofiler’s abundance is each KO’s share of the KO content found in a sample (a sample’s abundances sum to 1); funprofiler2lab adds relative_abundance, the same in percent, and plots that by default. Pathway abundances are sums over a pathway’s KOs, and since KOs are shared between pathways, a sample’s pathway abundances add up to more than 100%.
funprofiler reports only the KOs it detects, so a sample’s composition is completed with zeros for KOs 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 ?funprofiler_feature_abundance.