Skip to main content

Analyzing Complex Networks with Python

Project description

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

# Create an Erdős–Rényi network, and count motifs using a GPU
A_er = erdos_renyi(n=500, p=0.2, random_state=71070)  
f_er = nsm.motifs(A_er, algorithm="gpu")

# Visualize
print(f_er)
# [5447433 8132356 1031546 2023563 1011703 1011109  503098  512458
#   513352  167427   64844  127751   64442   63548   32483    1387]
nsv.bar_motifs(f_er)

The running-time speedup ratio 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 .[dev]

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 eyal.gal@mail.huji.ac.il.

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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netsci-0.0.4.tar.gz (467.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netsci-0.0.4-py3-none-any.whl (469.1 kB view details)

Uploaded Python 3

File details

Details for the file netsci-0.0.4.tar.gz.

File metadata

  • Download URL: netsci-0.0.4.tar.gz
  • Upload date:
  • Size: 467.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for netsci-0.0.4.tar.gz
Algorithm Hash digest
SHA256 bb83f3e448f3580d30c035ea914d0ab7365f2bc328f6d3a627201fa2e5d3fa25
MD5 5cd8f450ef7f698a2343d2f76ed0b295
BLAKE2b-256 c2c1ea65d90a251da152b267d09f6c7f322f1c7522c8ac8e5a5450a68f66522d

See more details on using hashes here.

File details

Details for the file netsci-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: netsci-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 469.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for netsci-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1a1851991b87df522297d3e70c5c5707cdab8f7da71ab8673e717ebe70ad7716
MD5 d2ca3b50bc4edc52f3a7d8ed94749f50
BLAKE2b-256 3776949e0d1f75db2848d2f108840ba37b1ad2b31510905e2a7046fa4d9a75f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page