Agent skill

bio-causal-genomics-mediation-analysis

Decompose total effects into direct and indirect paths through mediators using mediation, CMAverse 4-way, HIMA/HIMA2 high-dimensional, BAMA, two-step / MVMR mediation, or double-ML medDML. Use when testing whether a molecular phenotype (expression, methylation, protein) mediates a treatment-outcome relationship, decomposing exposure-mediator interaction via VanderWeele 4-way, screening high-dimensional EWAS mediators, or running MR-based mediation when sequential ignorability is implausible.

BioTender-maxgithub.com/BioTender-maxGitHub ↗
claude-codeNOASSERTION
Install
npx skills add BioTender-max/awesome-bio-agent-skills --skill mediation-analysis --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 6
SKILL.md size: 33 KB
Bundled scripts: none
Path: skills/bioskills/mediation-analysis/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 135
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Decompose the total effect of a treatment on an outcome into direct and indirect paths through one or more mediators, with explicit handling of exposure-mediator interaction and high-dimensional mediator screening, using multiple methods (mediation, CMAverse 4-way, HIMA/HIMA2, BAMA, two-step / MVMR mediation, or double-ML medDML).

How it works

Outlines concrete R-based workflows and concrete function calls for various scenarios:

  • For observational, single mediator, no E-M interaction with continuous outcome: use mediation::mediate(med_model, out_model, treat='X', mediator='M', boot=TRUE, sims=5000).
  • For 4-way decomposition with exposure-mediator interaction: CMAverse::cmest(...EMint=TRUE, estimation='paramfunc', inference='bootstrap', nboot=1000).
  • For high-dimensional EWAS mediators: HIMA::hima(Y ~ X + covariates, data.pheno, data.M, mediator.type='gaussian', penalty='DBlasso').
  • For MR-based mediation: two-step TwoSampleMR with independent instruments OR MVMR::ivw_mvmr for joint direct effect.
  • For doubly-robust estimation: causalweight::medDML(y, d, m, x). The skill emphasizes that sequential ignorability is untestable and requires sensitivity analyses (medsens or EValue). It provides a workflow to compute and present sensitivity metrics alongside mediation results.

When to use it

Triggered by scenarios where mediation pathways are tested, including:

  • Observational contexts with one or more mediators and potential E-M interaction, or
  • High-dimensional mediator screening, or
  • MR-based mediation where sequential ignorability is questionable, or
  • Longitudinal or g-formula analyses where advanced frameworks are appropriate.

What it can touch

Mentions use of specific R packages and functions:

  • mediation, CMAverse, HIMA, TwoSampleMR, MVMR, causalweight, EValue, gfoRmula, and related tools.
  • It instructs to ensure proper versions and parameter settings, such as pinning HIMA>=2.3.0 and using the correct mediator.type for HIMA, and to run sensitivity analyses with medsens or EValue.

Caveats

Highlights key limitations and risks:

  • Sequential ignorability is untestable; always report sensitivity metrics (rho via medsens and mediational E-value).
  • For high-dimensional mediators, ensure appropriate sample size and avoid overfitting; bootstrap iterations should be sufficient (sims=1000 minimum, 5000-10000 for publication) to stabilize CIs.
  • For MR-based mediation, ensure instrument independence (Steiger filter) and beware overlapping instruments across steps.
  • Non-linear outcomes may cause divergence between difference and product methods; use the counterfactual ACME from mediation::mediate() for non-linear outcomes.

Summary: The skill prescribes concrete tool usage and parameterization across mediation frameworks, with explicit notes on data preparation, sensitivity analyses, and scenario-specific pipelines for robust causal mediation analyses.

From the SKILL.md

## Version Compatibility Reference examples tested with: R 4.3+, mediation 4.5.0+, CMAverse 0.1.0+ (GitHub `BS1125/CMAverse`), HIMA >= 2.3.0 (CRAN), bama 1.3+, causalweight 1.0.5+ (medDML), MVMR 0.4+, TwoSampleMR 0.6+, EValue 4.1+, gesttools 1.3+, ipw 1.0.11+. Before using code patterns, verify installed versions match. If versions differ: - R: `packageVersion('<pkg>')` then `?function_name` to verify parameters - HIMA must be pinned at `>= 2.3.0` for the code patterns below; the formula interface `hima(formula, data.pheno, data.M, mediator.type, penalty, ...)` was introduced in 2.3.0. Users on HIMA 2.2.x must instead call `hima_classic()` with positional arguments (`X=`, `Y=`, `M=`, `COV.XM=`, `Y.family=`) and lose the formula interface; HIMA 2.2.x is NOT API-compatible with the examples here. - `hima_classic()` is still available in 2.3+ for the original Zhang 2016 SIS+MCP pipeline; use it only to reproduce 2016-2021 papers. If code throws an error, introspect the installed package (`?hima`, `args(cmest)`) and adapt the example to match the actual API rather than retrying. # Mediation Analysis **"Does expression of GENE_X mediate the SNP-to-disease effect?"** -> Decompose the tot

What's inside
Steps it walks through
  1. Version Compatibility
  2. Algorithmic Taxonomy
  3. 4-Way Decomposition Framework
  4. Decision Tree by Scenario
  5. Sequential Ignorability and Why It Always Needs Sensitivity
  6. Sequential ignorability untestable
  7. Methods-Section Defense of Sequential Ignorability
  8. Exposure-induced M-Y confounder
  9. HIMA covariate or data.pheno error
  10. HIMA mediator-type vs outcome-type mismatch
  11. Bootstrap iterations too low
  12. Two-step MR instrument independence
  13. Difference vs product of coefficients diverge for non-linear outcomes
  14. Required Reporting for Publication
Ships with 5 files
  • examples/cmaverse_4way.R
  • examples/eqtl_mediation.R
  • examples/mvmr_mediation.R
  • examples/sensitivity_analysis.R
  • usage-guide.md
More from awesome-bio-agent-skills
All skills →
About this skill
What does the bio-causal-genomics-mediation-analysis skill do?

Decompose total effects into direct and indirect paths through mediators using mediation, CMAverse 4-way, HIMA/HIMA2 high-dimensional, BAMA, two-step / MVMR mediation, or double-ML medDML. Use when testing whether a molecular phenotype (expression, methylation, protein) mediates a treatment-outcome relationship, decomposing exposure-mediator interaction via VanderWeele 4-way, screening high-dimensional EWAS mediators, or running MR-based mediation when sequential ignorability is implausible.

How do I install it?

Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill mediation-analysis --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going