This repository contains scripts for implementation of the
- [insert citation here]
Given an ensemble of undirected unweighted networks, each defined on the same set of nodes, but with different edge sets, this project develops a systematic and versatile framework to efficiently compute different local/global network science measures in each of the networks.
The framework exploits the structural similarity among the networks to hierarchically organize them into a
The five configurations of the framework are designed to run on
The project is implemented using the following programming languages:
- Preprocessing of real-world datasets: R version 4.4.2
- Functions for computations and analyses: Python versions 3.10 and 3.12.
Packages like
numpy, pandas, scipy, random, corals.correlationandstatsmodelhave been used repeatedly. - Workflows combining several scripts: Bourne Again SHell (BASH) scripting language
This section will help you set up the project for the first time — from cloning the repository to running a complete example. Please follow each step in the given order.
- Clone/download the project from GitHub to your local machine.
git clone https://github.com/BIRDSgroup/ProcesssNets PNets
cd PNets/ProcessNetsIf you face any issues due to
git clone https://github.com/BIRDSgroup/ProcesssNets PNets
cd "PNets/Miscellaneous/ProcessNets - sequential"If you want to print the I/O and Processing Time of the codes as well, then please use:
git clone https://github.com/BIRDSgroup/ProcesssNets PNets
cd "PNets/Miscellaneous/IOP Time/ProcessNets"-
Prepare input data.
As previously mentioned, this framework takes as input an ensemble of networks. Suppose your ensemble is titledEnsemble. Then please create a folder titledgraphs_Ensemble, and store your networks inside this folder. Each network$G_i$ should be stored in the filei.csvand should contain the edge list of the ith network - each row representing an edge in the network. Please don't add any other extra headers and column indexes to the files.
For example, using the Python programming language, if the A variable stores the adjacency matrix of the ith network, then you may use:
import numpy as np
edges = np.argwhere(A)
np.savetxt('graphs_Ensemble/' + str(i) + '.csv', edges, delimiter=',', fmt='%d')
Similarly, if your ith network networkx Python package and represented using the variable Gi, then please use:
import numpy as np
import networkx as nx
#edges = list(Gi.edges()) # required only if you want to generate the list of edges
nx.write_edgelist(Gi, 'graphs_Ensemble/' + str(i) + '.csv', delimiter=",", data=False)Additionally, a metadata file titled edge count.tsv containing information regarding of the size of each network should be present in the graphs_Ensemble folder. Every row of the file should contain the id of the network, number of nodes in the network and the number of edges in the network separated by tab.
For example, suppose you have graphs_Ensemble using:
cd graphs_EnsembleIf you are using Python, then please run the following script to generate edge count.tsv.
import numpy as np
for b in range(B): # replace B with the number of networks in your ensemble
edges = np.genfromtxt(str(b) + '.csv', delimiter = ',', dtype=int)
with open('edge count.tsv', 'a') as file:
print(b, len(np.unique(edges)), len(edges), sep='\t', end='\n', file=file)
file.close()-
Executing the Framework
Suppose your input ensemble has$B$ networks, each defined on$n$ nodes and generated from a dataset with$s$ samples. LetResultsbe the output folder to store all$\texttt{nc}$ -trees, measurement values and other outputs. Then please run the following command from the terminal.
mkdir Results graphs_orig_Ensemble
time ./main.sh Results n B s Ensemble [options]If you don't have the information pertaining to the number of samples on which the networks are constructed, then please use the value
mkdir Results graphs_orig_Ensemble
time ./main.sh Results n B -1 Ensemble [options]-
Optional Arguments
Please mention the required values next to the corresponding option separated by space-
--measuresSpecifies which measures to compute.
Valid values:
| Value | Description |
|----------|-------------|
|degree| Degree centrality |
|connectivity| Component Size |
|pr| PageRank centrality |
|cc| Closeness centrality |
If nothing is specified, then all measures are computed. -
--configSpecifies which configurations of the framework to use, i.e., the measures should be computed using which of the five$\texttt{nc}$ -trees.
Valid values:
| Value | Description |
|----------|-------------|
|rstar|$\mathrm{rstar}$ |
|slink|$\mathrm{slink}$ |
|fpa|$\mathrm{fpa}$ |
|upgma|$\mathrm{upgma}$ |
|wpgmc|$\mathrm{wpgmc}$ |
If nothing is specified, then all configurations are used. -
--tselfSpecifies if the measures should be computed using the self-implementation variant of baseline approach.
Valid values:
| Value | Description |
|----------|-------------|
|T| Compute all specified measures using this variant |
|F| Does not compute the specified measures using this variant |
Default value isT -
--tnxSpecifies if the measures should be computed using thenetworkxpackage with baseline approach.
Valid values:
| Value | Description |
|----------|-------------|
|T| Compute all specified measures using this variant |
|F| Does not compute the specified measures using this variant |
Default value isT.
-
An example run:
Suppose you want to compute degree centrality and PR centrality only using Eg_Ensemble with networkx package, then please execute the code as follows:
time ./main.sh Results 500 100 -1 Eg_Ensemble --measure degree pr --config rstar slink --tnx F-
Outputs
The framework output the folderResults, containing the following information:- For each constructed
$\texttt{nc}$ -tree$\mathrm{tree} \in \{\mathrm{rstar}, \mathrm{slink}, \mathrm{fpa}, \mathrm{upgma}, \mathrm{wpgmc}\}$ , a folder, titledTREEcontaining the following files.- A file corresponding to each branch of the tree, containing the list of incremental edges along the same branch. These incremental edges are stored in the row-major flattened index, i.e., the edge
$e = {i,j}$ between nodes$i$ and$j$ are stored as$i \times n + j$ . Here,$i,j \in \{1,2,\ldots,n\}$ . -
root.csv- a file containing the edge list of the root network -
info.tsv- a tab-separated file containing the branch id, source network id, destination network id, and number of incremental edges along the branch. -
child_count.tsv- this file is generated only for the tree constructed using$\mathrm{rstar}$ and contains the number of children of each branching point.
For example, consider the branch$(G_I, G_J)$ from$G_I$ to$G_J$ with the id$x$ . The list of incremental edges along this branch, i.e.,$E(G_J) \setminus E(G_I)$ is stored in the filex.csv. Suppose$|E(G_J) \setminus E(G_I)| = y$ . Then, the$x$ th line ininfo.tsvstoresx \t I \t J \t y.
- A file corresponding to each branch of the tree, containing the list of incremental edges along the same branch. These incremental edges are stored in the row-major flattened index, i.e., the edge
-
edge count.tsv- a tab-separated file containing the number of nodes and number of edges of each network in the input ensemble -
error.txt- stores the total running time taken by the framework and errors, if any. -
output.txt- stores terminal outputs, if any. -
jsi.txt- stores the$\mathtt{MPJS}$ value of the ensemble. - If degree centrality is computed, then:
- For each
$\mathtt{ProcessNets}$ configuration,$\mathrm{config}$ , that is executed, a file titledconfig degree.csv. - For the baseline approach with self-implementation, if executed, a file titled
mytrivial degree.csv. - For the baseline approach using
networkxpackage, if executed, a file titledtrivial degree.csv.
- For each
- If component size is computed, then:
- For each
$\mathtt{ProcessNets}$ configuration,$\mathrm{config}$ , that is executed, a file titledconfig connectivity.csv. - For the baseline approach with self-implementation, if executed, a file titled
mytrivial connectivity.csv. - For the baseline approach using
networkxpackage, if executed, a file titledtrivial connectivity.csv.
- For each
- If PR centrality is computed, then:
- For each
$\mathtt{ProcessNets}$ configuration,$\mathrm{config}$ , that is executed, a file titledconfig pr.csv. - For the baseline approach with self-implementation, if executed, a file titled
mytrivial pr.csv. - For the baseline approach using
networkxpackage, if executed, a file titledtrivial pr.csv.
- For each
- Running times are stored in the following files:
- For each
$\mathtt{ProcessNets}$ configuration,$\mathrm{config}$ , that is executed, a file titledconfig.txt. - For the baseline approach with self-implementation, if executed, a file titled
mytrivial.txt. - For the baseline approach using
networkxpackage, if executed, a file titledtrivial.txt.
- For each
- For each constructed
An example ensemble of
- Copy the folder
Example/graphs_Exampleto theProcessNetsfolder as:
cp -a Example/graphs_Example ProcessNets- Create the
Resultsdirectory as:
mkdir ProcessNets/Results- Copy the seed file as:
cp Example/seed.txt ProcessNets/Results- Execute the code as follows:
cd ProcessNets
time ./main.sh Results 50 100 -1 ExampleAll results generated will be contained in ProcessNets/Results, and will replicate Example/Results.
For each dataset, we provide codes both for parallel and sequential execution of different ensembles, constructed using the same procedure on the respective datasets but with different values of the parameters.
Note that, for parallel execution, each ensemble runs on dedicated
Before replicating the results, we start with cloning/downloading the project from GitHub to your local machine.
git clone https://github.com/BIRDSgroup/ProcesssNets PNets
cd PNets- To replicate the results in Simulated Ensemble I, use:
cd "Simulated Ensemble I"- To replicate the results in Simulated Ensemble II, use:
cd "Simulated Ensemble II"- To replicate the results in Real-World Ensembles on variants from the Muscle Skeletal tissue, use:
cd "Real World Ensembles"/"Muscle Skeletal"- To replicate the results in Real-World Ensembles on all chosen tissues, use:
cd "Real World Ensembles"/"All Chosen Tissues"For executing the programs and replicating the results, please do the following:
If you want parallel execution:
time ./run_parallel.shIf you want sequential execution:
time ./run_seq.shTo replicate these results, then please use the following:
cd "PNets/Miscellaneous/IOP Time/ProcessNets"If you want to replicate results on ensembles from Category A, then:
cp -r "../MS - Cat A - n_1000/graphs_Muscle_Skeletal" .
cp -r "../MS - Cat A - n_1000/Muscle_Skeletal" .
time ./main.sh Muscle_Skeletal/1000 1000 1000 -1 Muscle_SkeletalIf you want to replicate results on ensembles from Category B, then:
cp -r "../MS - Cat B - n_1000/graphs_Muscle_Skeletal" .
cp -r "../MS - Cat B - n_1000/Muscle_Skeletal" .
time ./main.sh Muscle_Skeletal/1000 1000 1000 -1 Muscle_Skeletal