Drug2Ways 0.0.9 Documentation

Drug2ways supports generic network formats such as JSON, CSV, GraphML, or GML. Check out drug2ways’s documentation here. Ideally, the network should contain three different types of nodes representing drugs, proteins, and indications/phenotypes. The hypothesis underlying this software is that by reasoning over a multitude of possible paths between a given drug and indication, the drug regulates the indication in the direction of the signs of the most frequently occurring paths (i.e., majority rule). In other words, we assume that a drug has a greater likelihood of interacting with its target, and its target with intermediate nodes, to modulate a pathological phenotype as the number of possible paths connecting a drug to the phenotype increases. Based on this hypothesis, this software can be applied for different applications outlined in the next section.

Installation is as easy as getting the code from PyPI with python3 -m pip install drug2ways. See the installation documentation.

See also

Installation

The latest stable code can be installed from PyPI with:

$ python3 -m pip install drug2ways

The most recent code can be installed from the source on GitHub with:

$ python3 -m pip install git+https://github.com/drug2ways/drug2ways.git

For developers, the repository can be cloned from GitHub and installed in editable mode with:

$ git clone https://github.com/drug2ways/drug2ways.git
$ cd drug2ways
$ python3 -m pip install -e .

Formats

Drug2ways handles the following formats:

  • CSV (.csv)

  • TSV (.tsv)

  • GraphML (.graphml or .xml)

  • GML (.gml or .xml)

  • BEL (.bel)

  • Pickle (.pickle). BELGraph object from PyBEL 0.13.2

  • Edge list (.lst)

  • Node-Link JSON (.json)

The GraphML, GML, EdgeList and Node-Link JSON readers of drug2ways rely on NetworkX. BEL and Pickle files rely on PyBEL. The two easiest format to work with drug2ways are a triple-based file represented as the file below (tsv/csv). The file must contain three columns: source, relation and target (order is not relevant) and the only condition is that the relation column contains 1 and -1 to indicate the direction of the relation (increase/decrease).

source

target | relation

Drug1

Protein1

-1

Protein1

Protein2

1

Protein2

Protein3

-1

Protein3

Disease1

1

Drug2ways API

Drug2ways implements an API with multiple methods that facilitate its programmatic usage. The majority of this methods are similar to the ones in the CLI. They are located in cli_helper.py.

 from drug2ways.cli_helper import wrapper_explore
 from networkx import DiGraph

 # Initialize a directed graph
 directed_graph = nx.DiGraph()
 directed_graph.add_edges_from([(1, 2), (1, 3)])

 results, time_cache = wrapper_explore(
    graph=directed_graph, # directed graph
    source_nodes=[1], # list of source nodes
    target_nodes=[3], # list of target nodes
    lmax=2, # max length of the path
    simple_paths=True, # with or without cycles (True=no cycles are allowed)
)

Command Line Interface

Drug2Ways Command Line Interface

drug2ways

drug2ways

drug2ways [OPTIONS] COMMAND [ARGS]...

combine

Run drug2ways for a given network and get sources that optimize given targets.

drug2ways combine [OPTIONS]

Options

-l, --log

Activate debug mode

-o, --output <output>

Output directory

-c, --combination-length <combination_length>

Required Combination length. Number of drugs in each combination.

-a, --activation-threshold <activation_threshold>

Activation threshold

--simple

Count only simple paths, i.e. paths without cycles.

-l, --lmax <lmax>

Required Maximum length of paths

-t, --targets <targets>

Path to file with source nodes

-s, --sources <sources>

Path to file with source nodes

-f, --fmt <fmt>

Graph fmt

Options

csv|tsv|graphml|bel|json|pickle

-g, --graph <graph>

Required Path to the network

explore

Run drug2ways for a given network.

drug2ways explore [OPTIONS]

Options

-t, --time

Export time measurements

-l, --log

Activate debug mode

-d, --drug-search-bel

Drug search for BEL graphs

-n, --name <name>

Name for output file

-o, --output <output>

Output directory

--simple

Count only simple paths, i.e. paths without cycles.

-l, --lmax <lmax>

Required Maximum length of paths

-t, --targets <targets>

Path to file with source nodes

-s, --sources <sources>

Path to file with source nodes

-f, --fmt <fmt>

Graph fmt

Options

csv|tsv|graphml|bel|json|pickle

-g, --graph <graph>

Required Path to the network

optimize

Run drug2ways for a given network and get sources that optimize given targets.

drug2ways optimize [OPTIONS]

Options

