Skip to content
dean geckt edited this page Oct 7, 2024 · 22 revisions

Network motif detection software

This software receives an input network as well as other arguments, and detects its network motif. The main python entry is motif_search_main.py (will refer to as main.py) which can be ran via any shell / script in a command-line-argument fashion:

motif_search_main.py —help                    					

Refer to the Readme for more usage deatails.

One can also run the software via a python IDE such as pycharm, or via a script (example is located under /scripts) for an automated process (e.g.; run on the same network with a different synapse threshold values in a loop fashion). In any case, it is mandatory to run from the root folder.

The output of the software depends on the Arguments. Most commonly would be to store the results in a binary result file for later analysis. In any case, the software will print out logs describing the: input network’s properties (#nodes, #edges, #degrees, etc…), the motif-criteria parameters, the enumeration and randomizer algorithms used, and finally the motif table. Note that all logs can be extracted via the binary file at any time.

Detecting motifs includes the following steps

  1. Enumerate the frequency of each subgraph (size k) of the input network
  2. Generate random networks (based on the input network). For each random graph, enumerate the frequency of each subgraph
  3. Test for a statistical significance of each subgraph

image

Each step is implemented in one of the Main Classes, and the logic is glued together in main.py.

All parts of the software (as well as later analysis) use common Data structures, these are the core parts of the software and help explain what is later saved in the binary result files.

To detect larger-than-3 motifs refer to Isomorphic mapping.

Network motif post analysis

These utilities are mostly jupyter notebooks located under the /post-motif-analysis folder. They require a binary output file(s) to work.

The important notebooks are:

  • motif_analysis.ipynb analyzes motifs in a single network using a variety of utilities (described below).
  • Multiple_network_motif_comparison.ipynb compares multiple networks’ motifs ($k=3$) and plots their Z scores in a variety of manners such as normalized and discretized.
  • network_properties.ipynb focuses on a network regardless of its motifs, it can plot the network distribution as well as other basic network properties.
  • 2_network_motif_comparison.ipynb specifically compares two networks’ motifs Z scores against each other.
Motif analysis utilities:
get_motif_sub_graphs

def get_motif_sub_graphs(motif: Motif, node = '', role = '', draw=True, log=True) This function returns and prints the full sub graphs list i.e., the occurrences or appearances consisting of that motif. node and role parameters are by default empty strings, i.e., not used, but if they are given it will filter for sub graphs where node node is in role role. Example:

get_motif_sub_graphs(m, log=False, node='RIMR', role='c')
Node "RIMR" as role "c" - sub graphs in Motif 74:

[{'a': 'SMDDL', 'b': 'RIAL', 'c': 'RIMR'},
 {'a': 'RMDL', 'b': 'RIAL', 'c': 'RIMR'},
 {'c': 'RIMR', 'a': 'SMDDR', 'b': 'RIAL'},
 {'a': 'RMDR', 'b': 'RIAL', 'c': 'RIMR'},
 {'a': 'SMDDL', 'b': 'RIAR', 'c': 'RIMR'},
 {'a': 'RMDL', 'b': 'RIAR', 'c': 'RIMR'},
 {'a': 'RMDR', 'b': 'RIAR', 'c': 'RIMR'},
 {'b': 'LUAL', 'a': 'AVAL', 'c': 'RIMR'}]
get_isolated_motif_sub_graphs

def get_isolated_motif_sub_graphs(sub_graphs: list[dict], rank_by: str): This function receives a list of sub graphs (output from previous method) and rank it by several available methods. rank_by can be: 'degree', 'in-degree', 'out-degree', 'cc' (clustering coefficient).

Example: get_isolated_motif_sub_graphs(subgraphs, 'degree')

[(8.666666666666666, {'b': 'AVJR', 'c': 'AVDR', 'a': 'ADLL'}),
 (10.0, {'b': 'FLPL', 'c': 'AVDR', 'a': 'FLPR'}),
 (11.666666666666666, {'b': 'AVAR', 'c': 'AVDR', 'a': 'PQR'}),
 (12.0, {'a': 'LUAL', 'b': 'AVAR', 'c': 'AVDR'}),
 (12.333333333333334, {'a': 'PHBR', 'b': 'AVAR', 'c': 'AVDR'}),
 (12.333333333333334, {'b': 'AVAR', 'c': 'AVDR', 'a': 'ADLL'}),
 (13.0, {'a': 'FLPL', 'b': 'AVAR', 'c': 'AVDR'}),
 (13.0, {'a': 'AVJR', 'b': 'AVAR', 'c': 'AVDR'}),
 (13.666666666666666, {'a': 'FLPR', 'b': 'AVAR', 'c': 'AVDR'})]
scatter_motifs

def scatter_motifs(motifs_, w_graph=False): This function plots the network motif results such that the Z scores are on the Y-Axis and the N_real (number of appearances of each motif in the real network) is on the X-axis. The w_graph bool parameter indicates whether or not to draw the actual circle above the scattered dot.

Example:

image

plot_motif_roles

def plot_motif_roles(motif: Motif, top=5): This function plots a sorted bar plot for each of the roles in the given motif. Each such plot is sorted by the appearances of the neurons belonging to that role.

Example:

image

draw_sub_graph

def draw_sub_graph(network: Network, neurons: list[str], full_pol=True, center=None): This function draws the induced subgraph of a given list of neurons (in a list of string format) of the given network. For polarity network the bool flag full_pol controls whether or not To display the full neurotransmitter or just the sign (i.e., +,- or c for complex). center could be one of neuron given in the list, it will change the layout such that this neuron is in the center. The weight of the arrow corresponds to the number of synapses that are in the given subgraph.

Example draw_sub_graph(network, ['RIAL', 'RMDVL', 'RMDDR', 'RIAR', 'RMDDL', 'RMDVR'], full_pol=True)

image

draw_neighbors

def draw_neighbors(network: Network, neuron: str, n_type: str, full_pol=True): Similar to the above, this function will draw an induced subgraph of the neighbors of the given neuron. n_type can be either ‘in’, ‘out’ or both in order to choose neurons with incoming / outgoing (or both) edges to neuron. And full_pol as described in draw_sub_graph.

Example: draw_neighbors(network, 'AVEL', 'out', True)

image