Skip to content

Commit 605eaab

Browse files
jy2941claude
andcommitted
Initial Python package for TriGer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JeQnKEVf918iZ8vbkGT6eX
0 parents  commit 605eaab

9 files changed

Lines changed: 707 additions & 0 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: tests
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: ["3.9", "3.11", "3.13"]
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: ${{ matrix.python-version }}
14+
- run: pip install ".[test]"
15+
- run: pytest

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__pycache__/
2+
*.pyc
3+
*.egg-info/
4+
build/
5+
dist/
6+
.pytest_cache/
7+
.DS_Store

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Jiaao Yu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# triger
2+
3+
Python package for **TriGer**, from the paper *Structured cross-omics interaction
4+
discovery with a triple-graph model*.
5+
6+
TriGer finds modules of features that are densely associated across two omics
7+
layers (X and Y) and coherent within each layer. It peels dense blocks from the
8+
cross-omics association matrix, then refines large blocks using the
9+
within-omics correlation matrices.
10+
11+
## Installation
12+
13+
```bash
14+
pip install git+https://github.com/jy2941/TriGer-PyPI.git
15+
```
16+
17+
## Quick start
18+
19+
```python
20+
import numpy as np
21+
from scipy import stats # only used here to compute p-values
22+
import triger
23+
24+
# X: samples x m features, Y: samples x n features
25+
N, m, n = X.shape[0], X.shape[1], Y.shape[1]
26+
R = np.corrcoef(np.hstack([X, Y]).T) # signed correlations
27+
r = np.clip(R, -0.999999, 0.999999)
28+
t = r * np.sqrt((N - 2) / (1 - r ** 2))
29+
P = -np.log10(2 * stats.t.sf(np.abs(t), N - 2)) # -log10 p
30+
np.fill_diagonal(P, 0)
31+
32+
blocks = triger.greedy_3step(P, R, m, n, lambda1=1.1, lambda2=1.8, lambda3=1.8,
33+
X_size=(10, 15), Y_size=(10, 250))
34+
for x_idx, y_idx in blocks:
35+
print(len(x_idx), "X features,", len(y_idx), "Y features")
36+
37+
triger.plot3in1_v1(R[:m, :m], R[m:, m:], R[:m, m:], blocks, line=True)
38+
```
39+
40+
## Functions
41+
42+
| Function | Description |
43+
|----------|-------------|
44+
| `greedy_3step` | Full pipeline: cross-omics block detection, then within-omics refinement of large blocks |
45+
| `greedy_peeling_XY_one` / `greedy_peeling_XY_all` | Dense blocks in a cross-omics (X-Y) matrix |
46+
| `greedy_peeling_X_one` / `greedy_peeling_X_all` | Dense communities in a within-omics (symmetric) matrix |
47+
| `sort_result` / `sort_result_XandY` | Order features within each block |
48+
| `plot3in1_v1` | X-Y heatmap with the X-X and Y-Y matrices as triangles |
49+
| `plot_all_result` | Heatmap of the detected blocks |
50+
51+
All indices are 0-based. `lambda1` is the cross-omics size penalty and `lambda2` /
52+
`lambda3` are the within-omics penalties for X and Y (λ₀, λ₁, λ₂ in the paper);
53+
higher values give smaller, denser blocks.
54+
55+
## Related
56+
57+
- R package: [TriGer-R](https://github.com/jy2941/TriGer-R)
58+
- Code for the paper's simulations and analyses: [TriGer](https://github.com/jy2941/TriGer)
59+
60+
## License
61+
62+
MIT

‎pyproject.toml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "triger"
7+
version = "0.1.0"
8+
description = "Structured cross-omics interaction discovery with a triple-graph model"
9+
readme = "README.md"
10+
license = "MIT"
11+
license-files = ["LICENSE"]
12+
requires-python = ">=3.9"
13+
authors = [{ name = "Jiaao Yu", email = "jy2941@umd.edu" }]
14+
keywords = ["multi-omics", "integration", "biclustering", "dense subgraph", "greedy peeling"]
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Operating System :: OS Independent",
18+
"Intended Audience :: Science/Research",
19+
"Topic :: Scientific/Engineering :: Bio-Informatics",
20+
]
21+
dependencies = ["numpy>=1.21", "matplotlib>=3.5"]
22+
23+
[project.optional-dependencies]
24+
test = ["pytest>=7"]
25+
26+
[project.urls]
27+
Homepage = "https://github.com/jy2941/TriGer-PyPI"
28+
"Paper code" = "https://github.com/jy2941/TriGer"
29+
30+
[tool.hatch.build.targets.wheel]
31+
packages = ["src/triger"]

‎src/triger/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""TriGer: structured cross-omics interaction discovery with a triple-graph model."""
2+
from .greedy_peeling import (greedy_peeling_XY_one, greedy_peeling_XY_all,
3+
greedy_peeling_X_one, greedy_peeling_X_all,
4+
sort_result, sort_result_XandY, greedy_3step)
5+
from .plotting import plot3in1_v1, plot_all_result, matlab_jet
6+
7+
__version__ = "0.1.0"
8+
__all__ = ["greedy_peeling_XY_one", "greedy_peeling_XY_all", "greedy_peeling_X_one",
9+
"greedy_peeling_X_all", "sort_result", "sort_result_XandY", "greedy_3step",
10+
"plot3in1_v1", "plot_all_result", "matlab_jet"]

0 commit comments

Comments
 (0)