agentsclimarketplace

Networkx object generation and export

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/networkx-object-generation-and-export

Use when after identifying statistically significant features and assigning them to structural clusters (isotopologue groups, adduct groups, cross-assay links) and correlation clusters via MamsiStructSearch.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill networkx-object-generation-and-export

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.2 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

NetworkX object generation and export

Summary

Convert structural cluster assignments and feature metadata into a NetworkX graph object, optionally visualizing it with pyvis and exporting for interactive analysis in Cytoscape. This skill enables programmatic construction of metabolite feature networks where nodes represent features and edges encode structural relationships (isotopologues, adducts, cross-assay links, correlation clusters).

When to use

After identifying statistically significant features and assigning them to structural clusters (isotopologue groups, adduct groups, cross-assay links) and correlation clusters via MamsiStructSearch. Use this skill when you need to represent pairwise structural relationships between features as a graph for visualization, curation, or downstream analysis in network tools.

When NOT to use

  • Features have not yet been assigned to structural clusters or correlation clusters; run MamsiStructSearch.get_structural_clusters() and get_correlation_clusters() first.
  • Input is already a NetworkX object or graph file format; use import/load functions instead.
  • Goal is to identify structural relationships de novo; this skill assumes upstream structural search has already been completed.

Inputs

  • Feature metadata table (assay, m/z, retention time, cluster membership, compound annotation)
  • Structural cluster assignments (isotopologue groups, adduct groups, cross-assay links)
  • Correlation cluster assignments from hierarchical clustering
  • Boolean parameter: include_all (True to include all features, False to filter to structurally linked features only)

Outputs

  • NetworkX graph object (nodes=features, edges=structural links with weights)
  • Interactive HTML visualization (pyvis network graph with spring layout)
  • Node attributes (assay, m/z, retention time, cluster membership, annotation)
  • Edge attributes (weight, link_type)

How to apply

Load feature metadata (m/z, retention time, assay identifier, cluster membership, compound annotation) and structural link assignments from MamsiStructSearch outputs. Create a NetworkX DiGraph or Graph with features as nodes, assigning node attributes from the metadata. Add weighted edges between nodes based on structural link type: weight 1 for isotopologue links (mass difference 1.00335 Da), weight 5 for adduct links (matching neutral masses within 15 ppm tolerance), weight 10 for cross-assay links ([M+H]+/[M-H]− references), and weight 15 for correlation cluster co-membership. Optionally filter to include only structurally linked features or include all features. Generate an interactive pyvis visualization with spring layout and node colors by correlation cluster; save as HTML. Return the NetworkX object for programmatic analysis or import into Cytoscape for manual curation and inspection of edge types.

Related tools

  • networkx (Core library for graph construction, node/edge attribute assignment, and programmatic analysis) — https://networkx.org
  • pyvis (Interactive HTML visualization of NetworkX graph with spring layout, node coloring, and edge thickness scaling) — https://pyvis.readthedocs.io
  • Cytoscape (Desktop application for manual curation, filtering, and exploratory analysis of exported NetworkX objects) — https://cytoscape.org
  • pandas (Load and manipulate feature metadata tables before graph construction) — https://pandas.pydata.org
  • MamsiStructSearch (Upstream tool that generates structural and correlation cluster assignments consumed by this skill) — https://github.com/kopeckylukas/py-mamsi

Examples

network = struct.get_structural_network(include_all=True, interactive=False, labels=True, return_nx_object=True)

Evaluation signals

  • NetworkX object has non-zero number of nodes equal to the number of features and edges equal to the number of identified structural relationships.
  • All nodes have assigned attributes (assay, m/z, retention time, cluster membership, annotation) with no missing values for required fields.
  • All edges have assigned weights matching the expected link types (isotopologue=1, adduct=5, cross-assay=10, correlation=15); sum of edge weights correlates with number of each link type.
  • Interactive HTML visualization renders without errors, node colors correspond to correlation cluster membership, and edge thickness is proportional to weight.
  • NetworkX object can be serialized and imported into Cytoscape without data loss or corruption; manual inspection confirms edge types match upstream structural search output.

Limitations

  • Visualization with pyvis can become cluttered and difficult to interpret with >500 nodes; filtering to structurally linked features only (include_all=False) is recommended for large datasets.
  • Edge weight scheme is fixed; custom link type definitions or weights require modification to the underlying MamsiStructSearch code.
  • Cytoscape import requires manual steps for interactive exploration; no automated curation or filtering is performed by this skill.
  • Correlation cluster assignment depends on hierarchical clustering parameters (flat_method, max_clusters); different choices produce different network topologies.
  • Cross-assay links use [M+H]+/[M-H]− as references only; other adduct pairs or ionization modes are not supported in the current implementation.

Evidence

  • [other] Create NetworkX graph with features as nodes, assigning node attributes (assay, m/z, retention time, cluster membership, compound annotation) extracted from feature metadata.: "Create NetworkX graph with features as nodes, assigning node attributes (assay, m/z, retention time, cluster membership, compound annotation) extracted from feature metadata."
  • [other] Add edges between nodes based on structural link type: assign weight 1 for isotopologue links, weight 5 for adduct links, weight 10 for cross-assay links, and weight 15 for correlation cluster co-membership.: "Add edges between nodes based on structural link type: assign weight 1 for isotopologue links, weight 5 for adduct links, weight 10 for cross-assay links, and weight 15 for correlation cluster"
  • [other] Generate interactive pyvis.network visualization with spring layout, node coloring by correlation cluster membership, and edge thickness proportional to link weight; save as HTML artifact.: "Generate interactive pyvis.network visualization with spring layout, node coloring by correlation cluster membership, and edge thickness proportional to link weight; save as HTML artifact."
  • [readme] You can also save the network as an NX object and review in Cytoscape to get better insight on what the structural relationships between individual features are: "You can also save the network as an NX object and review in Cytoscape to get better insight on what the structural relationships between individual features are"
  • [readme] The different node colours represent different flattened hierarchical correlation clusters, while the edges between nodes identify their structural links.: "The different node colours represent different flattened hierarchical correlation clusters, while the edges between nodes identify their structural links."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.