Skip to main content

Network builder for multi-omics matrices.

Project description

netan

PyPI version Python License

netan is a network analysis library for omics data. It builds sample or feature graphs from one or more matrices, tunes graph construction, ranks features against sample labels, and exports publication-ready or Cytoscape-ready outputs.

It works naturally with rodin and Rodin-like objects.

Web app: netan.io

Highlights

  • Build graphs in samples or features mode.
  • Work with single-omics or multilayer multi-omics data.
  • Use spearman, clr, rf, or glasso inference.
  • Tune graph construction with a reusable grid -> scores_grid -> materialize workflow.
  • Rank features with graph-aware label separation statistics.
  • Visualize interactively with Plotly and export edge tables directly.

Installation

pip install netan

Requires Python >=3.10.

Quick start

import rodin
import netan

r1 = rodin.create("metabolomics.csv", "meta.csv")
r2 = rodin.create("transcriptomics.csv", "meta.csv")

r1.transform()
r2.transform()

nt = netan.create([r1, r2])

nt.build(
    method="spearman",
    node_mode="samples",
    layer_mode="multilayer",
    graph="entire",
)

nt.plot(color="Group", title="Sample network")

Core workflow

Build

nt.build(
    method="rf",
    node_mode="samples",
    layer_mode="multilayer",
    graph="entire",
    k="auto",
)

If you do not pass thresholds, netan sparsifies automatically through auto_target.

Inspect

nt.info()
nt.params()
nt.scores()
edges = nt.edges()

Tune

tbl = nt.tune(label="Group", apply=False)
best = nt.best()
nt.materialize()

For repeated score iteration on the same candidate space:

g = nt.grid()

tbl = nt.scores_grid(
    g,
    label="Group",
    weights={
        "sep": [15, 5, 80],
        "supervised": [60, 15, 15, 10],
    },
)

nt.materialize(candidate=0)

Rank and shortlist

ranked = nt.rank("Group")
stable = nt.stability_rank("Group")
nt_small = nt.shortlist(p_adj_max=0.01)

This workflow is available in samples mode and is useful when you want graph-aware feature selection before rebuilding a smaller network.

Concepts

Node mode

  • samples: nodes are samples and edges represent sample similarity
  • features: nodes are features and multilayer builds can include cross-omics feature edges

Layer mode

  • stack: one combined graph
  • multilayer: per-layer graphs plus integrated outputs

Methods

  • spearman: correlation-based
  • clr: mutual-information based
  • rf: ExtraTrees similarity
  • glasso: sparse precision graph

Sparsity controls

  • auto_target: default thresholding control
  • k=None: threshold-only graph
  • k="auto": adaptive kNN pruning
  • mutual=True: stricter kNN graph
  • attach_isolates=True: reconnect isolates after sparsification

Tuning model

tune() separates expensive candidate construction from cheap rescoring:

  • grid(): build all candidate graph states once
  • scores_grid(): score the grid in unsupervised or supervised mode
  • materialize(): restore any leaderboard row as a live Netan object

This makes it practical to iterate on score weights without rerunning inference.

Visualization and export

fig = nt.plot(layout="spring", color="Group")
nt.export("edges.csv")

Supported layouts:

  • force-directed
  • spring
  • circular
  • kamada_kawai
  • random

Persistence

path = nt.save("netan.pkl")
nt2 = netan.load(path)

This restores stored graphs, rankings, caches, and tuning grids. The live Plotly figure handle is not serialized.

Input contract

netan expects one object or a list of objects exposing:

  • r.X: pandas.DataFrame with shape features x samples
  • r.samples: pandas.DataFrame whose first column contains sample IDs aligned to r.X.columns
  • r.features: optional feature metadata

Rodin already matches this layout.

Public API

Main entry points:

  • netan.create(...)
  • netan.load(path)
  • Netan.build(...)
  • Netan.adjust(...)
  • Netan.grid(...)
  • Netan.scores_grid(...)
  • Netan.materialize(...)
  • Netan.tune(...)
  • Netan.rank(...)
  • Netan.stability_rank(...)
  • Netan.shortlist(...)
  • Netan.plot(...)
  • Netan.export(...)
  • Netan.save(path)

For exact parameters, use the Python docstrings.

Notes

  • samples mode is where label-aware tuning and rank() make the most sense.
  • features mode is the right choice for variable-level network exploration.
  • For larger graphs, spearman, clr, and rf are usually the practical defaults.

License

MIT

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

netan-2.0.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

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

netan-2.0-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

Details for the file netan-2.0.tar.gz.

File metadata

  • Download URL: netan-2.0.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for netan-2.0.tar.gz
Algorithm Hash digest
SHA256 05b97ec6fae17380b342d57529ca5c7a83e64fe2505c458ac11610e26298ad21
MD5 39a1493be94dd7a7eb026ba374503d44
BLAKE2b-256 bd5dbb16b4deadecd0132a6ad851c300a2109edf0de3ebc52d4a0c9ccdbaf1e0

See more details on using hashes here.

File details

Details for the file netan-2.0-py3-none-any.whl.

File metadata

  • Download URL: netan-2.0-py3-none-any.whl
  • Upload date:
  • Size: 71.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for netan-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 591cc0741be803710a1cc17aa839a2df4944524686097df9a4b04e12cddababc
MD5 8823b3f11a264fe730d67dd3e6755231
BLAKE2b-256 0c0eba7423529794c78247b341b55544514c90e68f192eef3c31fdfc8d33df7c

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