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.
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.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
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.
## 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
- Version Compatibility
- Algorithmic Taxonomy
- 4-Way Decomposition Framework
- Decision Tree by Scenario
- Sequential Ignorability and Why It Always Needs Sensitivity
- Sequential ignorability untestable
- Methods-Section Defense of Sequential Ignorability
- Exposure-induced M-Y confounder
- HIMA covariate or data.pheno error
- HIMA mediator-type vs outcome-type mismatch
- Bootstrap iterations too low
- Two-step MR instrument independence
- Difference vs product of coefficients diverge for non-linear outcomes
- Required Reporting for Publication
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.
