LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome
The 7 matches
- [1] § Appendix E. Additional details of prediction tasks › Experimental details ↔ r/R/lgtm.R, lines 1 to 55 · score 0.71 · PyTorch, hidden dimension, random seeds, Adam, Cross, validation · Report a mismatch
- [2] § Appendix E. Additional details of prediction tasks › Experimental details ↔ src/lgtm/api/backend.py, lines 64 to 112 · score 0.70 · PyTorch, hidden dimension, random seeds, Adam, optimization, validation · Report a mismatch
- [3] § Methods › Training and optimization ↔ src/lgtm/api/backend.py, lines 64 to 112 · score 0.70 · Monte Carlo, mini batching, stochastic, space, KL, encoder · Report a mismatch
- [4] § Methods › Training and optimization ↔ r/R/lgtm.R, lines 1 to 55 · score 0.69 · Monte Carlo, mini batching, space, cross, KL, encoder · Report a mismatch
- [5] § Methods › Problem formulation ↔ src/lgtm/api/estimator.py, lines 12 to 49 · score 0.63 · topic taxon matrix, microbiome profile, subject ID, mapped, modulated, metadata · Report a mismatch
- [6] § Experiments and results › LGTM discovers diverse and stable microbial topics ↔ src/lgtm/api/estimator.py, lines 12 to 49 · score 0.61 · neural topic model, topic matrices, topic taxon, matched, fit, microbiome · Report a mismatch
- [7] § Experiments and results › LGTM identifies interpretable microbial co-abundance patterns ↔ scripts/hmp_data.py, lines 9 to 48 · score 0.58 · red meat, dairy, drinks, grains, probiotic, diet · Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
R · 185 lines · 7 KB · MIT · 2 matches
- #' Fit LGTM from metadata and microbiome tables
- #'
- #' Calls the existing LGTM Python API. The backend matches samples by
- #' `sample_id`, sorts them by subject and time, normalizes each abundance row
- #' to sum to one, and encodes categorical covariates.
- #'
- #' @param metadata A data frame with one row per sample and required columns
- #' `sample_id`, `subject_id`, and numeric `time`. Time is continuous. Extra
- #' columns are categorical covariates modeled through interactions with
- #' time. Sample IDs must be unique.
- #' @param microbiome A data frame with `sample_id` and one numeric abundance
- #' column per taxon. Sample IDs must be unique, and each abundance row must
- #' have a positive total. Preserve taxon names when reading the table.
- #' @param latent_dim Number of latent topics. Default: 6.
- #' @param n_epoch Number of training epochs. Default: 100.
- #' @param batch_size Mini-batch size. Default: 64.
- #' @param learning_rate Adam learning rate. Default: 0.05.
- #' @param hidden_dim Encoder hidden dimension. Default: 64.
- #' @param seed Random seed for Python, NumPy, and PyTorch. Default: 42.
- #' @param n_basis_functions Number of Hilbert-space basis functions for the
- #' squared exponential kernel approximation. Default: 5.
- #' @param kl_weight GP KL regularization weight. Default: 0.001.
- #' @param mc_samples Number of Monte Carlo samples during training. Default: 1.
- #' @param patience Early stopping patience. Default: 0.
- #' @param early_stop Enable early stopping using the training data as validation
- #' data. This is a full-data fit, not cross-validation. Default: TRUE.
- #' @param init_topics Initialize topic loadings using NNDSVD. Default: TRUE.
- #' @param use_encoder Use the encoder pathway during training. Default: TRUE.
- #'
- #' @returns A list containing:
- #' - `sample_topic`: a sample-by-topic data frame of topic proportions, with
- #' sample IDs as row names and `topic-1`, `topic-2`, etc. as column names.
- #' - `topic_taxon`: a topic-by-taxon data frame of loadings, with topic names
- #' as row names and taxon names as column names.
- #' - `model`: the fitted Python `LGTM` estimator.
- #'
- #' Both tables use the same topic order, sorted by decreasing mean
- #' sample-topic proportion. The Python model reference is valid only in the
- #' current R session; save result tables separately when using `saveRDS()`.
- #' @examples
- #' \dontrun{
- #' metadata <- read.csv("metadata.csv", check.names = FALSE)
- #' microbiome <- read.csv("microbiome.csv", check.names = FALSE)
- #' fit <- lgtm_fit(
- #' metadata,
- #' microbiome,
- #' latent_dim = 6,
- #' n_epoch = 100,
- #' seed = 42
- #' )
- #' fit$sample_topic
- #' fit$topic_taxon
- #' }
- #' @export
- lgtm_fit <- function(
- metadata,
- microbiome,
- latent_dim = 6L,
- n_epoch = 100L,
- batch_size = 64L,
- learning_rate = 0.05,
- hidden_dim = 64L,
- seed = 42L,
- n_basis_functions = 5L,
- kl_weight = 0.001,
- mc_samples = 1L,
- patience = 0L,
- early_stop = TRUE,
- init_topics = TRUE,
- use_encoder = TRUE
- ) {
- lgtm <- reticulate::import("lgtm")
- config <- lgtm$LGTMConfig(
- latent_dim = as.integer(latent_dim),
- n_epoch = as.integer(n_epoch),
- batch_size = as.integer(batch_size),
- learning_rate = learning_rate,
- hidden_dim = as.integer(hidden_dim),
- seed = as.integer(seed),
- n_basis_functions = as.integer(n_basis_functions),
- kl_weight = kl_weight,
- mc_samples = as.integer(mc_samples),
- patience = as.integer(patience),
- early_stop = early_stop,
- init_topics = init_topics,
- use_encoder = use_encoder
- )
- model <- lgtm$LGTM(config)
- model$fit(metadata, microbiome)
- list(
- sample_topic = model$sample_topic_,
- topic_taxon = model$topic_taxon_,
- model = model
- )
- }
- #' Plot LGTM results
- #'
- #' Reuses the Python API's Matplotlib figures. When `show = TRUE`, a PNG preview
- #' is drawn on the R graphics device. The original Figure and Axes remain
- #' available for customization and vector export with `figure$savefig()`.
- #'
- #' @param fit A result from [lgtm_fit()].
- #' @param type Plot type: `"si"` for covariate importance, `"topics"` for the
- #' topic overview, `"topic"` for one topic's taxon loadings, `"gp"` for GP
- #' components, or `"latent"` for observed sample-topic proportions.
- #' @param topic One-based topic number, sorted by decreasing mean proportion.
- #' Used for `"topic"`, `"gp"`, and `"latent"`. Default: 1.
- #' @param ... Arguments forwarded to the corresponding Python plotting method.
- #' See Details for supported arguments and their defaults.
- #' @param show Draw a preview on the R graphics device. Default: TRUE.
- #' @param dpi Resolution of the PNG preview. Default: 300.
- #'
- #' @details
- #' Plot-specific arguments follow the Python API:
- #' - `"si"`: `rotation = 45` sets the angle of covariate labels in degrees.
- #' - `"topics"`: `top_k = 5` limits the taxa shown per topic; `threshold = 0.01`
- #' is the minimum absolute loading for display; `num_plot = NULL` shows all
- #' topics, or an integer limits the number shown.
- #' - `"topic"`: `top_n = 20` sets the number of taxa considered;
- #' `threshold = 0.01` controls which taxa are annotated;
- #' `figsize = c(18, 2)` sets the figure size.
- #' - `"gp"`: `repeats = 5` sets the number of stochastic GP draws used for
- #' uncertainty bands; `figsize = c(18, 3)` sets the figure size;
- #' `plot_id = FALSE` omits subject-ID GP components.
- #' - `"latent"`: `figsize = c(18, 3)` sets the figure size;
- #' `plot_pointplot = FALSE` disables group mean points; `plot_id = FALSE`
- #' omits subject-ID panels.
- #'
- #' Use a numeric vector of length two for `figsize`, in inches.
- #'
- #' @returns Invisibly, a list containing the original Matplotlib `figure` and
- #' its `axes`. The Figure is removed from pyplot's registry after plotting
- #' but remains usable through this list.
- #' @examples
- #' \dontrun{
- #' lgtm_plot(fit, type = "si")
- #' plot_result <- lgtm_plot(fit, type = "gp", topic = 1)
- #' plot_result$figure$savefig("gp.svg", bbox_inches = "tight")
- #' }
- #' @export
- lgtm_plot <- function(
- fit,
- type = c("si", "topics", "topic", "gp", "latent"),
- topic = 1L,
- ...,
- show = TRUE,
- dpi = 300
- ) {
- type <- match.arg(type)
- method <- switch(
- type,
- si = fit$model$plot_si,
- topics = fit$model$plot_topics,
- topic = fit$model$plot_topic,
- gp = fit$model$plot_gp,
- latent = fit$model$plot_latent
- )
- args <- list(...)
- for (name in intersect(
- names(args),
- c("top_k", "num_plot", "top_n", "repeats")
- )) {
- if (!is.null(args[[name]])) {
- args[[name]] <- as.integer(args[[name]])
- }
- }
- if (type %in% c("topic", "gp", "latent")) {
- args$topic <- as.integer(topic)
- }
- result <- do.call(method, args)
- figure <- result[[1L]]
- plt <- reticulate::import("matplotlib.pyplot")
- on.exit(plt$close(figure), add = TRUE)
- if (show) {
- buffer <- reticulate::import("io")$BytesIO()
- on.exit(buffer$close(), add = TRUE)
- figure$savefig(buffer, format = "png", dpi = dpi, bbox_inches = "tight")
- preview <- png::readPNG(as.raw(buffer$getvalue()))
- grid::grid.newpage()
- grid::grid.raster(preview)
- }
- invisible(list(figure = figure, axes = result[[2L]]))
- }
lgtm.R at commit 57c1d06, under MIT · at the source
Overview
- Institute of Biotechnology, Helsinki Institute of Life Science, University of Helsinki, Helsinki, Finland
- Department of Computer Science, Aalto University, Espoo, Finland
- Department of Electrical Engineering (ESAT), STADIUS Center for Dynamical Systems, Signal Processing and Data Analytics, Leuven, Belgium
- Department of Artificial Intelligence and Systems Engineering, Faculty of Electrical Engineering and Informatics, Budapest University of Technology and Economics, Budapest, Hungary
- Department of Microbiology, Faculty of Agriculture and Forestry, University of Helsinki, Helsinki, Finland
- Research Program for Clinical and Molecular Metabolism, Faculty of Medicine, University of Helsinki, Helsinki, Finland
- Broad Institute of MIT and Harvard, Cambridge, MA, USA
- Liggins Institute, University of Auckland, Auckland, New Zealand
Abstract
Longitudinal microbiome data are key to understanding the dynamics of microbial communities and their relationships with the host and environment. However, analysis of such data is challenging due to high dimensionality, compositionality, irregular sampling and temporal dependencies on external covariates. Existing analytical approaches typically address only subsets of these challenges, limiting their ability to yield biologically interpretable insights. We introduce LGTM, a probabilistic modeling framework that combines flexible non-linear longitudinal modeling with interpretable topic-based representations of the microbiome. LGTM simultaneously identifies microbial co-abundance patterns (“topics”) and models how their proportions change over time and in relation to host and environmental covariates. Using multiple longitudinal human gut microbiome datasets, we demonstrate that LGTM identifies diverse microbial topics whose major patterns are reproducible across runs, while achieving competitive performance in imputation and forecasting tasks. A key strength of the framework is its interpretability: LGTM yields microbial topics with biologically interpretable taxonomic compositions and directly quantifies associations between covariates and microbial dynamics. LGTM is available at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Repositories
Its files are read in the Code ↔ Paper reader above, with 7 matches between paragraphs and lines of code.
yuanx749/lgtm
57c1d0639dc00fe360d9ae9cb4c244c64640dca2, 19 September 2026Availability: 1 check, the latest on 8 October 2026: the link answers
- 8 October 2026: the link answers
28 files
- examples/
hmp_gp.ipynb , Jupyter, 88 lines - r/
R/ , R, 185 lines, 2 matcheslgtm.R - r/
R/ , R, 6 lineszzz.R - scripts/
align_alto.R , R, 70 lines - scripts/
bench_data.py , Python, 50 lines - scripts/
bench_plot.py , Python, 73 lines - scripts/
bench_run.py , Python, 116 lines - scripts/
hmp_data.py , Python, 202 lines, 1 match - scripts/
hmp_download.sh , Shell, 5 lines - scripts/
model_simple.py , Python, 211 lines - scripts/
plot_alignment_anchor.R , R, 107 lines - scripts/
train_pypots.py , Python, 248 lines - scripts/
train_vae.py , Python, 407 lines - scripts/
tune.py , Python, 205 lines - scripts/
tune_pypots.py , Python, 158 lines - scripts/
utils2.py , Python, 183 lines - src/
lgtm/ , Python, 6 lines__init__.py - src/
lgtm/ , Python, 393 lines, 2 matchesapi/ backend.py - src/
lgtm/ , Python, 257 lines, 2 matchesapi/ estimator.py - src/
lgtm/ , Python, 31 linesconfig.py - src/
lgtm/ , Python, 105 linesdata.py - src/
lgtm/ , Python, 933 linesmodel.py - src/
lgtm/ , Python, 317 linesstreamlit_app/ streamlit_app.py - src/
lgtm/ , Python, 521 linestrain.py - src/
lgtm/ , Python, 162 linesutils.py - src/
lgtm/ , Python, 702 linesutils_plot.py - LICENSE, License, 21 lines
- README.md, Text, 66 lines
Zenodo 20588704
Availability: 1 check, the latest on 8 October 2026: the link answers (HTTP 200)
- 8 October 2026: the link answers (HTTP 200)
26 files
- examples/
hmp_gp.ipynb , Jupyter, 88 lines - scripts/
align_alto.R , R, 70 lines - scripts/
bench_data.py , Python, 50 lines - scripts/
bench_plot.py , Python, 73 lines - scripts/
bench_run.py , Python, 116 lines - scripts/
hmp_data.py , Python, 202 lines - scripts/
hmp_download.sh , Shell, 5 lines - scripts/
model_simple.py , Python, 211 lines - scripts/
plot_alignment_anchor.R , R, 107 lines - scripts/
train_pypots.py , Python, 248 lines - scripts/
train_vae.py , Python, 407 lines - scripts/
tune.py , Python, 205 lines - scripts/
tune_pypots.py , Python, 158 lines - scripts/
utils2.py , Python, 183 lines - src/
lgtm/ , Python, 6 lines__init__.py - src/
lgtm/ , Python, 393 linesapi/ backend.py - src/
lgtm/ , Python, 257 linesapi/ estimator.py - src/
lgtm/ , Python, 31 linesconfig.py - src/
lgtm/ , Python, 105 linesdata.py - src/
lgtm/ , Python, 933 linesmodel.py - src/
lgtm/ , Python, 317 linesstreamlit_app/ streamlit_app.py - src/
lgtm/ , Python, 521 linestrain.py - src/
lgtm/ , Python, 162 linesutils.py - src/
lgtm/ , Python, 702 linesutils_plot.py - LICENSE, License, 21 lines
- README.md, Text, 62 lines
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 50 scripts, each with its path and the digest of its content;
- 7 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability statement
The LGTM source code is available at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 8 October 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 5 keywords, 52 references.
Cite
This paper
Yuan, X., Arany, Á., Formanek, A., Moreau, Y., Lähdesmäki, H., & Vatanen, T. (2026). LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome. Gut Microbes, 18(1), 2741488.
BibTeX
@article{yuan2026lgtm,
author = {Yuan, Xiao and Arany, Ádám and Formanek, András and Moreau, Yves and Lähdesmäki, Harri and Vatanen, Tommi},
title = {{LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome}},
journal = {Gut Microbes},
year = {2026},
month = oct,
volume = {18},
number = {1},
pages = {2741488},
publisher = {Taylor \& Francis},
issn = {1949-0976},
pmcid = {PMC13644641}
}
RIS
TY - JOUR
AU - Yuan, Xiao
AU - Arany, Ádám
AU - Formanek, András
AU - Moreau, Yves
AU - Lähdesmäki, Harri
AU - Vatanen, Tommi
TI - LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome
T2 - Gut Microbes
J2 - Gut Microbes
PY - 2026
DA - 2026/
VL - 18
IS - 1
SP - 2741488
SN - 1949-0976
PB - Taylor & Francis
LA - en
ER -
CSL-JSON
{
"id": "pmcid:PMC13644641",
"type": "article-journal",
"title": "LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome",
"container-title": "Gut Microbes",
"author": [
{
"family": "Yuan",
"given": "Xiao"
},
{
"family": "Arany",
"given": "Ádám"
},
{
"family": "Formanek",
"given": "András"
},
{
"family": "Moreau",
"given": "Yves"
},
{
"family": "Lähdesmäki",
"given": "Harri"
},
{
"family": "Vatanen",
"given": "Tommi"
}
],
"container-title-short":
"volume": "18",
"issue": "1",
"page": "2741488",
"PMCID": "PMC13644641",
"ISSN": "1949-0976",
"publisher": "Taylor & Francis",
"language": "en",
"issued": {
"date-parts": [
[
2026,
10,
8
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1016/j.xgen.2025.100886 [code]
- CellWalker2: Multi-omic discovery using hierarchical cell type relationships.Journal: Cell genomicsIn common: reticulate, PyTorch, ggplot2, 6 other tools, 1 reference
- [2] doi:10.1093/bib/bbaf657 [code]
- SpaTM: topic models for inferring spatially informed transcriptional programs.Journal: Briefings in bioinformaticsIn common: reticulate, PyTorch, ggplot2, 6 other tools, 1 reference
- [3] doi:10.1186/s13059-023-02850-y [code]
- siVAE: interpretable deep generative models for single-cell transcriptomes.Journal: Genome biologyIn common: reticulate, PyTorch, ggplot2, 6 other tools, 1 reference
- [4] doi:10.1038/s41467-024-55798-3 [code]
- Interconnected pathways link faecal microbiota plasma lipids and brain activity to childhood malnutrition related cognition.Journal: Nature communicationsIn common: seaborn, scikit-learn, pandas, 3 other tools, 3 references
- [5] doi:10.1016/j.xcrm.2026.102655 [code]
- An integrative multi-omics approach identifies microbiome alterations linked to pathological and behavioral features in autism spectrum disorder.Journal: Cell reports. MedicineIn common: reticulate, ggplot2, seaborn, 5 other tools, 1 reference
- [6] doi:10.1186/s40168-025-02095-w [code]
- Distinct gut microbiome characteristics and dynamics in patients with Parkinson's disease based on the presence of premotor rapid-eye movement sleep behavior disorders.Journal: MicrobiomeIn common: ggplot2, scikit-learn, SciPy, 2 other tools, 3 references
- [7] doi:10.1038/s41531-025-01147-0 [code]
- Neural networks reveal novel gene signatures in Parkinson disease from single-nuclei transcriptomes.Journal: NPJ Parkinson's diseaseIn common: PyTorch, ggplot2, seaborn, 5 other tools, 1 reference
- [8] doi:10.1126/sciadv.adj0400 [code]
- A digital twin of the infant microbiome to predict neurodevelopmental deficits.Journal: Science advancesIn common: seaborn, scikit-learn, pandas, 3 other tools, 2 references
- [9] doi:10.1186/s40168-026-02342-8 [code]
- Impacts of host genetics on gut microbiome composition in Alzheimer's disease.Journal: MicrobiomeIn common: ggplot2, 4 references
- [10] doi:10.1371/journal.pcbi.1012101 [code]
- Balancing central control and sensory feedback produces adaptable and robust locomotor patterns in a spiking, neuromechanical model of the salamander spinal cord.Journal: PLoS computational biologyIn common: seaborn, scikit-learn, pandas, 3 other tools, 2 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 50 scripts, and 7 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:684f029030477921…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/repo/github.com/yuanx749/lgtm)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/repo/github.com/yuanx749/lgtm.svg
:target: https://openscicode.org/badge/repo/github.com/yuanx749/lgtm
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/repo/github.com/yuanx749/lgtm"><img src="https://openscicode.org/badge/repo/github.com/yuanx749/lgtm.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
