| Title: | Structured Cross-Omics Interaction Discovery with a Triple-Graph Model |
|---|---|
| Description: | Detects modules of features that are densely associated across two omics layers and coherent within each layer. Dense cross-omics blocks are found by greedy peeling of the cross-omics association matrix, and large blocks are refined by greedy peeling of the within-omics correlation matrices. Input can be numeric matrices or SummarizedExperiment objects. Plotting functions show the detected modules alongside the within-omics correlation structure. The method is described in Yu, Lin and Chen (2026) <doi:10.64898/2026.09.10.749540>. |
| Authors: | Jiaao Yu [aut], Huang Lin [aut, cre] (ORCID: <https://orcid.org/0000-0002-4892-7871>) |
| Maintainer: | Huang Lin <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.0 |
| Built: | 2026-11-23 03:00:13 UTC |
| Source: | https://github.com/BiocStaging/TriGer |
The TriGer pipeline on precomputed matrices. Step 1 peels dense blocks
from the cross-omics part of P with greedy_peeling_XY_all(). Blocks
with X_size[1] or fewer X features, or Y_size[1] or fewer Y features,
are dropped. In steps 2 and 3, the X and Y sides of blocks with more than
X_size[2] or Y_size[2] features are refined by within-omics peeling of
the signed correlations in R: the side is replaced by the communities
with at least min_community_size features, each ordered by within-
community sums. triger() computes P and R from data and calls this
function.
greedy_3step( P, R, m, n, lambda1 = 1.5, lambda2 = 1.5, lambda3 = 1.5, X_size = c(10, 200), Y_size = c(10, 200), min_community_size = 2, keep_unrefined_if_empty = TRUE, max_blocks = 5 )greedy_3step( P, R, m, n, lambda1 = 1.5, lambda2 = 1.5, lambda3 = 1.5, X_size = c(10, 200), Y_size = c(10, 200), min_community_size = 2, keep_unrefined_if_empty = TRUE, max_blocks = 5 )
P |
|
R |
|
m, n
|
Numbers of X and Y features. |
lambda1 |
Cross-omics size penalty (step 1). |
lambda2, lambda3
|
Within-omics size penalties for X and Y (steps 2 and 3). |
X_size, Y_size
|
|
min_community_size |
Smallest within-omics community kept during refinement. |
keep_unrefined_if_empty |
If refinement keeps no community, keep that
side of the block unrefined ( |
max_blocks |
Maximum number of blocks found in step 1. |
A list of modules, each list(X, Y, density), with X in 1:m,
Y in 1:n, and density the penalized density of the step-1 block
before refinement.
set.seed(1) N <- 150 m <- 80 n <- 120 f <- rnorm(N) X <- matrix(rnorm(N * m), N) Y <- matrix(rnorm(N * n), N) X[, 1:25] <- X[, 1:25] + 1.5 * f Y[, 1:40] <- Y[, 1:40] + 1.5 * f R <- cor(cbind(X, Y)) P <- abs(R) diag(P) <- 0 modules <- greedy_3step(P, R, m, n, lambda1 = 1.1, lambda2 = 1.8, lambda3 = 1.8) lengths(modules[[1]][c("X", "Y")])set.seed(1) N <- 150 m <- 80 n <- 120 f <- rnorm(N) X <- matrix(rnorm(N * m), N) Y <- matrix(rnorm(N * n), N) X[, 1:25] <- X[, 1:25] + 1.5 * f Y[, 1:40] <- Y[, 1:40] + 1.5 * f R <- cor(cbind(X, Y)) P <- abs(R) diag(P) <- 0 modules <- greedy_3step(P, R, m, n, lambda1 = 1.1, lambda2 = 1.8, lambda3 = 1.8) lengths(modules[[1]][c("X", "Y")])
Applies greedy_peeling_X_one() repeatedly, removing each accepted
community before the next round, while the community's penalized density
exceeds that of the full matrix.
greedy_peeling_X_all(Wp, lam, min_size = 1)greedy_peeling_X_all(Wp, lam, min_size = 1)
Wp |
Symmetric matrix of within-omics associations, for example signed correlations. |
lam |
Size penalty, typically in [1, 2]. Higher values give smaller, denser blocks. |
min_size |
Smallest community returned. Communities with fewer features are peeled but not returned. The default, 1, returns every community. |
A list of communities, each list(X, density), with indices into
the rows of Wp.
set.seed(1) S <- matrix(runif(50 * 50, -0.2, 0.2), 50, 50) S[1:12, 1:12] <- S[1:12, 1:12] + 0.9 S <- (S + t(S)) / 2 comms <- greedy_peeling_X_all(S, 1.5) comms[[1]]$Xset.seed(1) S <- matrix(runif(50 * 50, -0.2, 0.2), 50, 50) S[1:12, 1:12] <- S[1:12, 1:12] + 0.9 S <- (S + t(S)) / 2 comms <- greedy_peeling_X_all(S, 1.5) comms[[1]]$X
Greedily removes the feature with the smallest remaining sum and keeps the
intermediate subset with the highest penalized density, sum / size^lam.
greedy_peeling_X_one(Wp, lam)greedy_peeling_X_one(Wp, lam)
Wp |
Symmetric matrix of within-omics associations, for example signed correlations. |
lam |
Size penalty, typically in [1, 2]. Higher values give smaller, denser blocks. |
A list with density and X (indices of the community).
set.seed(1) S <- matrix(runif(50 * 50, -0.2, 0.2), 50, 50) S[1:12, 1:12] <- S[1:12, 1:12] + 0.9 S <- (S + t(S)) / 2 greedy_peeling_X_one(S, 1.5)$Xset.seed(1) S <- matrix(runif(50 * 50, -0.2, 0.2), 50, 50) S[1:12, 1:12] <- S[1:12, 1:12] + 0.9 S <- (S + t(S)) / 2 greedy_peeling_X_one(S, 1.5)$X
Applies greedy_peeling_XY_one() repeatedly, removing the rows and
columns of each accepted block before the next round. A block is accepted
while its penalized density exceeds that of the full matrix, up to
max_blocks blocks.
greedy_peeling_XY_all(XY, lam = 1.5, max_blocks = 5)greedy_peeling_XY_all(XY, lam = 1.5, max_blocks = 5)
XY |
Non-negative cross-omics association matrix. |
lam |
Size penalty, typically in [1, 2]. Higher values give smaller, denser blocks. |
max_blocks |
Maximum number of blocks returned. |
A list of blocks, each list(X, Y, density), with indices into
the rows (X) and columns (Y) of XY.
set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blocks <- greedy_peeling_XY_all(W, 1.5) lengths(blocks[[1]][c("X", "Y")])set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blocks <- greedy_peeling_XY_all(W, 1.5) lengths(blocks[[1]][c("X", "Y")])
Greedily removes the X feature (row) or Y feature (column) with the
weakest remaining association and keeps the intermediate submatrix with
the highest penalized density, sum / (|X| * |Y|)^(lam / 2). A row is
removed when its sum, scaled by the current ratio |X| / |Y|, is at most
the smallest column sum; otherwise a column is removed.
greedy_peeling_XY_one(Wp, lam)greedy_peeling_XY_one(Wp, lam)
Wp |
Non-negative matrix of cross-omics associations (X features in rows, Y features in columns), for example -log10 p-values. |
lam |
Size penalty, typically in [1, 2]. Higher values give smaller, denser blocks. |
A list with density (the penalized density of the block), X
(row indices) and Y (column indices).
set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blk <- greedy_peeling_XY_one(W, 1.5) range(blk$X) range(blk$Y)set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blk <- greedy_peeling_XY_one(W, 1.5) range(blk$X) range(blk$Y)
The jet colour map used by the plotting functions.
matlab_jet(m = 256)matlab_jet(m = 256)
m |
Number of colours. |
A character vector of m colours.
matlab_jet(8)matlab_jet(8)
Shows Wp reordered so that the features of the detected blocks come
first. With full = TRUE the whole matrix is shown with one box around
the selected region; otherwise only the selected region is shown, with one
box per block.
plot_all_result(Wp, result, full = FALSE, line = TRUE, crange = NULL)plot_all_result(Wp, result, full = FALSE, line = TRUE, crange = NULL)
Wp |
The matrix the blocks were detected in. |
result |
A list of blocks, each with X indices first and Y indices
second; for a symmetric |
full |
Show the full matrix. |
line |
Draw boxes around the blocks. |
crange |
Colour limits; defaults to the range of the plotted values. |
Invisibly, the plotted matrix.
set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 plot_all_result(W, greedy_peeling_XY_all(W, 1.5), full = TRUE)set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 plot_all_result(W, greedy_peeling_XY_all(W, 1.5), full = TRUE)
Draws the cross-omics matrix restricted to the selected features as a heatmap, with the X-X and Y-Y matrices of the same features as rotated triangles on the top and right. Draws into the current graphics device; a 5.6 x 4.2 inch device matches the default layout.
plot3in1_v1( X, Y, XY, result, line = FALSE, step = NULL, bar = FALSE, figsize = c(5.6, 4.2), cbar_pos = c(0.15, 0.13, 0.013, 0.45), clim_tri = NULL, clim_mid = NULL, box_lw = 2 )plot3in1_v1( X, Y, XY, result, line = FALSE, step = NULL, bar = FALSE, figsize = c(5.6, 4.2), cbar_pos = c(0.15, 0.13, 0.013, 0.45), clim_tri = NULL, clim_mid = NULL, box_lw = 2 )
X, Y
|
Within-omics matrices for the X and Y features. |
XY |
Cross-omics matrix (X features in rows). |
result |
A list of blocks, each with X indices first and Y indices
second, as returned by |
line |
Draw a box around each block. |
step |
|
bar |
Add a colour bar for the middle panel. |
figsize |
Device size in inches, used to keep the panels square. |
cbar_pos |
Colour bar position |
clim_tri, clim_mid
|
Colour limits for the triangles and the middle
panel. By default |
box_lw |
Line width of the block boxes, in points. |
Invisibly, a list with the plotted X and Y indices.
set.seed(1) N <- 150 m <- 80 n <- 60 f <- rnorm(N) X <- matrix(rnorm(N * m), N) Y <- matrix(rnorm(N * n), N) X[, 1:25] <- X[, 1:25] + 1.5 * f Y[, 1:20] <- Y[, 1:20] + 1.5 * f R <- cor(cbind(X, Y)) P <- abs(R) diag(P) <- 0 modules <- greedy_3step(P, R, m, n, 1.1, 1.8, 1.8) plot3in1_v1(R[1:m, 1:m], R[m + 1:n, m + 1:n], R[1:m, m + 1:n], modules, line = TRUE, step = c(10, 5))set.seed(1) N <- 150 m <- 80 n <- 60 f <- rnorm(N) X <- matrix(rnorm(N * m), N) Y <- matrix(rnorm(N * n), N) X[, 1:25] <- X[, 1:25] + 1.5 * f Y[, 1:20] <- Y[, 1:20] + 1.5 * f R <- cor(cbind(X, Y)) P <- abs(R) diag(P) <- 0 modules <- greedy_3step(P, R, m, n, 1.1, 1.8, 1.8) plot3in1_v1(R[1:m, 1:m], R[m + 1:n, m + 1:n], R[1:m, m + 1:n], modules, line = TRUE, step = c(10, 5))
sort_result() orders the features of each block by their within-block
sums in Wp; for a cross-omics Wp, rows and columns are ordered by the
absolute values of their sums. sort_result_XandY() orders X features by
their sums within X[blk$X, blk$X] and Y features by their sums within
Y[blk$Y, blk$Y].
sort_result(Wp, blocks, symmetric = NULL) sort_result_XandY(X, Y, blocks)sort_result(Wp, blocks, symmetric = NULL) sort_result_XandY(X, Y, blocks)
Wp |
The matrix the blocks were detected in. |
blocks |
A list of blocks, as returned by |
symmetric |
Whether |
X, Y
|
Within-omics matrices for the X and Y features. |
blocks with the features of each block reordered.
set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blocks <- sort_result(W, greedy_peeling_XY_all(W, 1.5)) head(blocks[[1]]$X)set.seed(1) W <- matrix(runif(60 * 80, 0, 0.5), 60, 80) W[6:20, 11:30] <- W[6:20, 11:30] + 4 blocks <- sort_result(W, greedy_peeling_XY_all(W, 1.5)) head(blocks[[1]]$X)
Runs the TriGer pipeline on two omics layers measured on the same
samples. triger_association() computes the cross- and within-omics
correlations and their -log10 p-values, and greedy_3step() finds blocks
of X and Y features that are densely associated across the two layers and
refines large blocks by within-omics peeling.
triger( x, y, lambda1 = 1.5, lambda2 = 1.5, lambda3 = 1.5, X_size = c(10, 200), Y_size = c(10, 200), method = c("pearson", "spearman"), assay_x = 1, assay_y = 1, ... )triger( x, y, lambda1 = 1.5, lambda2 = 1.5, lambda3 = 1.5, X_size = c(10, 200), Y_size = c(10, 200), method = c("pearson", "spearman"), assay_x = 1, assay_y = 1, ... )
x, y
|
The two omics layers: numeric matrices or data frames with samples in rows and features in columns, or SummarizedExperiment::SummarizedExperiment objects with features in rows and samples in columns. |
lambda1 |
Cross-omics size penalty (step 1). Higher values give smaller, denser blocks. |
lambda2, lambda3
|
Within-omics size penalties for X and Y (steps 2 and 3). |
X_size, Y_size
|
|
method |
Correlation coefficient: |
assay_x, assay_y
|
Assay used when |
... |
Further arguments to |
Samples are matched by name when both layers carry sample names (row
names of a matrix, column names of a SummarizedExperiment); y is then
reordered to the sample order of x. Without sample names, the samples
must be in the same order.
A list with
modulesA list of modules, each list(X, Y, density, X_names, Y_names), where X and Y index the features of x and y and
density is the penalized density of the step-1 block.
R, P, m, n
The output of triger_association().
set.seed(1) N <- 100 f <- rnorm(N) x <- matrix(rnorm(N * 40), N, dimnames = list(NULL, paste0("g", 1:40))) y <- matrix(rnorm(N * 30), N, dimnames = list(NULL, paste0("m", 1:30))) x[, 1:12] <- x[, 1:12] + f y[, 1:8] <- y[, 1:8] + f res <- triger(x, y, lambda1 = 1.3, X_size = c(3, 50), Y_size = c(3, 50)) res$modules[[1]]$X_names res$modules[[1]]$Y_namesset.seed(1) N <- 100 f <- rnorm(N) x <- matrix(rnorm(N * 40), N, dimnames = list(NULL, paste0("g", 1:40))) y <- matrix(rnorm(N * 30), N, dimnames = list(NULL, paste0("m", 1:30))) x[, 1:12] <- x[, 1:12] + f y[, 1:8] <- y[, 1:8] + f res <- triger(x, y, lambda1 = 1.3, X_size = c(3, 50), Y_size = c(3, 50)) res$modules[[1]]$X_names res$modules[[1]]$Y_names
Computes the signed correlation matrix and the matrix of -log10 two-sided
p-values over the features of two omics layers measured on the same
samples. These are the inputs R and P of greedy_3step().
triger_association(x, y, method = c("pearson", "spearman"))triger_association(x, y, method = c("pearson", "spearman"))
x |
Numeric matrix of the first omics layer, samples in rows and features in columns. |
y |
Numeric matrix of the second omics layer, with the same samples in the same order. |
method |
Correlation coefficient: |
The p-value of a correlation coefficient estimated from
samples is computed from with
degrees of freedom, as in stats::cor.test() (for Spearman
correlations, the same t approximation). is capped at
so that perfectly correlated features receive a large
finite value, and the diagonal of P is set to 0.
A list with R and P, both (m + n) x (m + n) with the m
features of x first and the n features of y second, and m and
n. Row and column names are the column names of x and y, or
X1, X2, ... and Y1, Y2, ... when these are missing.
set.seed(1) x <- matrix(rnorm(50 * 5), 50) y <- matrix(rnorm(50 * 4), 50) assoc <- triger_association(x, y) round(assoc$P[1:5, 6:9], 2)set.seed(1) x <- matrix(rnorm(50 * 5), 50) y <- matrix(rnorm(50 * 4), 50) assoc <- triger_association(x, y) round(assoc$P[1:5, 6:9], 2)