OSCR

LGTM: Gaussian process modulated neural topic modeling for longitudinal microbiome

Code ↔ Paper

7 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 7 matches
  1. [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. [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. [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. [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. [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. [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. [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

  1. #' Fit LGTM from metadata and microbiome tables
  2. #'
  3. #' Calls the existing LGTM Python API. The backend matches samples by
  4. #' `sample_id`, sorts them by subject and time, normalizes each abundance row
  5. #' to sum to one, and encodes categorical covariates.
  6. #'
  7. #' @param metadata A data frame with one row per sample and required columns
  8. #' `sample_id`, `subject_id`, and numeric `time`. Time is continuous. Extra
  9. #' columns are categorical covariates modeled through interactions with
  10. #' time. Sample IDs must be unique.
  11. #' @param microbiome A data frame with `sample_id` and one numeric abundance
  12. #' column per taxon. Sample IDs must be unique, and each abundance row must
  13. #' have a positive total. Preserve taxon names when reading the table.
  14. #' @param latent_dim Number of latent topics. Default: 6.
  15. #' @param n_epoch Number of training epochs. Default: 100.
  16. #' @param batch_size Mini-batch size. Default: 64.
  17. #' @param learning_rate Adam learning rate. Default: 0.05.
  18. #' @param hidden_dim Encoder hidden dimension. Default: 64.
  19. #' @param seed Random seed for Python, NumPy, and PyTorch. Default: 42.
  20. #' @param n_basis_functions Number of Hilbert-space basis functions for the
  21. #' squared exponential kernel approximation. Default: 5.
  22. #' @param kl_weight GP KL regularization weight. Default: 0.001.
  23. #' @param mc_samples Number of Monte Carlo samples during training. Default: 1.
  24. #' @param patience Early stopping patience. Default: 0.
  25. #' @param early_stop Enable early stopping using the training data as validation
  26. #' data. This is a full-data fit, not cross-validation. Default: TRUE.
  27. #' @param init_topics Initialize topic loadings using NNDSVD. Default: TRUE.
  28. #' @param use_encoder Use the encoder pathway during training. Default: TRUE.
  29. #'
  30. #' @returns A list containing:
  31. #' - `sample_topic`: a sample-by-topic data frame of topic proportions, with
  32. #' sample IDs as row names and `topic-1`, `topic-2`, etc. as column names.
  33. #' - `topic_taxon`: a topic-by-taxon data frame of loadings, with topic names
  34. #' as row names and taxon names as column names.
  35. #' - `model`: the fitted Python `LGTM` estimator.
  36. #'
  37. #' Both tables use the same topic order, sorted by decreasing mean
  38. #' sample-topic proportion. The Python model reference is valid only in the
  39. #' current R session; save result tables separately when using `saveRDS()`.
  40. #' @examples
  41. #' \dontrun{
  42. #' metadata <- read.csv("metadata.csv", check.names = FALSE)
  43. #' microbiome <- read.csv("microbiome.csv", check.names = FALSE)
  44. #' fit <- lgtm_fit(
  45. #' metadata,
  46. #' microbiome,
  47. #' latent_dim = 6,
  48. #' n_epoch = 100,
  49. #' seed = 42
  50. #' )
  51. #' fit$sample_topic
  52. #' fit$topic_taxon
  53. #' }
  54. #' @export
  55. lgtm_fit <- function(
  56. metadata,
  57. microbiome,
  58. latent_dim = 6L,
  59. n_epoch = 100L,
  60. batch_size = 64L,
  61. learning_rate = 0.05,
  62. hidden_dim = 64L,
  63. seed = 42L,
  64. n_basis_functions = 5L,
  65. kl_weight = 0.001,
  66. mc_samples = 1L,
  67. patience = 0L,
  68. early_stop = TRUE,
  69. init_topics = TRUE,
  70. use_encoder = TRUE
  71. ) {
  72. lgtm <- reticulate::import("lgtm")
  73. config <- lgtm$LGTMConfig(
  74. latent_dim = as.integer(latent_dim),
  75. n_epoch = as.integer(n_epoch),
  76. batch_size = as.integer(batch_size),
  77. learning_rate = learning_rate,
  78. hidden_dim = as.integer(hidden_dim),
  79. seed = as.integer(seed),
  80. n_basis_functions = as.integer(n_basis_functions),
  81. kl_weight = kl_weight,
  82. mc_samples = as.integer(mc_samples),
  83. patience = as.integer(patience),
  84. early_stop = early_stop,
  85. init_topics = init_topics,
  86. use_encoder = use_encoder
  87. )
  88. model <- lgtm$LGTM(config)
  89. model$fit(metadata, microbiome)
  90. list(
  91. sample_topic = model$sample_topic_,
  92. topic_taxon = model$topic_taxon_,
  93. model = model
  94. )
  95. }
  96. #' Plot LGTM results
  97. #'
  98. #' Reuses the Python API's Matplotlib figures. When `show = TRUE`, a PNG preview
  99. #' is drawn on the R graphics device. The original Figure and Axes remain
  100. #' available for customization and vector export with `figure$savefig()`.
  101. #'
  102. #' @param fit A result from [lgtm_fit()].
  103. #' @param type Plot type: `"si"` for covariate importance, `"topics"` for the
  104. #' topic overview, `"topic"` for one topic's taxon loadings, `"gp"` for GP
  105. #' components, or `"latent"` for observed sample-topic proportions.
  106. #' @param topic One-based topic number, sorted by decreasing mean proportion.
  107. #' Used for `"topic"`, `"gp"`, and `"latent"`. Default: 1.
  108. #' @param ... Arguments forwarded to the corresponding Python plotting method.
  109. #' See Details for supported arguments and their defaults.
  110. #' @param show Draw a preview on the R graphics device. Default: TRUE.
  111. #' @param dpi Resolution of the PNG preview. Default: 300.
  112. #'
  113. #' @details
  114. #' Plot-specific arguments follow the Python API:
  115. #' - `"si"`: `rotation = 45` sets the angle of covariate labels in degrees.
  116. #' - `"topics"`: `top_k = 5` limits the taxa shown per topic; `threshold = 0.01`
  117. #' is the minimum absolute loading for display; `num_plot = NULL` shows all
  118. #' topics, or an integer limits the number shown.
  119. #' - `"topic"`: `top_n = 20` sets the number of taxa considered;
  120. #' `threshold = 0.01` controls which taxa are annotated;
  121. #' `figsize = c(18, 2)` sets the figure size.
  122. #' - `"gp"`: `repeats = 5` sets the number of stochastic GP draws used for
  123. #' uncertainty bands; `figsize = c(18, 3)` sets the figure size;
  124. #' `plot_id = FALSE` omits subject-ID GP components.
  125. #' - `"latent"`: `figsize = c(18, 3)` sets the figure size;
  126. #' `plot_pointplot = FALSE` disables group mean points; `plot_id = FALSE`
  127. #' omits subject-ID panels.
  128. #'
  129. #' Use a numeric vector of length two for `figsize`, in inches.
  130. #'
  131. #' @returns Invisibly, a list containing the original Matplotlib `figure` and
  132. #' its `axes`. The Figure is removed from pyplot's registry after plotting
  133. #' but remains usable through this list.
  134. #' @examples
  135. #' \dontrun{
  136. #' lgtm_plot(fit, type = "si")
  137. #' plot_result <- lgtm_plot(fit, type = "gp", topic = 1)
  138. #' plot_result$figure$savefig("gp.svg", bbox_inches = "tight")
  139. #' }
  140. #' @export
  141. lgtm_plot <- function(
  142. fit,
  143. type = c("si", "topics", "topic", "gp", "latent"),
  144. topic = 1L,
  145. ...,
  146. show = TRUE,
  147. dpi = 300
  148. ) {
  149. type <- match.arg(type)
  150. method <- switch(
  151. type,
  152. si = fit$model$plot_si,
  153. topics = fit$model$plot_topics,
  154. topic = fit$model$plot_topic,
  155. gp = fit$model$plot_gp,
  156. latent = fit$model$plot_latent
  157. )
  158. args <- list(...)
  159. for (name in intersect(
  160. names(args),
  161. c("top_k", "num_plot", "top_n", "repeats")
  162. )) {
  163. if (!is.null(args[[name]])) {
  164. args[[name]] <- as.integer(args[[name]])
  165. }
  166. }
  167. if (type %in% c("topic", "gp", "latent")) {
  168. args$topic <- as.integer(topic)
  169. }
  170. result <- do.call(method, args)
  171. figure <- result[[1L]]
  172. plt <- reticulate::import("matplotlib.pyplot")
  173. on.exit(plt$close(figure), add = TRUE)
  174. if (show) {
  175. buffer <- reticulate::import("io")$BytesIO()
  176. on.exit(buffer$close(), add = TRUE)
  177. figure$savefig(buffer, format = "png", dpi = dpi, bbox_inches = "tight")
  178. preview <- png::readPNG(as.raw(buffer$getvalue()))
  179. grid::grid.newpage()
  180. grid::grid.raster(preview)
  181. }
  182. invisible(list(figure = figure, axes = result[[2L]]))
  183. }

lgtm.R at commit 57c1d06, under MIT · at the source

Overview

Authors: Xiao Yuan1,2, Ádám Arany3, András Formanek3,4, Yves Moreau3, Harri Lähdesmäki2, Tommi Vatanen1,5,6,7,8
  1. Institute of Biotechnology, Helsinki Institute of Life Science, University of Helsinki, Helsinki, Finland
  2. Department of Computer Science, Aalto University, Espoo, Finland
  3. Department of Electrical Engineering (ESAT), STADIUS Center for Dynamical Systems, Signal Processing and Data Analytics, Leuven, Belgium
  4. Department of Artificial Intelligence and Systems Engineering, Faculty of Electrical Engineering and Informatics, Budapest University of Technology and Economics, Budapest, Hungary
  5. Department of Microbiology, Faculty of Agriculture and Forestry, University of Helsinki, Helsinki, Finland
  6. Research Program for Clinical and Molecular Metabolism, Faculty of Medicine, University of Helsinki, Helsinki, Finland
  7. Broad Institute of MIT and Harvard, Cambridge, MA, USA
  8. Liggins Institute, University of Auckland, Auckland, New Zealand
Journal: Gut Microbes, volume 18, issue 1, article 2741488
Dates: received 26 February 2026; accepted 25 September 2026; published online 5 October 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI · PMCID PMC13644641
Status: code verified (how the code is found and verified)
Methods: Spectral & time-frequency, Machine learning
Keywords: Metagenome, longitudinal study, Gaussian process, topic model, autoencoder
Citations: not cited yet (Europe PMC); 73 references in the paper

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://github.com/yuanx749/lgtm.

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

License: MIT
State: the link answers, verified on 8 October 2026
Evidence: files inventoried
Commit: 57c1d0639dc00fe360d9ae9cb4c244c64640dca2, 19 September 2026
Languages: Python (20), R (4), Jupyter (1), Shell (1)
Size: 40 files, 26 scripts
Software Heritage: not archived
Found in: “Data availability statement”
Holds: README, license file, environment (pyproject.toml, r/DESCRIPTION, src/lgtm/streamlit_app/requirements.txt), documentation, 1 notebook
Not found: CITATION.cff, tests, continuous integration
Tools: NumPy (15 files), PyTorch (9 files), Matplotlib (5 files), pandas (4 files), scikit-learn (3 files), SciPy (3 files), seaborn (3 files), ggplot2 (2 files), reticulate (2 files)
Availability: 1 check, the latest on 8 October 2026: the link answers
  • 8 October 2026: the link answers
28 files

Zenodo 20588704

License: MIT
State: the link answers, verified on 8 October 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Data availability statement”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (15 files), PyTorch (9 files), Matplotlib (5 files), pandas (4 files), scikit-learn (3 files), SciPy (3 files), seaborn (3 files), ggplot2 (2 files)
Availability: 1 check, the latest on 8 October 2026: the link answers (HTTP 200)
  • 8 October 2026: the link answers (HTTP 200)
26 files

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://github.com/yuanx749/lgtm. An archived version of the code is available on Zenodo at https://doi.org/10.5281/zenodo.20588704. Data from the DIABIMMUNE and Dhaka studies are available at NCBI Sequence Read Archive under BioProject IDs PRJNA497734 and PRJNA806984, respectively. DIABIMMUNE data can also be accessed through the DIABIMMUNE microbiome website at https://diabimmune.broadinstitute.org/. Microbiome profiles of the HMP2 study are publicly available via the IBDMDB at https://ibdmdb.org/.

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/10/08
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": "Gut Microbes",
"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 genomics
In 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 bioinformatics
In 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 biology
In 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 communications
In 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. Medicine
In 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: Microbiome
In 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 disease
In 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 advances
In 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: Microbiome
In 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 biology
In 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.

Add the badge to the code's README

OSCR: the badge of this paper

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 -->
[![OSCR](https://openscicode.org/badge/repo/github.com/yuanx749/lgtm.svg)](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:end
HTML
<!-- 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.