Datasets:
image imagewidth (px) 1.82k 3.2k |
|---|
edge_ML metabolomics co-response graph
An undirected graph of 18,494 nodes and 2,709,209 edges built from pairwise metabolite co-response statistics across 83 MetaboLights studies, together with the node properties, the PyTorch Geometric graph object, and the full pipeline that produces them.
A node is one differential comparison within one study assay (MTBLS1405_0002_00003332
= study MTBLS1405, assay 002, feature 00003332). An edge carries the association
between two comparisons, summarised as a 2Γ2 contingency table of InChIKey counts across
the up/down directions of each side.
What is here
| Path | Contents | Size |
|---|---|---|
data/edge_ML_expected_ge5.parquet |
The 2,709,209 filtered edges, 12 columns | 106 MB |
data/nodes_ML_utf8.tsv |
118,422 node property rows, headerless, UTF-8 | 51 MB |
data/Edge_Header.tsv, data/Node_Header.tsv |
Column names for the headerless files | β |
graph/edge_ML_expected_ge5_pyg.pt |
PyG Data: edge_index, edge_attr, x, node_id |
206 MB |
figures/umap_species_{light,dark}.png |
UMAP of the embeddings, coloured by species | 652 KB |
figures/umap_coords.npy |
Cached 2D UMAP coordinates, [18494, 2] |
148 KB |
bootstrap.py |
Rebuilds graph.duckdb from the two data files |
β |
scripts/ |
The pipeline, from graph build to evaluation and figures | β |
scripts/umap_app.py |
Streamlit explorer for the UMAP, coloured by node property | β |
scripts/paths.py |
Where every script looks for things β one place to repoint | β |
provenance/import_nodes.py |
The encoding repair as originally run | β |
pyproject.toml, uv.lock, .python-version |
Pinned environment, down to the interpreter | β |
The trained Node2Vec embeddings live in a separate model repository.
The edge filter
The source edge table has 39,319,908 rows. Only rows whose 2Γ2 table has every expected frequency at 5 or above β the conventional chi-square validity threshold β are released here: 2,709,209 rows, 6.9%.
Because every expected count is row_i Γ col_j / N, the smallest of the four is
min(a+b, c+d) Γ min(a+c, b+d) / N, so one comparison settles all four cells. It was
applied in integer form, min_row Γ min_col >= 5 * N, to keep a floating-point result
from landing the wrong side of exactly 5. No row has N = 0. The reduction from 43.7%
(rows whose counts merely sum to 20 or more) to 6.9% is driven mainly by zero margins
rather than small ones.
Graph object
Data(edge_index=[2, 5418418], edge_attr=[5418418, 2], num_nodes=18494,
node_id=[18494], edge_attr_names=[2], x=[18494, 559],
feature_groups={...})
edge_indexβ 5,418,418 columns, both directions of 2,709,209 undirected edges.to_undirected()collapsed nothing (5,418,418 is exactly twice 2,709,209), which establishes that every unordered pair occurs exactly once in the source table. No self-loops, no isolated nodes; degree runs 1 / 90 / 2,290 (min / median / max).edge_attrβ[num_edges, 2]float64:OddsRatio_log2,ChiTestsPValue. float64 is deliberate: p-values reach 1.76 Γ 10β»β·βΉ and 273 edges fall below float32's smallest normal value, so a float32 store β or a later.float()cast β flushes them to zero. For model input,-log10(p)is the float32-safe encoding. Both quantities are invariant under transposing the 2Γ2 table, so the reverse direction of each edge genuinely carries identical values.xβ[18494, 559]one-hot over nine categorical groups:Study(83),Analytics(114),species(115),factor1_org(54),factor2_org(54),color_group(11),color_group_upper1(5),tissue1(60),tissue2(63). Column ranges are indata.feature_groups, labels indata.feature_names. Every row sums to exactly 9, so no node is missing metadata.tissue1/tissue2are parsed from field 2 of the pipe-delimitedfactor1/factor2strings. Excluded:factor(13,201 near-unique values), rawfactor1/factor2(756 / 780), andcolor_group_upper2(identical tocolor_group_upper1on every node).node_idβ indeximaps to the original string ID. The order is lexicographic over the union ofstart_idandend_id, whichbootstrap.pyreproduces exactly.
Loading needs one extra step on torch β₯ 2.6, which defaults to weights_only=True:
import torch
from torch_geometric.data import Data
from torch_geometric.data.data import DataEdgeAttr, DataTensorAttr
from torch_geometric.data.storage import BaseStorage, EdgeStorage, GlobalStorage
torch.serialization.add_safe_globals(
[Data, DataEdgeAttr, DataTensorAttr, BaseStorage, EdgeStorage, GlobalStorage])
data = torch.load("graph/edge_ML_expected_ge5_pyg.pt", weights_only=True)
Reproducing the pipeline
uv sync
export MODEL_DIR=../edge-ML-node2vec # only for scripts reading the embeddings
uv run python bootstrap.py # data files -> graph.duckdb
uv run python scripts/build_graph.py # DuckDB -> PyG graph (no x)
uv run python scripts/add_node_features.py # must follow build_graph.py
uv run python scripts/verify_load.py # round-trips edge_attr against DuckDB
uv run python scripts/verify_features.py # decodes one-hot rows back to the table
uv run python scripts/umap_species.py # the figure (uses the cached coordinates)
uv run python scripts/umap_species.py dark # dark-mode variant
This has been tested from a clean download. bootstrap.py reproduces all three table
row counts, and the rebuilt graph is identical to the released one β edge_index,
edge_attr, x, node_id, feature_names and feature_groups all compare equal.
scripts/paths.py holds the layout. DATA_DIR is this checkout β it defaults to the
directory containing scripts/, so it needs setting only if you move things around β
and MODEL_DIR is the model repository checkout (default: the same as DATA_DIR). Only
sanity_check.py, species_purity.py and umap_species.py read the embeddings, so
MODEL_DIR matters only for those; point it at your model checkout, or train locally
with node2vec_model.py --epochs 20, which writes them there.
build_graph.py rewrites graph/edge_ML_expected_ge5_pyg.pt in place, so downstream
scripts read the same path whether you downloaded the graph or rebuilt it. It writes the
graph without x, so add_node_features.py must run after it.
The interpreter is pinned to Python 3.12 by .python-version. Without that pin uv sync
resolves a newer interpreter β 3.14 at the time of writing β which installs different
wheels than this work used.
Interactive explorer
uv sync
uv run python bootstrap.py # the app reads graph.duckdb
export MODEL_DIR=../edge-ML-node2vec # and the embeddings
uv run streamlit run scripts/umap_app.py
A Plotly scatter of all 18,494 nodes over the cached UMAP coordinates, with hover showing
node ID, species, study and tissue. The sidebar colours by species, Study,
color_group, tissue1 or Analytics, highlights any single category, restricts the
view to a chosen set (excluded nodes stay as a faint backdrop), and adjusts point size
and opacity.
Click a point and the panel beside it shows that node's metadata and degree, then its ten nearest embeddings by cosine similarity, each row marked with whether it shares the species and whether a real graph edge exists between the two. Box- or lasso-select instead for a category breakdown of the selection.
Only three categories are ever coloured at once. A scatter puts every pair of hues on screen simultaneously, and the palette clears the colour-vision separation floors at three slots but not four, so everything else folds into a muted "Other" and the remaining categories are reached one at a time through the highlight control. Both light and dark token sets are included; the app follows the Streamlit theme.
scripts/verify_app.py renders the figure in five states outside Streamlit and asserts
that every colour is on-palette, all 18,494 points are drawn, the axes are hidden and the
aspect ratio locked, and hover is wired.
figures/app_overview.png, figures/app_selection.png and figures/app_neighbours.png
show the app running: the whole view, a clicked node in the Camellia sinensis cluster,
and that node's ten nearest embeddings with their cosine similarities and graph-edge
flags.
The environment is pinned in pyproject.toml and uv.lock: torch 2.14.0+cu130,
torch-geometric 2.8.0, pyg-lib 0.9.0+pt214cu130, duckdb, umap-learn, matplotlib.
pyg-lib is not on PyPI and is pinned through a [[tool.uv.index]] entry with
format = "flat" pointing at data.pyg.org; that URL is specific to torch 2.14 and
CUDA 13.0 and needs changing with any torch upgrade.
A note on the node file encoding
The source node property file was mixed-encoding: most lines UTF-8, but 168 lines
carrying raw Latin-1 bytes (mojibake inside the free-text factor fields), which made
DuckDB reject the whole file. The released TSV was produced by decoding each line as
UTF-8 where that succeeds and as Latin-1 otherwise β byte-preserving, dropping no row
and silently replacing no character. Both files also use CRLF line endings.
Known limitations
- Species and study structure are strongly entangled. Edges form mostly within a study and a study is normally one species, so any clustering by species partly reflects how the graph was assembled rather than an independent biological signal.
- The graph covers one source file (
edge_ML). Four further edge files (edge_MLvsMW,edge_MW_1,edge_MW_2,edge_MW_3, about 106 GB together) and a second node property file (nodes_MW, 1,019,678 rows) are not included; no node in this graph resolves againstnodes_MW. - The full 39.3 M-row edge table is not released, only the filtered subset. Reproducing the filter itself from raw inputs requires the original 14 GB TSV.
- Downloads last month
- 173