Skip to main content

DOMINO, Detection Of MesoscopIc structures via iNfOrmation criteria

Project description

DOMINO - Detection Of MesoscopIc structures via iNfOrmation criteria

DOMINO is a mesoscale detection framework that combines Leiden optimization with Bayesian Information Criterion (BIC) minimization under several Stochastic Block Model (SBM) likelihoods.

Supported modes:

  • binary: SBM, dcSBM
  • signed: signed SBM, signed dcSBM (positive, negative, absent)
  • weighted: geometric-weight SBM, and its degree-corrected variant

The recommended public entry point is detect.

Installation

Editable install (development):

python -m pip install -e ".[viz]"

Run tests:

python -m pip install pytest
pytest -q

Quickstart

Binary SBM (non degree-corrected)

import numpy as np
import networkx as nx
from domino import detect

rng = np.random.default_rng(0)
A = (rng.random((100, 100)) < 0.05).astype(int)
A = np.triu(A, 1)
A = A + A.T
G = nx.from_numpy_array(A)

res = detect(G, A, mode="binary", degree_corrected=False, max_outer=3)
part, bic = res["partition"], res["bic"]
print("K:", len(part), "BIC:", bic)

Signed SBM (non degree-corrected)

You can pass a single signed matrix A with negative entries.

import numpy as np
import networkx as nx
from domino import detect

rng = np.random.default_rng(1)
n = 100
A = np.zeros((n, n), dtype=float)

# Two blocks with positive internal edges
A[:50, :50] = (rng.random((50, 50)) < 0.10).astype(float)
A[50:, 50:] = (rng.random((50, 50)) < 0.10).astype(float)

# Negative cross-block edges
A[:50, 50:] = -(rng.random((50, 50)) < 0.08).astype(float)
A[50:, :50] = A[:50, 50:].T
np.fill_diagonal(A, 0.0)
A = np.triu(A, 1)
A = A + A.T

G = nx.from_numpy_array((np.abs(A) > 0).astype(int))
res = detect(G, A, mode="signed", degree_corrected=False, max_outer=3)
part, bic = res["partition"], res["bic"]
print("K:", len(part), "BIC:", bic)

Weighted SBM (geometric, non degree-corrected)

import numpy as np
import networkx as nx
from domino import detect

rng = np.random.default_rng(2)
W = rng.poisson(2.0, size=(100, 100)).astype(float)
W = np.triu(W, 1)
W = W + W.T
np.fill_diagonal(W, 0.0)

G = nx.from_numpy_array((W > 0).astype(int))
res = detect(G, W, mode="weighted", degree_corrected=False, max_outer=3)
part, bic = res["partition"], res["bic"]
print("K:", len(part), "BIC:", bic)

Documentation

  • Usage notes: docs/usage.md
  • Mathematical details: docs/math.md
  • API quick reference: docs/api_quick_reference.md

Continuous integration

GitHub Actions workflow: .github/workflows/ci.yml

License

See LICENSE.

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

domino_mesoscale-0.1.0.tar.gz (68.2 kB view details)

Uploaded Source

Built Distribution

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

domino_mesoscale-0.1.0-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

Details for the file domino_mesoscale-0.1.0.tar.gz.

File metadata

  • Download URL: domino_mesoscale-0.1.0.tar.gz
  • Upload date:
  • Size: 68.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for domino_mesoscale-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be3334ada23591a739fa0005a010147b0df4a7df3d1e9dd24caf02ac284e9084
MD5 88c3028a4a82e67a0f32d9a8300a4375
BLAKE2b-256 d1cbff084937f67b2583f529d09a1c044d695e9439615c662f5c350342b1c3fb

See more details on using hashes here.

File details

Details for the file domino_mesoscale-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for domino_mesoscale-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 338b6d0c3d33bb521d43f2d9ee874076132e081a39fa9917c27b0bbee74080ef
MD5 da87b19bfe84a8aa1de882d4e95d41b2
BLAKE2b-256 662958fb7bd92ac59eddb7b00e474f55d7c56631da56f6f12375077e43cfaa8f

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