OmniPath table ingestion¶
omnipath_client.to_annnet builds a graph from an OmniPath-style
interaction table. AnnNet reaches no knowledge base of its own: the
client for a knowledge base is what returns AnnNet objects. This
notebook uses a local table so it is deterministic.
In [1]:
Copied!
import annnet as an
import omnipath_client as oc
an.info()
import annnet as an
import omnipath_client as oc
an.info()
[2026-08-07 02:29:57] [DEBUG] [pkg_infra.session ] ▸ Using app logger: default
[2026-08-07 02:29:57] [DEBUG] [pkg_infra.session ] ▸ Session time initialized: utc=2026-08-07 00:29:57.380209+00:00, local=2026-08-07 02:29:57.380210+02:00, timezone=CEST
[2026-08-07 02:29:57] [DEBUG] [pkg_infra.session ] ▸ Location lookup skipped
[2026-08-07 02:29:57] [INFO ] [pkg_infra.session ] ▸ Creating new session...
[2026-08-07 02:29:57] [INFO ] [pkg_infra.session ] ▸ Session has been created
Out[1]:
annnetv0.2.0graph: networkxplot: graphvizI/O: 10/12
Show environment details
| Version | v0.2.0 |
|---|---|
| License | BSD-3-Clause |
| Authors | Youssef Zerta ✉, Daniele Bottazzi ✉, Denes Turei ✉ |
| Repository | https://github.com/saezlab/annnet |
| Documentation | https://saezlab.github.io/annnet/reference/ |
| Default adapter backend | networkx |
| Default plot backend | graphviz |
| Graph backends | ✓networkx✓igraph✗graph-tool✗pyg |
| Plot backends | ✓graphviz✓pydot✓matplotlib |
| Tabular data backends | ✓polars✓pandas✓pyarrow |
| I/O modules | ✓annnet✓json/ndjson✓dataframes✓csv✓excel✓graphml/gexf✓sif✓cx2✓parquet✓zarr✗sbml✗scverse |
| Installable bundles | backendsplotiostorageall |
Build from a local OmniPath-style table¶
In [2]:
Copied!
import polars as pl
interactions = pl.DataFrame(
{
'source': ['EGF', 'EGFR', 'EGFR', 'EGFR', 'RAS', 'MEK'],
'target': ['EGFR', 'RAS', 'RAS', 'GRB2', 'MEK', 'ERK'],
'interaction_id': [
'EGF_EGFR',
'EGFR_RAS_primary',
'EGFR_RAS_secondary',
'EGFR_GRB2_complex',
'RAS_MEK',
'MEK_ERK',
],
'is_directed': [True, True, True, False, True, True],
'curation_score': [0.95, 0.88, 0.63, 0.76, 0.82, 0.79],
'consensus_direction': [1, 1, 1, 0, 1, 1],
'source_database': [
'omnipath',
'omnipath',
'literature',
'complexportal',
'pathwayextra',
'kinaseextra',
],
}
)
G = oc.to_annnet(
interactions,
source_col='source',
target_col='target',
edge_id_col='interaction_id',
directed_col='is_directed',
weight_col='curation_score',
edge_attr_cols=['consensus_direction', 'source_database'],
)
print('shape:', G.shape)
G.views.edges().select(
['edge_id', 'source', 'target', 'effective_weight', 'source_database']
)
import polars as pl
interactions = pl.DataFrame(
{
'source': ['EGF', 'EGFR', 'EGFR', 'EGFR', 'RAS', 'MEK'],
'target': ['EGFR', 'RAS', 'RAS', 'GRB2', 'MEK', 'ERK'],
'interaction_id': [
'EGF_EGFR',
'EGFR_RAS_primary',
'EGFR_RAS_secondary',
'EGFR_GRB2_complex',
'RAS_MEK',
'MEK_ERK',
],
'is_directed': [True, True, True, False, True, True],
'curation_score': [0.95, 0.88, 0.63, 0.76, 0.82, 0.79],
'consensus_direction': [1, 1, 1, 0, 1, 1],
'source_database': [
'omnipath',
'omnipath',
'literature',
'complexportal',
'pathwayextra',
'kinaseextra',
],
}
)
G = oc.to_annnet(
interactions,
source_col='source',
target_col='target',
edge_id_col='interaction_id',
directed_col='is_directed',
weight_col='curation_score',
edge_attr_cols=['consensus_direction', 'source_database'],
)
print('shape:', G.shape)
G.views.edges().select(
['edge_id', 'source', 'target', 'effective_weight', 'source_database']
)
shape: (6, 6)
Out[2]:
shape: (6, 5)
| edge_id | source | target | effective_weight | source_database |
|---|---|---|---|---|
| str | str | str | f64 | str |
| "EGF_EGFR" | "EGF" | "EGFR" | 0.95 | "omnipath" |
| "EGFR_RAS_primary" | "EGFR" | "RAS" | 0.88 | "omnipath" |
| "EGFR_RAS_secondary" | "EGFR" | "RAS" | 0.63 | "literature" |
| "EGFR_GRB2_complex" | "EGFR" | "GRB2" | 0.76 | "complexportal" |
| "RAS_MEK" | "RAS" | "MEK" | 0.82 | "pathwayextra" |
| "MEK_ERK" | "MEK" | "ERK" | 0.79 | "kinaseextra" |
Add analysis context as slices¶
In [3]:
Copied!
rows = list(G.views.edges().iter_rows(named=True))
edge_label = {
row['edge_id']: f"{row['source']} -> {row['target']}"
for row in rows
}
high_confidence = [
row['edge_id']
for row in rows
if row['effective_weight'] >= 0.85
]
G.slices.add('high_confidence')
G.slices.add_edges('high_confidence', high_confidence)
print(
'high-confidence interactions:',
[edge_label[eid] for eid in sorted(G.slices.edges('high_confidence'))],
)
rows = list(G.views.edges().iter_rows(named=True))
edge_label = {
row['edge_id']: f"{row['source']} -> {row['target']}"
for row in rows
}
high_confidence = [
row['edge_id']
for row in rows
if row['effective_weight'] >= 0.85
]
G.slices.add('high_confidence')
G.slices.add_edges('high_confidence', high_confidence)
print(
'high-confidence interactions:',
[edge_label[eid] for eid in sorted(G.slices.edges('high_confidence'))],
)
high-confidence interactions: ['EGFR -> RAS', 'EGF -> EGFR']
Draw the prior network¶
In [4]:
Copied!
from annnet.utils import plotting
plotting.plot(
G,
backend='graphviz',
show_edge_labels=True,
edge_label_keys=['source_database'],
)
from annnet.utils import plotting
plotting.plot(
G,
backend='graphviz',
show_edge_labels=True,
edge_label_keys=['source_database'],
)
Out[4]:
The client hands back a graph that keeps confidence, provenance and every downstream context in one object. Where the table came from is the concern of the client, and what the graph does with it is the concern of AnnNet.