Skip to main content

TriGer

Modules of features that are densely associated across two omics layers and coherent within each layer, detected with a triple-graph model.

Multi-omics integration released R Python MATLAB

TriGer (triple-graph model) detects modules of features from two omics layers \(X\) and \(Y\). It uses three association matrices: the cross-omics matrix between \(X\) and \(Y\), and the within-omics correlation matrices of \(X\) and of \(Y\). Dense blocks are first extracted from the cross-omics matrix by greedy peeling, and large blocks are then refined with the within-omics matrices. Each module is therefore densely associated across the two layers and coherent within each layer. The parameter lambda1 is the size penalty of the cross-omics step, and lambda2 and lambda3 are the within-omics penalties for \(X\) and \(Y\); larger values give smaller, denser modules.

Platforms

Platform Package Install Documentation
R TriGer remotes::install_github("MATRIX-Research-Lab/TriGer") GitHub · vignette("TriGer")
Python triger (PyPI) pip install triger PyPI · GitHub
MATLAB TriGer functions (Jiaao Yu) Clone the repository; add matlab/methods and matlab/visualization to the path GitHub

The R package is installed from GitHub; its Bioconductor submission is under review. The R and Python packages give identical results on the same input. The MATLAB implementation is by Jiaao Yu; its repository also contains the code for the simulations and real-data analyses of the paper.

Extended tutorial

The R tutorial detects modules of gut bacterial genera and stool metabolites in the PRISM and validation cohorts of Franzosa et al. (2019), which include patients with Crohn’s disease (CD), patients with ulcerative colitis (UC), and controls. The data are the processed metagenomic and metabolomic tables of the curated microbiome–metabolome collection of Muller et al. (2022). The modules are detected from all samples, and the strength of each module is then compared between the diagnosis groups.

Select a platform.

Model

Let \(\mathbf{X}\) denote the \(n \times m\) matrix of the first omics layer and \(\mathbf{Y}\) the \(n \times q\) matrix of the second, with the same \(n\) samples in rows. Let \(\mathbf{Z} = [\mathbf{X} \mid \mathbf{Y}]\) denote their combination, with \(m + q\) columns. Let \(r_{ab}\) denote the correlation of columns \(a\) and \(b\) of \(\mathbf{Z}\), and let \(p_{ab}\) denote the p-value of the test of zero correlation. TriGer uses the \((m + q) \times (m + q)\) matrices

\[ \mathbf{R} = (r_{ab}) \]

and

\[ \mathbf{P} = (-\log_{10} p_{ab}). \]

The cross-omics block of \(\mathbf{P}\), with rows \(1, \ldots, m\) and columns \(m + 1, \ldots, m + q\), defines a weighted bipartite graph between the features of \(X\) and \(Y\). The within-omics blocks of \(\mathbf{R}\) define one weighted graph for each layer; together with the bipartite graph they form the triple graph. In the first step, TriGer extracts dense blocks of the bipartite graph by greedy peeling, with size penalty \(\lambda_1\). In the second and third steps, the \(X\) side and the \(Y\) side of each block that exceeds a maximum size are divided into dense communities of the corresponding within-omics graph, with size penalties \(\lambda_2\) and \(\lambda_3\). A module is a resulting set of \(X\) features and \(Y\) features.

Data

The \(X\) layer consists of the bacterial genera with a prevalence of at least 50% and a mean relative abundance of at least 0.2%, on the centered log-ratio (CLR) scale. The \(Y\) layer consists of the named metabolites with at most 30% zeros, on the log scale; features with the same HMDB identifier, or without one and with names that differ only by a trailing asterisk, are treated as one compound. In both layers, zeros are replaced by half of the smallest positive value of the feature.

library(TriGer)
library(tidyverse)

url <- paste0("https://raw.githubusercontent.com/borenstein-lab/",
              "microbiome-metabolome-curated-data/main/data/processed_data/",
              "FRANZOSA_IBD_2019/")

meta <- read.delim(paste0(url, "metadata.tsv"), check.names = FALSE)
fmap <- read.delim(paste0(url, "mtb.map.tsv"), check.names = FALSE)
mtb  <- as.matrix(read.delim(paste0(url, "mtb.tsv"), check.names = FALSE, row.names = 1))
gen  <- as.matrix(read.delim(paste0(url, "genera.tsv"), check.names = FALSE, row.names = 1))
stopifnot(identical(rownames(mtb), meta$Sample), identical(rownames(gen), meta$Sample))

half_min <- function(v) { v[v == 0] <- min(v[v > 0]) / 2; v }

# X: genera, CLR over the retained genera.
gen <- gen[, colMeans(gen > 0) >= 0.5 & colMeans(gen) >= 0.002]
colnames(gen) <- sub(".*;g__", "", colnames(gen))
log_gen <- log(apply(gen, 2, half_min))
x <- log_gen - rowMeans(log_gen)

