agentsclimarketplace

Dmodx orthogonal distance metric

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/dmodx-orthogonal-distance-metric

Use when apply DModX when you have a normalized LC-MS feature matrix (post-normalization, Step 7 in OUKS) and need to identify samples whose metabolomic profiles are systematically displaced from the learned PCA subspace—indicating potential technical artifacts, extreme biological phenotypes, or.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill dmodx-orthogonal-distance-metric

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

DModX Orthogonal Distance Metric

Summary

DModX (Distance to Model in X-space) quantifies the orthogonal distance of each sample from the principal component model subspace in untargeted LC-MS metabolomic data, enabling detection of samples that deviate structurally from the main dataset population. This metric complements Hotelling T-squared for robust multivariate outlier detection in preprocessed feature matrices.

When to use

Apply DModX when you have a normalized LC-MS feature matrix (post-normalization, Step 7 in OUKS) and need to identify samples whose metabolomic profiles are systematically displaced from the learned PCA subspace—indicating potential technical artifacts, extreme biological phenotypes, or sample contamination that should be flagged before statistical hypothesis testing.

When NOT to use

  • Input feature matrix has not been normalized (Box-Cox or equivalent); DModX is most interpretable on variance-stabilized data.
  • Sample size is extremely small (<10–15); PCA model and percentile thresholds become unstable with insufficient training data.
  • You have already filtered or removed obvious outliers by other means (e.g., QC-based drift correction); DModX may flag fewer additional samples.

Inputs

  • Preprocessed feature matrix (normalized, post-Step 7 normalization)
  • Sample metadata (optional, for stratified threshold definition)

Outputs

  • Per-sample DModX scores (numeric vector)
  • Per-sample outlier flags (logical/binary vector)
  • Tabular outlier report with sample IDs, DModX scores, and threshold status

How to apply

After normalization (Box-Cox transformation), construct a PCA model on the preprocessed feature matrix to define the principal component subspace. For each sample, compute its orthogonal projection residual—the Euclidean distance from the sample to its projection onto the PCA subspace. Establish a DModX threshold (typically the 95th percentile of the training distribution or a user-specified limit based on expected model fit). Flag samples exceeding this threshold as outliers. Output per-sample DModX scores and binary outlier status (TRUE/FALSE). The rationale is that legitimate samples cluster near the model, while outliers (batch effects, instrument drift, biological extremes) produce large residuals in the X-space orthogonal to the learned components.

Related tools

Examples

# Load normalized feature matrix post-Step 7; compute PCA and DModX outlier scores
pca_model <- prcomp(feature_matrix, scale=TRUE, center=TRUE)
ordist <- rowSums((feature_matrix - predict(pca_model)) ^ 2) ^ 0.5
dmodx_threshold <- quantile(ordist, 0.95)
outlier_flags <- ordist > dmodx_threshold
outlier_report <- data.frame(sample_id=rownames(feature_matrix), DModX=ordist, outlier=outlier_flags)

Evaluation signals

  • DModX scores are non-negative, non-zero for all samples, with a right-skewed distribution typical of distance metrics.
  • Outlier flags (TRUE/FALSE) are consistent with visual PCA score plots—flagged samples should appear distant from the main ellipse cloud.
  • Approximately 5% of samples are flagged at the 95th percentile threshold (or close to the user-specified limit), validating threshold calibration.
  • Joint inspection with Hotelling T-squared: samples flagged by DModX should largely differ from those flagged by T-squared alone, indicating complementary information (orthogonal vs. Mahalanobis distance).
  • Flagged samples correlate with known batch effects, instrument drift timestamps, or biological extremes (e.g., disease severity outliers) when metadata are available.

Limitations

  • DModX depends on PCA model quality; if the number of PCs is poorly chosen (too few or too many), threshold calibration and outlier detection sensitivity may degrade.
  • No guidance provided in the OUKS paper or README on automatic PC selection or sensitivity analysis for threshold tuning; practitioner must specify these parameters manually.
  • DModX is sensitive to the preprocessing method (normalization, imputation strategy); different Box-Cox implementations or missing-value fill methods will alter scores.
  • The metric assumes that legitimate samples cluster in a lower-dimensional subspace; highly heterogeneous biological cohorts (e.g., multiple disease subtypes with distinct metabolomes) may not satisfy this assumption, leading to high false-positive outlier flags.
  • Computational scalability and performance characteristics for very large datasets (>10,000 samples or >10,000 features) are not documented.

Evidence

  • [other] Compute DModX (distance to model in X-space) metric as the orthogonal distance of each sample from the principal component model subspace.: "Compute DModX (distance to model in X-space) metric as the orthogonal distance of each sample from the principal component model subspace."
  • [other] Define outlier thresholds for T-squared (e.g., critical value from F-distribution or 95th percentile) and DModX (95th percentile or user-specified limit).: "Define outlier thresholds for T-squared (e.g., critical value from F-distribution or 95th percentile) and DModX (95th percentile or user-specified limit)."
  • [other] Flag samples exceeding either threshold as outliers and generate per-sample outlier status (TRUE/FALSE) with associated scores.: "Flag samples exceeding either threshold as outliers and generate per-sample outlier status (TRUE/FALSE) with associated scores."
  • [readme] comprehensive nine step LC-MS untargeted metabolomic profiling data processing toolbox: "comprehensive nine step LC-MS untargeted metabolomic profiling data processing toolbox"

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.