agentsclimarketplace

Principal component analysis for metabolomics

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/principal-component-analysis-for-metabolomics

Use when after loading a Metaboprep object containing metabolomic abundance data when you need to: (1) identify samples that are statistical outliers in multivariate metabolite space; (2) determine the number of statistically significant principal components;From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill principal-component-analysis-for-metabolomics

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

  • 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 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.6 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

principal-component-analysis-for-metabolomics

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

Summary

Apply principal component analysis (PCA) to metabolomics abundance matrices to identify and enumerate sample outliers in reduced principal component space at user-specified standard deviation thresholds. This skill enables detection of multivariate outliers and assessment of data quality before downstream statistical analysis.

When to use

Apply this skill after loading a Metaboprep object containing metabolomic abundance data when you need to: (1) identify samples that are statistical outliers in multivariate metabolite space; (2) determine the number of statistically significant principal components; (3) evaluate sample quality across multiple SD cutoffs (3, 4, 5 SD) to decide on exclusion thresholds; or (4) assess whether samples cluster appropriately by known experimental variables before proceeding to association analysis.

When NOT to use

  • Input is already a pre-filtered feature table without access to the original Metaboprep object structure
  • You have fewer samples than features after median imputation (PCA may be unstable)
  • Your metabolomics dataset has been heavily pre-filtered such that only 1–2 informative PCs remain, limiting sensitivity to multivariate outliers

Inputs

  • Metaboprep object with metabolite abundance matrix (samples × features)
  • source_layer parameter specifying which data layer to analyze (e.g., 'input', 'qc')
  • optional sample_ids filter to subset samples
  • optional feature_ids filter to subset features

Outputs

  • data.frame with PC eigenvectors for top 10 principal components
  • outlier count vector at 3 SD, 4 SD, and 5 SD thresholds on top 2 PCs
  • variance explained vector (attribute)
  • acceleration factor result (attribute)
  • parallel analysis result (attribute)

How to apply

Load a Metaboprep object containing metabolomic data and call pc_and_outliers() with a specified source_layer (e.g., 'input' or 'qc'). The function internally imputes missing data to the median, performs acceleration analysis and parallel analysis to determine the number of significant principal components automatically, then computes eigenvectors for the top 10 PCs. Sample outliers are counted at 3 SD, 4 SD, and 5 SD thresholds on the top two PCs. The choice of SD threshold depends on your tolerance for false positive exclusions: lower thresholds (3 SD) are more stringent; higher thresholds (5 SD) are more conservative. Return values include PC eigenvectors, variance explained per PC, and outlier counts at each threshold, which can inform downstream QC filtering decisions via the quality_control function.

Related tools

  • metaboprep (R package providing pc_and_outliers() function and Metaboprep object container for metabolomics data) — https://github.com/MRCIEU/metaboprep
  • R (Statistical computing environment in which metaboprep and PCA functions execute)
  • ggplot2 (Visualization library for plotting PCA scores and outlier distributions)

Examples

pc_result <- pc_and_outliers(metaboprep = mydata, source_layer = "input", sample_ids = NULL, feature_ids = NULL)

Evaluation signals

  • PC eigenvectors are non-zero and ordered by decreasing variance explained; first two PCs capture the dominant axes of metabolite variation
  • Outlier counts at 3 SD ≥ counts at 4 SD ≥ counts at 5 SD (monotonic ordering enforced by stricter thresholds)
  • Variance explained per PC decreases monotonically; sum of explained variance for top 2 PCs is typically 30–60% for metabolomics data
  • Samples identified as outliers at 5 SD threshold align with known problematic samples (failed QC, extreme missingness, or known batch effects) when cross-checked against sample metadata
  • Number of statistically significant PCs returned by acceleration/parallel analysis is ≤ min(samples, features) and is consistent across repeated calls on the same data

Limitations

  • Missing data imputation is performed only to the median; systematic or non-random missingness may inflate variance and bias PC estimates
  • The function assumes that metabolite features are reasonably independent before PCA; highly correlated features (e.g., from the same pathway or isotopologue series) can inflate specific PC axes
  • Outlier detection is performed on only the top 2 PCs; rare outliers that deviate along lower-variance PCs (PC 3+) may be missed
  • SD thresholds (3, 4, 5) are fixed; no adaptive threshold selection based on the empirical distribution is performed
  • If the number of available informative PCs is smaller than max_num_pcs (default 10), a warning is issued but analysis proceeds; this may reduce outlier detection power if samples are similar

Evidence

  • [methods] The pc_and_outliers function internally imputes missing data to the median, performs acceleration analysis and parallel analysis to determine the number of significant PCs, and computes sample outlier counts at 3 SD, 4 SD, and 5 SD thresholds on the top two PCs.: "The function internally imputes missing data to the median, performs acceleration analysis and parallel analysis to determine the number of significant PCs, and computes sample outlier counts at 3"
  • [methods] The metaboprep package provides data filtering capabilities including outlier detection mechanisms applied to principal components at configurable standard deviation cutoffs.: "The metaboprep package provides data filtering capabilities using a standard pipeline with user-defined thresholds, which includes outlier detection mechanisms applied to principal components at"
  • [methods] Return a data.frame with PC eigenvectors for the top 10 PCs and outlier counts, plus attributes containing variance explained vector, acceleration factor result, and parallel analysis result.: "Return a data.frame with PC eigenvectors for the top 10 PCs and outlier counts, plus attributes containing variance explained vector, acceleration factor result, and parallel analysis result."
  • [readme] Running sample data PCA outlier analysis at +/- 5 Sdev with re-identification of feature independence and PC outliers.: "Running sample data PCA outlier analysis at +/- 5 Sdev - re-identify feature independence and PC outlier analysis"

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 326,861. 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.