# Y: named metabolites, one feature per compound, log scale.
named <- fmap |>
  filter(!is.na(Compound.Name), Compound %in% colnames(mtb)) |>
  mutate(name = str_remove(Compound.Name, "[*]+$"),
         key  = coalesce(HMDB, name),
         zero = colMeans(mtb[, Compound] == 0)) |>
  arrange(key, zero) |>
  distinct(key, .keep_all = TRUE) |>
  distinct(name, .keep_all = TRUE) |>
  filter(zero <= 0.3)
y <- log(apply(mtb[, named$Compound], 2, half_min))
colnames(y) <- named$name

c(samples = nrow(x), genera = ncol(x), metabolites = ncol(y))
#>     samples      genera metabolites 
#>         220          73         291

Analysis

res <- triger(x, y, method = "spearman",
              lambda1 = 1.5, lambda2 = 1.8, lambda3 = 1.8,
              X_size = c(3, 25), Y_size = c(5, 50))
length(res$modules)
#> [1] 2
Argument Role
method Correlation used for \(\mathbf{R}\) and \(\mathbf{P}\): "pearson" or "spearman".
lambda1 Size penalty \(\lambda_1\) of the cross-omics step; larger values give smaller, denser blocks.
lambda2, lambda3 Size penalties \(\lambda_2\) and \(\lambda_3\) of the within-omics steps for \(X\) and \(Y\).
X_size, Y_size c(min, max): blocks with min or fewer features on a side are dropped, and sides with more than max features are refined.
max_blocks Maximum number of blocks of the cross-omics step (default 5).

The result contains the list modules, the matrices R and P over the \(m + q\) features, and the numbers of features m and n of the two layers. Each module holds the column indices X and Y, the feature names X_names and Y_names, and the density of its block.

Modules

modules <- imap(res$modules, function(b, k) {
  tibble(module = k, layer = c(rep("genus", length(b$X)), rep("metabolite", length(b$Y))),
         feature = c(b$X_names, b$Y_names))
}) |> list_rbind()

modules |>
  summarise(features = paste(feature, collapse = ", "), .by = c(module, layer)) |>
  knitr::kable(caption = "Features of each module.")
Features of each module.
module layer features
1 genus Faecousia, Veillonella, CAG-83, Faecalimonas, Ruminococcus_B, ER4, Enterocloster, Blautia, CAG-170, CAG-103
1 metabolite C18:0e MAG, C18:1 carnitine, C16 carnitine, ketodeoxycholate, alpha-muricholate, chenodeoxycholate, cholate, docosapentaenoate, N-acetylputrescine, palmitoylethanolamide, adrenic acid, eicosatrienoic acid, urobilin, C18:2 carnitine
2 genus Escherichia, Alistipes, Lactobacillus, Limosilactobacillus, Streptococcus, Evtepia, Enterococcus_B, Haemophilus_D, UBA1417, Klebsiella, Adlercreutzia
2 metabolite 2-hydroxy-3-methylpentanoic acid / leucinic acid, ADMA/SDMA, C16:0 LPC, C16:0 ceramide (d18:1), C20:4 carnitine, creatine, guanine, thiamine, taurine, 2-methylglutaric acid, 3-methyladipate-pimelate, creatinine, erythronic acid, dodecanedioic acid, deoxycholic acid, lithocholic acid, hydrocinnamic acid, azelaic acid, sebacate, pentadecanoate, undecanedionate, suberate, cholestenone, 2-hydroxyphenethylamine, putrescine, pyridoxamine, ADMA, carnosol, diacetylspermine, 2-hydroxymyristic acid, phytosphingosine, linoleoyl ethanolamide, 2-hydroxyhexadecanoate, L-1,2,3,4-tetrahydro-beta-carboline-3-carboxylic acid, 4-hydroxy-3-methylacetophenone, cystine
m <- res$m
q <- res$n
plot3in1_v1(res$R[1:m, 1:m], res$R[m + 1:q, m + 1:q], res$R[1:m, m + 1:q],
            res$modules, line = TRUE, step = c(10, 50))
Figure 1: Correlation matrices of the module features. The square is the cross-omics matrix of genera (columns) and metabolites (rows); the triangles are the within-omics matrices of the genera (top) and of the metabolites (right). Red boxes mark the modules.
b <- res$modules[[1]]
cor(x[, b$X_names], y[, b$Y_names], method = "spearman") |>
  as_tibble(rownames = "genus") |>
  pivot_longer(-genus, names_to = "metabolite", values_to = "r") |>
  ggplot(aes(x = genus, y = metabolite, fill = r)) +
  geom_tile(color = "white") +
  scale_fill_gradient2(low = "#466675", mid = "white", high = "#a63d2f", limits = c(-1, 1)) +
  labs(x = NULL, y = NULL, fill = "Spearman r") +
  theme_minimal(base_size = 11) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))
