agentsclimarketplace

Variable importance ranking and interpretation

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/variable-importance-ranking-and-interpretation

Use when after fitting a random forest classifier to metabolomics count data with a binary or multiclass grouping variable (e.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill variable-importance-ranking-and-interpretation

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

7.2 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

variable-importance-ranking-and-interpretation

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Ranks and visualizes metabolite importance in random forest classification models to identify which compounds discriminate between experimental groups. This skill extracts feature importance scores from a fitted random forest model and generates publication-ready plots, enabling interpretation of which metabolites drive group separation in metabolomics datasets.

When to use

After fitting a random forest classifier to metabolomics count data with a binary or multiclass grouping variable (e.g., treatment, genotype, disease status), use this skill to identify which metabolites are most predictive of group membership and to communicate their relative importance in a figure.

When NOT to use

  • Input random forest model was not fitted to metabolomics count data or was trained on pre-aggregated/collapsed features rather than individual metabolites.
  • Grouping variable is continuous (e.g., pH, age in years) rather than categorical; random forest importance is designed for classification tasks, not regression.
  • Dataset has extreme class imbalance or very few samples per group, making importance scores unreliable due to instability in tree construction.

Inputs

  • randomForest model object (output from Omu's random_forest wrapper function)
  • Metabolomics count data (c57_nos2KO_mouse_countDF or equivalent count matrix)
  • Metadata with grouping factor (e.g., Treatment, Grouped column from c57_nos2KO_mouse_metadata)

Outputs

  • ggplot2 object showing ranked metabolite importance scores
  • Variable importance ranking (metabolite names and scores)
  • Publication-ready visualization customizable with ggplot2 themes

How to apply

Call the plot_variable_importance function on the random forest model object returned by the Omu random_forest wrapper. This function extracts variable importance scores (which measure the decrease in impurity, typically Gini importance, across all splits in the forest) and produces a ggplot2 object ranking metabolites by importance. The resulting plot can be customized with standard ggplot2 themes (e.g., theme_bw) to remove gridlines or adjust aesthetics. Importance scores reflect the average discriminative power of each metabolite across all trees; metabolites with higher scores contributed more to correct classification. Inspect the top-ranked metabolites to identify which compounds or metabolite classes best separate your experimental groups.

Related tools

  • randomForest (Underlying R package that implements the random forest algorithm; Omu's random_forest wrapper calls randomForest with default hyperparameters and returns a model object containing importance scores.) — https://cran.r-project.org/web/packages/randomForest/
  • ggplot2 (Produces the variable importance plot as a ggplot2 object, allowing customization with themes, coordinate flips, and geom modifications.) — https://ggplot2.tidyverse.org/
  • Omu (R package containing the random_forest wrapper function and plot_variable_importance function that extract and visualize variable importance from randomForest models applied to metabolomics data.) — https://github.com/connor-reid-tiffany/Omu

Examples

model <- random_forest(count_data=c57_nos2KO_mouse_countDF, metadata=c57_nos2KO_mouse_metadata, response='Metabolite', grouping='Treatment'); plot_variable_importance(model) + theme_bw() + theme(panel.grid=element_blank())

Evaluation signals

  • Variable importance plot displays all metabolites ranked by importance score in descending order; top metabolites should correspond to compounds known to differ between experimental groups.
  • Importance scores are non-negative and sum to a total reflecting the model's discriminative power; verify no scores are NaN or Inf.
  • Plot is a ggplot2 object that responds to ggplot2 theme functions (e.g., theme_bw); custom themes can be applied without error.
  • Random forest model accuracy or out-of-bag error rate is reasonable (better than random guessing) on the grouping variable; poor model performance indicates importance scores may be uninformative.
  • Top-ranked metabolites, when manually inspected in the original count data, show visibly different distributions or mean abundance across groups.

Limitations

  • Variable importance scores depend on default randomForest hyperparameters (mtry, ntree, etc.) documented in the randomForest package; changing these parameters may alter rankings.
  • Importance is biased toward high-cardinality features in some implementations; metabolites with many unique values may receive inflated importance scores.
  • Importance does not measure effect size or biological significance; a metabolite can rank high while having a small log-fold-change between groups.
  • No built-in statistical significance test for importance scores; practitioners should consider permutation testing or cross-validation to assess ranking stability.
  • Omu's documentation does not specify the exact importance metric (Gini, permutation, etc.) used by the random_forest wrapper, making it difficult to reproduce or compare with other implementations.

Evidence

  • [other] Extract variable importance: "Generate a variable importance plot using plot_variable_importance on the random forest model object, which produces a ggplot2 object"
  • [other] Customize with ggplot2: "customize with ggplot2 themes as desired (e.g., theme_bw, remove gridlines)"
  • [other] Random forest wrapper in Omu: "Omu has a function, random_forest, which is a wrapper built around the function randomForest from the R package randomForest"
  • [other] ggplot2 compatibility: "The figure is a ggplot2 object, so it is compatible with any ggplot2 themes"
  • [other] Model output structure: "Extract the returned random forest model object and associated metadata from the wrapper output"

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.