Microbe metabolite attribution scoring
Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder
npx -y skills add HolobiomicsLab/asb-skill-collections --skill microbe-metabolite-attribution-scoringAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 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 author says it does
Copied from the file, not written here
Use when after training multi-layer perceptron neural networks via cross-validation to predict metabolite abundances from microbiome composition, when you need to interpret which microbes drive predictions of specific metabolites and to identify groups of microbes with coherent metabolite.
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
11.2 KB, as published. Nobody here has run it
microbe-metabolite-attribution-scoring
Summary
Compute feature attribution scores linking individual microbes to predicted metabolites using Olden's method applied to trained neural network weights. This quantifies the directional and magnitude contribution of each microbe to each metabolite prediction, enabling downstream functional module discovery.
When to use
After training multi-layer perceptron neural networks via cross-validation to predict metabolite abundances from microbiome composition, when you need to interpret which microbes drive predictions of specific metabolites and to identify groups of microbes with coherent metabolite interaction patterns.
When NOT to use
- Linear regression models (e.g., Elastic Net, MelonnPan): Olden's method is designed for multi-layer networks and does not apply to single-layer linear models without modification.
- When microbes and metabolites have not yet been filtered for quality: apply feature presence filtering (features in <10% of samples removed) and well-predicted metabolite selection before attribution scoring.
- Input is a pre-computed interaction or correlation matrix rather than trained neural network weights: this skill specifically requires learned weight matrices from trained networks.
Inputs
- Trained neural network models from 10 iterations of 10-fold cross-validation (100 total models)
- Learned weight matrices W_l from all hidden layers of each trained model
- Background distribution of correlation coefficients from shuffled cross-validated data
- Significant correlation threshold from 95th percentile of background distribution
- List of well-predicted metabolites (those exceeding the 95th percentile threshold)
Outputs
- Per-model microbe-metabolite feature attribution score matrices (100 matrices, one per trained network)
- Normalized and clipped attribution score matrix S* (values in [−1, 1])
- Binary significance mask indicating microbe-metabolite pairs above 97.5th percentile threshold
- Filtered microbe list containing only those with ≥1 significant metabolite association
- Normalized attribution matrices indexed by microbe and metabolite feature names (NumPy arrays or CSV format)
How to apply
Extract weight matrices W_l from all hidden layers of each trained network model, then apply Olden's method by computing the element-wise product across layers: S = ∏(W_l) for l ∈ L, where each row represents a microbe input feature and each column a metabolite output feature. Normalize each attribution matrix S_i by dividing by the significant threshold score identified from a background distribution (generated by shuffling and cross-validating on permuted data). Clip normalized values to the range [−1, 1]. Flag microbe-metabolite pairs with absolute attribution scores above the 97.5th percentile of the background distribution as significant interactions. Positive scores indicate increased microbe abundance associates with increased metabolite abundance; negative scores indicate inverse associations. Retain only microbes with at least one significant attribution to well-predicted metabolites; filter out non-significant microbes from all downstream analyses.
Related tools
- MiMeNet (Source of trained multi-layer perceptron neural network models from which weight matrices are extracted for attribution scoring) — https://github.com/YDaiLab/MiMeNet
- TensorFlow or PyTorch (Framework used to implement neural networks and extract layer weight matrices for Olden's method computation)
- NumPy (Efficient element-wise matrix multiplication and normalization operations for computing and processing attribution score matrices)
- SciPy (Statistical functions for percentile calculations and background distribution analysis)
- Pandas (Data structure for organizing and indexing attribution matrices by microbe and metabolite feature names)
Examples
# Load 100 trained models and extract attribution scores
import numpy as np
import tensorflow as tf
from sklearn.preprocessing import StandardScaler
# For each of 100 models from cross-validation
attribution_matrices = []
for model_path in model_paths:
model = tf.keras.models.load_model(model_path)
# Extract weights and compute Olden's method: S = product of all layer weights
S = np.array([1.0]) # Start with identity
for layer in model.layers:
if len(layer.get_weights()) > 0:
W = layer.get_weights()[0]
S = S @ W
# Normalize by background threshold and clip to [-1, 1]
S_norm = np.clip(S / background_threshold, -1, 1)
attribution_matrices.append(S_norm)
# Identify significant pairs at 97.5th percentile
attribution_matrices = np.array(attribution_matrices)
significant_mask = np.abs(attribution_matrices) > np.percentile(np.abs(attribution_matrices), 97.5)
print(f'Significant interactions: {np.sum(significant_mask) / significant_mask.size * 100:.2f}%')
Evaluation signals
- All 100 per-model attribution matrices have shape (n_microbes, n_metabolites) matching input feature counts, with row and column labels preserved.
- Normalized score values are strictly within [−1, 1] after clipping; verify no values fall outside this range.
- Percentage of significant interactions (|score| > 97.5th percentile threshold) is <2.5% of all possible pairs, confirming threshold calibration against background distribution.
- Microbe rows with zero significant interactions are completely removed from S*; verify no microbes without ≥1 significant association remain in output.
- Sign consistency check: across the 100 models, a given microbe-metabolite pair should predominantly have the same sign (positive or negative) if the interaction is robust; high sign flipping suggests weak or noisy attribution.
Limitations
- Attribution scores are data-driven without incorporating mechanistic knowledge; scores reflect learned network associations but do not prove causal metabolic relationships.
- Olden's method assumes feed-forward network architecture; application to recurrent or other non-feedforward architectures requires modification.
- Background distribution and significance thresholds are sample-size and dataset-dependent; thresholds identified on one cohort (e.g., IBD PRISM) may not transfer to external cohorts with different sample sizes, prevalence, or microbiota composition.
- Not all metabolites may be genuinely associated with microbes; some may have low prediction correlations independent of microbiome, leading to lower average attribution scores across all metabolites.
- Attribution scores cannot distinguish direct versus indirect interactions—a high score may reflect direct microbe-metabolite relationships or microbe A → microbe B → metabolite cascades mediated through the latent layer representations.
Evidence
- [other] For each trained model, extract weight matrices W_l from all hidden layers l in the network.: "For each trained model, extract weight matrices W_l from all hidden layers l in the network."
- [other] Apply Olden's method by computing the product of weight matrices across all layers: S = ∏(W_l) for l ∈ L: "Apply Olden's method by computing the product of weight matrices across all layers: S = ∏(W_l) for l ∈ L, where each row represents a microbe input feature and each column represents a metabolite"
- [other] Normalize these scores by dividing by the significant threshold identified from background distribution and clips values to be between -1 and 1: "MiMeNet constructs a microbe-metabolite feature attribution score matrix using learned network weights from cross-validation training, then normalizes these scores by dividing by the significant"
- [other] absolute values above the 97.5th percentile threshold considered significant interactions: "with absolute values above the 97.5th percentile threshold considered significant interactions."
- [other] positive scores indicate increased microbe abundance leads to increased metabolite abundance, and negative scores indicate increased microbe abundance leads to decreased metabolite abundance: "where positive scores indicate increased microbe abundance leads to increased metabolite abundance, and negative scores indicate increased microbe abundance leads to decreased metabolite abundance."
- [results] We identified 163 microbes that had at least one significant attribution score with a well-predicted metabolite: "We identified 163 microbes that had at least one significant attribution score with a well-predicted metabolite"
- [methods] a threshold was set at the 97.5 percentile. Any feature attribution score in the observed dataset with an absolute value above the threshold was considered significant: "a threshold was set at the 97.5 percentile. Any feature attribution score in the observed dataset with an absolute value above the threshold was considered significant"
- [methods] We normalized the values in each feature attribution score matrix Si by dividing the significant threshold score identified from the background and clipped values to be between -1 and 1: "We normalized the values in each feature attribution score matrix Si by dividing the significant threshold score identified from the background and clipped values to be between -1 and 1"