BEL Tools

Convert BEL to y0 mixed graphs.

bel_to_admg(graph, *, include_associations=False, indirect_handler=None)[source]

Convert a BEL Graph to an Ananke ADMG.

Parameters
  • graph (BELGraph) – A BEL graph

  • include_associations (bool) – Should pybel.constants.ASSOCIATION relationships be included as bidirected edges in the graph? Defaults to false.

  • indirect_handler (Optional[str]) – How should indirected edges be handled? If ‘bi’, adds as bidirected edges. Elif ‘di’, adds as bidirected edges. If ‘skip’, do not include. If None, defaults to ‘bi’.

Return type

ADMG

Returns

An Ananke ADMG

>>> import pybel
>>> from y0.dsl import P, Variable
>>> from y0.identify import is_identifiable
>>> from y0_bio.resources import BEL_EXAMPLE
>>> from y0_bio.io.bel import bel_to_nxmg
>>> bel_graph = pybel.load(BEL_EXAMPLE)
>>> nxmg = bel_to_nxmg(bel_graph)
>>> is_identifiable(nxmg, P(Variable('Severe Acute Respiratory Syndrome') @ Variable('angiotensin II')))
bel_to_causaleffect(graph, *, include_associations=False, indirect_handler=None)[source]

Convert a BEL Graph to a CausalEffect R graph object.

Parameters
  • graph (BELGraph) – A BEL graph

  • include_associations (bool) – Should pybel.constants.ASSOCIATION relationships be included as bidirected edges in the graph? Defaults to false.

  • indirect_handler (Optional[str]) – How should indirected edges be handled? If ‘bi’, adds as bidirected edges. Elif ‘di’, adds as bidirected edges. If ‘skip’, do not include. If None, defaults to ‘bi’.

Return type

ADMG

Returns

A CausalEffect R graph object

bel_to_nxmg(bel_graph, *, include_associations=False, indirect_handler=None)[source]

Convert a BEL Graph to a y0 networkx mixed graph.

Rules:

  • Directly increases, directly decreases, and directly regulates all become directed edges

  • Optional: increases, decreases, and regulates become bidirected edges because there might be some confounders in the middle

  • Positive correlation, negative correlation, and correlation become bidirected edges

  • Association edges are excluded by default, could be optionally included

  • Only include protein-protein relationships identified by HGNC

Parameters
  • bel_graph (BELGraph) – A BEL graph

  • include_associations (bool) – Should pybel.constants.ASSOCIATION relationships be included as bidirected edges in the graph? Defaults to false.

  • indirect_handler (Optional[str]) – How should indirected edges be handled? If ‘bi’, adds as bidirected edges. Elif ‘di’, adds as bidirected edges. If ‘skip’, do not include. If None, defaults to ‘bi’.

Return type

NxMixedGraph

Returns

A y0 networkx mixed graph

Raises

ValueError – for invalid input on “indirect_handler”

emmaa_to_nxmg(model, date=None, **kwargs)[source]

Get content from EMMAA and convert to a NXMG.

Parameters
  • model (str) – The name of the EMMAA model

  • date (Optional[str]) – The optional date of the EMMAA model. See pybel.from_emmaa().

  • kwargs – Keyword arguments to pass to bel_to_nxmg()

Return type

NxMixedGraph

Returns

A y0 networkx mixed graph

The following example uses the RAS model on EMMAA.

>>> from y0.dsl import P, Variable
>>> from y0.identify import is_identifiable
>>> from y0_bio.io.bel import emmaa_to_nxmg
>>> KRAS = Variable('KRAS')
>>> MAPK1 = Variable('MAPK1')
>>> ras = emmaa_to_nxmg('rasmodel')
>>> is_identifiable(ras, P(MAPK1 @ KRAS))
True