Code Monkey home page Code Monkey logo

netsci's Introduction

netsci

Analyzing Complex Networks with Python

Author Version Demo
Gialdetti PyPI Binder

netsci is a python package for efficient statistical analysis of spatially-embedded networks. In addition, it offers several algorithms and implementations (CPU and GPU-based) of motif counting algorithms.

For other models and metrics, we highly recommend using existing and richer tools. Noteworthy packages are the magnificent NetworkX, graph-tool or Brain Connectivity Toolbox.

A simple example

Analyzing a star network (of four nodes)

import numpy as np
import netsci.visualization as nsv

A = np.array([[0,1,1,1], [0,0,0,0], [0,0,0,0], [0,0,0,0]])
nsv.plot_directed_network(A, pos=[[0,0],[-1,1],[1,1],[0,-np.sqrt(2)]])

Alt text

import netsci.metrics.motifs as nsm
f = nsm.motifs(A, algorithm='brute-force')
print(f)
# [1 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0]
nsv.bar_motifs(f)

Alt text

GPU speedup

Using GPU for the motif counting is easy

from netsci.models.random import erdos_renyi

A_er = erdos_renyi(n=1000, p=0.01, random_state=71070)    # Create an Erdős–Rényi network
f_er = nsm.motifs(A_er, algorithm='gpu')                  # Count motifs using a GPU

print(f_er)
# [156453141   9481653     37283     95997     47667     48287      1001       843
#        769       334         2         9         5         9         0         0]

The running-time speedup resulting from the GPU-based implementation, as measured over several networks sizes (n) and sparsities (p), is depicted below

A full a live notebook for performing this benmarching is provided below.

Installation

Install latest release version via pip

$ pip install netsci

Install latest development version

via pip

$ pip install git+https://github.com/gialdetti/netsci.git

or in development mode

$ git clone https://github.com/gialdetti/netsci.git
$ cd netsci
$ pip install -e .

Testing

After installation, you can launch the test suite:

$ pytest

Help and Support

Examples

Theme MyBinder Colab
Basic network motifs demo Binder
Connectomics dataset, and 3-neuron motif embedding Binder Open In Colab
Tech: GPU speedup of motif analysis Binder Open In Colab

Communication

Please send any questions you might have about the code and/or the algorithm to [email protected].

Citation

If you use netsci in a scientific publication, please consider citing the following paper:

Gal, E., Perin, R., Markram, H., London, M., and Segev, I. (2019). Neuron Geometry Underlies a Universal Local Architecture in Neuronal Networks. BioRxiv 656058.

Bibtex entry:

@article {Gal2019
    author = {Gal, Eyal and Perin, Rodrigo and Markram, Henry and London, Michael and Segev, Idan},
    title = {Neuron Geometry Underlies a Universal Local Architecture in Neuronal Networks},
    year = {2019},
    doi = {10.1101/656058},
    journal = {bioRxiv}
}

netsci's People

Contributors

gialdetti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netsci's Issues

How to use the tool with giant adj matrices.

I am trying to compute triad motifs for a network of 500k neurons and needed to use scipy scr matrix. Otherwise around 2TB of mem is required. Is there a way to use csr matrix in netsci.metrics.motifs.motifs ? Or what do you suggest?

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.