|
| 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 |
0 commit comments