-l, --log

Activate debug mode

-o, --output <output>

Output directory

-a, --activation-threshold <activation_threshold>

Activation threshold

--simple

Count only simple paths, i.e. paths without cycles.

-l, --lmax <lmax>

Required Maximum length of paths

-t, --targets <targets>

Path to file with source nodes

-s, --sources <sources>

Path to file with source nodes

-f, --fmt <fmt>

Graph fmt

Options

csv|tsv|graphml|bel|json|pickle

-g, --graph <graph>

Required Path to the network

pathway-analysis

Run drug2ways pathway enrichment on the paths.

drug2ways pathway-analysis [OPTIONS]

Options

-l, --log

Activate debug mode

-o, --output <output>

Output directory

--simple

Count only simple paths, i.e. paths without cycles.

-l, --lmax <lmax>

Required Maximum length of paths

-t, --targets <targets>

Path to file with source nodes

-s, --sources <sources>

Path to file with source nodes

-f, --fmt <fmt>

Graph fmt

Options

csv|tsv|graphml|bel|json|pickle

-g, --graph <graph>

Required Path to the network

Algorithm

Graph traversal methods.

drug2ways.graph_traversal.compute_all_paths_multitarget(graph: networkx.classes.digraph.DiGraph, source: Iterable[Any], targets, lmax: int, previous_history: Dict) → Tuple[int, List[List[Union[float, int]]]][source]

Compute all paths to all the targets, separately.

Parameters
  • graph – graph

  • source – source nodes

  • targets – target nodes

  • lmax – lmax

  • previous_history – previous history of visited nodes

Returns

drug2ways.graph_traversal.compute_all_paths_multitarget_dict(graph: networkx.classes.digraph.DiGraph, source, targets, lmax: int, previous_history: Dict, cycle_history: Dict, simple_paths: bool = False) → Tuple[int, List[List[Union[float, int]]]][source]

Compute all paths to all the targets, separately. Uses dict to store target path count instead of array.

Parameters
  • graph – graph

  • source – source node

  • targets – target nodes

  • lmax – lmax

  • previous_history – history of visited nodes

  • cycle_history – history of cycles

  • simple_paths – simple paths mode

Alternative methods for path calculations in graphs (depricated and not used in the package).

drug2ways.alternative_graph_traversal.enumerate_paths(graph, source, targets, lmax, cycle_free=False)[source]

Enumerate paths.

Parameters
  • graph – graph

  • source – source node

  • targets – target nodes

  • lmax – lmax

  • cycle_free

Returns

Constants

Constants of drug2ways.

drug2ways.constants.DEFAULT_DRUG2WAYS_DIR = '/home/docs/.drug2ways'

Default drug2ways directory

drug2ways.constants.ensure_genesets()[source]

Download gene sets.

drug2ways.constants.ensure_output_dirs()[source]

Ensure that the output directories exists.

drug2ways.constants.download_pathway(url: str, export_path: str)None[source]

Make a function that downloads the data for you, or uses a cached version at the given path.

Parameters
  • url – The URL of some data

  • export_path – folder where decompressed file will be exported

drug2ways.constants.CSV = 'csv'

csv

drug2ways.constants.TSV = 'tsv'

tsv

drug2ways.constants.GRAPHML = 'graphml'

graphML

drug2ways.constants.BEL = 'bel'

bel

node link json

drug2ways.constants.BEL_PICKLE = 'pickle'

pickle

drug2ways.constants.GML = 'gml'

gml

drug2ways.constants.EDGE_LIST = '.lst'

edge list

drug2ways.constants.FORMATS = ['csv', 'tsv', 'graphml', 'bel', 'json', 'pickle']

drug2ways available network formats

drug2ways.constants.FORMAT_SEPARATOR_MAPPING = {'csv': ',', 'tsv': '\t'}

Acceptable column names for the graph

drug2ways.constants.SOURCE = 'source'

Column name for source node

drug2ways.constants.TARGET = 'target'

Column name for target node

drug2ways.constants.RELATION = 'relation'

Column name for relation

drug2ways.constants.EMOJI = '💊🔬'

drug2ways emoji

Performance

Drug2ways enables for parallelization to improve the performance. The only requirement is to install the MPI package (https://mpi4py.readthedocs.io/). Once the package is installed, drug2ways recognizes it automatically to calculate the predictions using parallelization.

Disclaimer

Drug2Ways is a scientific software that has been developed in an academic capacity, and thus comes with no warranty or guarantee of maintenance, support, or back-up of data.