Figure 2: Spearman correlations between the genera and the metabolites of module 1, from all samples.

Modules by diagnosis

The modules are detected from all samples, so their associations can include differences between the diagnosis groups. The mean absolute Spearman correlation of the genus–metabolite pairs of each module, computed within each group, describes the association within the groups.

by_group <- expand_grid(module = seq_along(res$modules),
                        diagnosis = c("Control", "CD", "UC")) |>
  mutate(n = map_int(diagnosis, \(g) sum(meta$Study.Group == g)),
         mean_abs_r = map2_dbl(module, diagnosis, function(k, g) {
           s <- meta$Study.Group == g
           b <- res$modules[[k]]
           mean(abs(cor(x[s, b$X_names], y[s, b$Y_names], method = "spearman")))
         }))

by_group |>
  pivot_wider(id_cols = module, names_from = diagnosis, values_from = mean_abs_r) |>
  knitr::kable(digits = 2, caption = "Mean absolute genus-metabolite Spearman correlation of each module, by diagnosis.")
Mean absolute genus-metabolite Spearman correlation of each module, by diagnosis.
module Control CD UC
1 0.36 0.32 0.49
2 0.16 0.29 0.34

Session information

Code
sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: aarch64-apple-darwin23
#> Running under: macOS Sequoia 15.8.3
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
#> 
#> locale:
#> [1] en_US/C.UTF-8/en_US/C/en_US/en_US
#> 
#> time zone: America/New_York
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] lubridate_1.9.5 forcats_1.0.1   stringr_1.6.0   dplyr_1.2.1    
#>  [5] purrr_1.2.2     readr_2.2.0     tidyr_1.3.2     tibble_3.3.1   
#>  [9] ggplot2_4.0.4   tidyverse_2.0.0 TriGer_0.99.0  
#> 
#> loaded via a namespace (and not attached):
#>  [1] gtable_0.3.6       jsonlite_2.0.0     compiler_4.6.2     tidyselect_1.2.1  
#>  [5] scales_1.4.0       yaml_2.3.12        fastmap_1.2.0      R6_2.6.1          
#>  [9] labeling_0.4.3     generics_0.1.4     knitr_1.52         htmlwidgets_1.6.4 
#> [13] pillar_1.11.1      RColorBrewer_1.1-3 tzdb_0.5.0         rlang_1.3.0       
#> [17] stringi_1.8.9      xfun_0.62          S7_1.0.0           otel_0.3.0        
#> [21] timechange_0.4.0   cli_3.6.6          withr_3.0.3        magrittr_2.0.5    
#> [25] digest_0.6.39      grid_4.6.2         hms_1.1.4          lifecycle_1.0.5   
#> [29] vctrs_0.7.3        evaluate_1.0.5     glue_1.8.1         farver_2.1.2      
#> [33] rmarkdown_2.32     tools_4.6.2        pkgconfig_2.0.3    htmltools_0.5.9

The code in this tab is shown for reference and is not executed on this page. The Python package gives the same modules as the R package on the same input; indices are 0-based.

pip install triger
import triger

# x: samples x genera (CLR); y: samples x metabolites (log), as pandas DataFrames
# with the same sample index, prepared as in the R tab.
res = triger.triger(x, y, method="spearman",
                    lambda1=1.5, lambda2=1.8, lambda3=1.8,
                    X_size=(3, 25), Y_size=(5, 50))

for k, mod in enumerate(res.modules, start=1):
    print(k, mod.X_names, mod.Y_names)

m = res.m
triger.plot3in1_v1(res.R[:m, :m], res.R[m:, m:], res.R[:m, m:], res.modules,
                   line=True)

The lower-level functions are listed in the package README.

The code in this tab is shown for reference and is not executed on this page. It applies the three steps to precomputed matrices P and R over the \(m + q\) features.

addpath('matlab/methods'); addpath('matlab/visualization')

result = greedy_3step(P, R, m, q, 1.5, 1.8, 1.8, [3 25], [5 50]);
plot3in1_v1(R(1:m, 1:m), R(m+1:end, m+1:end), R(1:m, m+1:end), result, true, [10 50]);

The functions and the real-data analyses of the paper are in the MATLAB repository.

Data sources

Franzosa EA, Sirota-Madi A, Avila-Pacheco J, et al. Gut microbiome structure and metabolic activity in inflammatory bowel disease. Nature Microbiology 4:293–305 (2019). doi:10.1038/s41564-018-0306-4

Muller E, Algavi YM, Borenstein E. The gut microbiome-metabolome dataset collection: a curated resource for integrative meta-analysis. npj Biofilms and Microbiomes 8:79 (2022). doi:10.1038/s41522-022-00345-5

Citation

Yu J, Lin H, Chen S. Structured cross-omics interaction discovery with a triple-graph model. bioRxiv (2026). doi:10.64898/2026.09.10.749540