Giter Club home page Giter Club logo

nestedness_modularity_in-block_nestedness_analysis's Introduction

Structural Analysis Nestedness, Modularity and In-block

This code performs structural analysis in binary unipartite and bipartite networks by means of in-block nestedness as defined by Solé-Ribalta et al, PRE 2018 (https://doi.org/10.1103/PhysRevE.97.062302), as well as global nestedness and modularity.

Inputs:

  1. path-folder = directory where the network data files are. The data files with .csv file extension. It can be either in edge list or adjacency matrix format with no headers.
  2. bipartite = boolean value to indicate if "filename" is a bipartite (True) or unipartite (False) network.
  3. edge_data = boolean value indicating the format of the data file. Three-column/edge list (True) or matrix format (False).

Outputs:

  1. A summary file, data_structures_NQI_results.csv, containing as many rows as input files found in path-folder. Its columns report for each network analysed the name of its input file, and the values of formula, formula, and formula.

  2. As many files as input files with general naming in-block_partition_<filename>.csv, where <filename> is the extensionless name of the respective input file. Each files are formed by one or two columns, depending whether the network is unipartite or bipartite. A column contains the indices of the block each node is assigned to by optimizing the in-block nestedness, following zero indexing. Therefore, columns' lengths equal the number of nodes present in the corresponding graph or subgraph. As an example for a bipartite network, the i-th value of the column labelled by rows (columns) indicates the block of the i-th node of the subgraph associated to the rows (columns) of the input adjacency matrix. N.B. block indices are generally not contiguous, namely, the number of blocks does not in principle coincide with the largest block index+1.

  3. Like above, but the general naming is modularity_partition_<filename>.csv and partitions are calculated by optimising the modularity.

If for example we pass bipartite=True and edge_data=True, all the networks we want to analyze have to fulfill such conditions.

example:

python structural_analysis.py home/User/data/ True False

Nestedness and In-block nestedness

Both metrics are computed considering the condition formula to compare the paired overlap between pairs of nodes, in contrast with the NODF metrics that considers formula

Modularity and in-block nestedness optimization

The optimization of modularity and in-block nestedness is performed by employing the Extremal optimization algorithm (https://doi.org/10.1103/PhysRevE.72.027104). The main code for this function was written in c++ and should be compiled as a file with a .so extension for Python 3.x. This file will be imported in Python as a library.

This will be possible for MacOS or Linux.

System Requirements

Compilers

  1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or newer) or
  2. GCC 4.8 or newer

Python 3.x.

pybind11 (via pip or conda)

To compile the c++ files

Compilation on Linux:

g++ -O3 -Wall -shared -std=c++11 -fPIC `python -m pybind11 --includes` EO_functions_bipartite.cpp -o extremal_bi.so

Compilation on MacOS:

g++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup `python -m pybind11 --includes` EO_functions_bipartite.cpp -o extremal_bi.so

Citations

DOI

MJ Palazzi, J Borge-Holthoefer, CJ Tessone and A Solé-Ribalta. Macro- and mesoscale pattern interdependencies in complex networks. J. R. Soc. Interface, 16, 159, 20190553 (2019). DOI: 10.1098/rsif.2019.0553

MJ Palazzi, A Solé-Ribalta, V Calleja-Solanas, CA Plata, S Meloni, S Suweis and J Borge-Holthoefer. An ecological approach to structural flexibility in online communication systems. Nature Communications, 12, 1941 (2021). DOI: 10.1038/s41467-021-22184-2

nestedness_modularity_in-block_nestedness_analysis's People

Contributors

justinloye avatar mariapalazzi avatar

nestedness_modularity_in-block_nestedness_analysis's Issues

UnboundLocalError: local variable 'Ci_' referenced before assignment

This error occurs when I attempt to run structural_analysis.py, line 55.

Comparing the "# In-block nestedness with B=1" block of code with the "#Modularity Extremal" and "# Inblock nestedness extremal" blocks, I guess the fix is replacing

max_blockN=max(max(Ci_[0]),max(Ci_[1]))+1

by

max_blockN=max(max(Cn_[0]),max(Cn_[1]))+1

PR: #2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.