DiNAR

DiNAR (Differential Network Analysis in R) shows differential expression (or other omics data) of several conditions or time points on a prior knowledge network, one cluster of nodes at a time (clusters of at most 2000 edges). A PSS gene network, CKN, or a subnetwork of either can be used as the knowledge network (as a DiNAR Custom Network in the form of a nodes table and an edges table).

From Python

write_dinar() writes a network as DiNAR’s nodes and edges tables (to_dinar() returns them as pandas.DataFrame):

from skm_tools.dinar import write_dinar
from skm_tools.pss import pss_gene_network_to_networkx

pss_ath = pss_gene_network_to_networkx(species="ath", data_dir="data")
write_dinar(pss_ath, "pss-ath-dinar-nodes.txt", "pss-ath-dinar-edges.txt", clusters="pathway")

Nodes get shortName from display_label, shortDescription from description and MapManBin from mapman (see MapMan annotations), joined with " | ". DiNAR draws an edge by the start of its reactionType: act (activation), inh (inhibition), or anything else (unknown). So, as in DiNAR’s own PSS tables, reactionType is act_, inh_ or unk_, from the edge’s interaction (positive, negative or unknown influence), followed by the PSS reaction_type (e.g. act_protein activation), or by influence for networks without one (CKN). Missing values are -, as DiNAR expects, and the columns DiNAR needs but skm-tools has no data for (expressed, exists) are 1.

Clusters

DiNAR shows one cluster at a time, so choose clusters that make sense to look at together. The argument clusters can be a node attribute (e.g. "pathway"; for a gene in several functional clusters, its first one is used) or a {node: cluster} mapping, e.g. from community detection:

import networkx as nx

communities = nx.community.louvain_communities(nx.Graph(ckn_subnetwork), seed=0)
clusters = {n: i for i, community in enumerate(communities) for n in community}
write_dinar(ckn_subnetwork, "nodes.txt", "edges.txt", clusters=clusters)

Without clusters, all nodes are in one cluster, which is fine for small networks (e.g. PSS). Nodes without a cluster (e.g. without a pathway) are put together in one more cluster. Nodes without edges get clusterID 0, which DiNAR doesn’t show. DiNAR can’t show clusters with more than 2000 edges: to_dinar() raises a ValueError for them, so split large networks into clusters.

Coordinates

positions is a {node: (x, y)} mapping, as returned by the networkx layout functions, or a node attribute holding them. By default, the pos node attribute is used if every node has one (the networkx convention, nx.set_node_attributes(g, pos, "pos")); otherwise each cluster gets a spring layout, with the clusters on a grid. To use a layout made in Cytoscape (see Cytoscape automation):

import py4cytoscape as p4c

xy = p4c.get_node_position(network=suid)
# Cytoscape's y axis points down
positions = {n: (x, -y) for n, x, y in zip(xy.index, xy["x"], xy["y"])}
write_dinar(pss_ath, "nodes.txt", "edges.txt", clusters="pathway", positions=positions)

In DiNAR

Run DiNAR (online or locally, see its README), choose Custom network, upload the nodes and edges tables, and then the expression tables of your conditions.

Without code

Networks from the SKM explorers can be turned into DiNAR tables with DiNAR’s GMM-SKM-KnetMiner app:

  1. Get the (sub)network of interest: download the result of a query in the PSS or CKN Explorer, exporting the nodes and edges as .csv. In the case of PSS, the entire network is also visualisable (download from skm.nib.si/downloads).

  2. Run the GMM-SKM-KnetMiner app, online or locally (script).

  3. Load the files.

  4. Follow the instructions, and save the Custom Network tables (nodes and edges).

  5. Load the Custom Network and the expression tables into DiNAR.

  6. Export the results as needed (examples).

In tables made by hand, replace empty values with -, and keep shortName short.