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
- Build graphs in
samplesorfeaturesmode. - Work with single-omics or multilayer multi-omics data.
- Use
spearman,clr,rf, orglassoinference. - Tune graph construction with a reusable
grid -> scores_grid -> materializeworkflow. - Rank features with graph-aware label separation statistics.
- Visualize interactively with Plotly and export edge tables directly.
pip install netanRequires Python >=3.10.
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",
)
nt.plot(color="Group", title="Sample network")nt.build(
method="rf",
node_mode="samples",
layer_mode="multilayer",
k="auto",
)If you do not pass thresholds, netan sparsifies automatically through auto_target.
nt.info()
nt.params()
nt.scores()
nt.edges()nt.tune(label="Group")
nt.best()For repeated score iteration on the same candidate space:
nt.grid()
nt.scores_grid(
label="Group",
weights={
"sep": [15, 5, 80],
"supervised": [60, 15, 15, 10],
},
)
nt.materialize()nt.rank("Group")
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.
samples: nodes are samples and edges represent sample similarityfeatures: nodes are features and multilayer builds can include cross-omics feature edges
stack: one combined graphmultilayer: per-layer graphs plus integrated outputs
spearman: correlation-basedclr: mutual-information basedrf: ExtraTrees similarityglasso: sparse precision graph
auto_target: default thresholding controlk=None: threshold-only graphk="auto": adaptive kNN pruningmutual=True: stricter kNN graphattach_isolates=True: reconnect isolates after sparsification
tune() separates expensive candidate construction from cheap rescoring:
grid(): build all candidate graph states oncescores_grid(): score the grid in unsupervised or supervised modematerialize(): restore any leaderboard row as a liveNetanobject
This makes it practical to iterate on score weights without rerunning inference.
nt.plot(layout="kamada_kawai", color="Group")
nt.export("edges.csv")Supported layouts:
force-directedspringcircularkamada_kawairandom
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.
netan expects one object or a list of objects exposing:
r.X:pandas.DataFramewith shapefeatures x samplesr.samples:pandas.DataFramewhose first column contains sample IDs aligned tor.X.columnsr.features: optional feature metadata
Rodin already matches this layout.
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.
samplesmode is where label-aware tuning andrank()make the most sense.featuresmode is the right choice for variable-level network exploration.- For larger graphs,
spearman,clr, andrfare usually the practical defaults.
MIT