/lucid-coder:mofafrom lucid-coder
Multi-omics factor analysis with MOFA2 (Python mofapy2) on per-view sample tables (pseudobulk RNA, ADT, Olink, chromVAR TF scores): a seeded CPU fit with a fixed number of factors, variance explained per factor and view, factor scores, feature weights, factor-metadata tests, a model file, figures, a report and a reproducibility bundle. Fire on "run MOFA", "MOFA2 on RNA plus protein", "multi-omics factors", "integrate views with factor analysis", "which factor separates disease", "variance explained per view". Do NOT fire for single-view PCA or NMF, cell-level integration (scVI, totalVI, WNN, Harmony), MEFISTO or other covariate-smoothed models, mofaflex, or for regression of factors on several covariates at once.
Ships in lucid-coder. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
You are the dispatcher for mofa. The script does the analysis; you collect its arguments, run it, and explain its outputs.
Run scripts/mofa.py. Never re-implement the model, change a threshold, or
pick a value the user has not given. If a required argument is unknown, ask
the user (these are grill questions), or run --demo only when the user asks
for a demo.
Then read result.json and relay chat_summary_lines and preferred_artifacts.
If the script prints ERROR: ... and exits 2, tell the user the message and the
argument it names. Do not work around it.
Fire this skill when the user says any of:
Do NOT fire when:
factors.tsv).Environment: pixi feature mofa (pixi install -e mofa, from templates/pixi.toml).
| Input | Format | Required content | Example |
|---|---|---|---|
--view name=path | TSV, wide, repeated | first column sample ID; one numeric column per feature; empty or NA is missing | examples/demo_rna.tsv |
--metadata | TSV | column sample, the --group-col, every --assoc-cols column (and --donor-col if given); only the --assoc-cols columns are tested | examples/demo_meta.tsv |
Feature names must be unique across views (prefix them, rna_CD4). Views are
joined on sample IDs: skillkit.check_compatible stops the run when no sample
is in every view, and result.json reports n_shared_ids (adopted 2026-10-28). IDs are
read as text, so 01 stays 01. Gaussian views should be normalised and on a
log-like scale; the script does not transform them.
Ask these through the analysis contract: ${CLAUDE_PLUGIN_ROOT}/skills/lucid-coder/references/contracts.md.
Each row is a grill question. Ask the user; never fill one in.
| Argument | Grill question | Demo-only value |
|---|---|---|
--context | Species, tissue or cell type, condition and dataset? It opens the report and the chat summary. | synthetic demo: 60 samples, healthy vs disease, no real tissue |
--view | Which views, each as name=path? (repeat the flag) | rna, adt, tf from examples/ |
--metadata | Which TSV holds one row per sample? | examples/demo_meta.tsv |
--group-col | Which metadata column holds the groups to colour the plots by? It is tested only when it is also in --assoc-cols. | group |
--assoc-cols | Which metadata columns (comma-separated) are tested against the factors? This list is the Benjamini-Hochberg family: adding a column adds tests and raises every padj. No default; never "all columns". | group,age |
--donor-col (optional) | Which metadata column names the donor? Give it when a donor has several samples: factor scores are averaged per donor before the tests, and every --assoc-cols column must be constant within a donor. Absent means one row per sample (use only when each donor has one sample). | absent |
--likelihoods | Per view, gaussian (continuous), bernoulli (0/1) or poisson (counts)? As name=lik,... | all gaussian |
--factors | How many factors to train (>= 2)? | 6 |
--scale-views | Scale each view to unit variance (yes), so large views do not dominate, or keep raw scales (no)? | yes |
--convergence | ELBO tolerance: fast, medium or slow? | fast |
--min-var-explained | Which R² (%) in a view counts as a factor explaining it? | 5 |
--n-top-features | How many top weights per view go in each weight chart? | 10 |
--seed | Which seed fixes the initialisation and the box jitter? | 0 |
--reference | Which genome build and annotation release name the gene-level features (GRCh38, GENCODE 44)? Pass none when no view is gene-level. | synthetic demo, no genome build |
--outdir | Which new directory gets the outputs? It must not exist. | given by the user |
The last column is demo-only, not defaults. --demo alone pins all of them;
beside --demo only --outdir may be given.
--reference is required because the usual MOFA run has a gene-level RNA
view, and a gene name means nothing without its annotation release.
python scripts/mofa.py \
--context "human PBMC pseudobulk, RNA + ADT + Olink, healthy vs SLE, cohort X" \
--view rna=results/pb/rna_scaled.tsv --view adt=results/pb/adt.tsv \
--view olink=results/olink/npx.tsv \
--metadata results/meta/samples.tsv --group-col status \
--assoc-cols status,age,batch --donor-col donor \
--likelihoods rna=gaussian,adt=gaussian,olink=gaussian \
--factors 6 --scale-views yes --convergence slow \
--min-var-explained 2 --n-top-features 10 --seed 1 \
--reference 'GRCh38, GENCODE 44' \
--outdir results/2026-10-27_mofa
# Demo (only when the user asks for one)
python scripts/mofa.py --demo --outdir demo_out
--view name=path pairs, one likelihood per
view.skillkit.check_unique refuses a
repeated feature name or sample ID within a view (read from the raw header,
before pandas renames a repeat); a feature name in two views is refused too.check_unique refuses a repeated metadata sample; a modelled sample
absent from the metadata or without a group is refused. Metadata samples in
no view are left out and counted per group (dropped_per_group).
MOFA fits no design, so there is no design-rank check, and it joins no
resource (gene sets, network), so there is no n_matched count.entry_point: views, samples and features sorted
first, because the seeded initialisation maps onto input order;
set_data_options(scale_views=), set_model_options(factors=),
set_train_options(convergence_mode=, seed=, dropR2=None, gpu_mode=False).
BLAS threads are pinned to 1. save() writes data/model.hdf5, with
factors sorted by variance explained.>= --min-var-explained; it is active when it explains at least one view.
No factor is dropped.--assoc-cols column:
Spearman for a numeric column, Kruskal-Wallis otherwise; BH across all
factor-covariate tests, so the --assoc-cols list is the BH family (the
captions and summary say so). With --donor-col and a donor of several
samples, factor scores are averaged per donor first (a column that varies
within a donor stops the run before training: varies_within_donor), and
n counts donors; result.json has assoc_unit (sample or donor). The
summary line names the test actually used for --group-col, or says the
group was not tested (not in --assoc-cols, or no testable p-value).variance_explained.tsv: factor, view, r2 (%), explains, active; sorted by
factor number, then view.factors.tsv: sample, Factor1..K; sorted by sample.weights.tsv: view, feature, factor, weight (unscaled); sorted by view,
feature, factor number.factor_vs_metadata.tsv: factor, covariate, n, test (spearman or
kruskal-wallis), statistic (rho or H), pvalue, padj (BH over all rows with
a p-value, one row per --assoc-cols column and factor); sorted by factor number, then covariate.Weight and box figures exist for active factors only; the demo draws three of each.
outdir/
├── report.md # params, summary, figures with captions
├── result.json # context, n_samples, views, n_factors, n_active, active_factors, r2_total, device, threads, dropped_per_group, n_shared_ids, assoc_unit, assoc_n_tests, params, seed, reference, chat_summary_lines, preferred_artifacts
├── tables/
│ ├── variance_explained.tsv
│ ├── factors.tsv
│ ├── weights.tsv
│ └── factor_vs_metadata.tsv
├── data/
│ └── model.hdf5 # mofapy2 model; load_model() in MOFA2 reads it
├── figures/
│ ├── variance_explained.pdf
│ ├── variance_explained.png
│ ├── variance_explained.csv
│ ├── factor1_vs_factor2.pdf
│ ├── factor1_vs_factor2.png
│ ├── factor1_vs_factor2.csv
│ ├── weights_Factor1.pdf
│ ├── weights_Factor1.png
│ ├── weights_Factor1.csv
│ ├── weights_Factor2.pdf
│ ├── weights_Factor2.png
│ ├── weights_Factor2.csv
│ ├── weights_Factor3.pdf
│ ├── weights_Factor3.png
│ ├── weights_Factor3.csv
│ ├── box_Factor1.pdf
│ ├── box_Factor1.png
│ ├── box_Factor1.csv
│ ├── box_Factor2.pdf
│ ├── box_Factor2.png
│ ├── box_Factor2.csv
│ ├── box_Factor3.pdf
│ ├── box_Factor3.png
│ └── box_Factor3.csv
└── reproducibility/
├── commands.sh # argv as run, and the resolved command with every argument
├── environment.txt # Python and package versions, device, thread pins
└── checksums.sha256 # tables and figure PDFs; sha256sum -c from outdir
data/model.hdf5 is not checksummed: HDF5 bytes are not stable.
--min-var-explained (MOFA2's
drop_factor_threshold). Do not. Training keeps all --factors; the table
flags them, and a dropped factor cannot be checked later.factor_vs_metadata.tsv, and remember the sign of a factor is arbitrary
(demo: disease scores lower on Factor1).--factors or the seed until a factor
separates the groups. Do not. Both are fixed before the run; report what the
fit gives.gaussian. Do not. Normalise and
log first, or give poisson; ask the user which.factors.tsv.claims.strength).factor_vs_metadata.tsv padj is.
A factor with high R² can tie to no covariate.--reference from the gene names. Do not.
Ask; pass none only when no view is gene-level.--demo only when the user asked for a demo.mofapy2 seeds numpy with --seed when it initialises the model, and the script
sorts views, samples and features first, so row and column order of the input
do not change the fit (a test shuffles one view). BLAS threads are pinned to 1
(OMP_NUM_THREADS, OPENBLAS_NUM_THREADS, MKL_NUM_THREADS) and
gpu_mode=False; both are recorded in environment.txt and result.json.
Reruns here were bit-identical, so the rerun test compares checksums. Another
BLAS build may move R² in the second decimal; the golden R² test allows ±0.5
percentage points for that.
Not arguments: the script sets these, and reproducibility/environment.txt
records the package versions. A change is a maintainer edit, not a user choice.
set_model_options(factors = --factors) with the package
defaults for the rest (spikeslab_weights = True, ard_weights = True,
spikeslab_factors = False, ard_factors = False); set_train_options with
convergence_mode = --convergence, dropR2 = None, gpu_mode = False, default
iter = 1000.--assoc-cols family.Corpus sources, ClawBio mechanisms, tests, citations and the plot spec are in references/maintainer.md. The agent running the script does not need them.
examples/demo_adt.tsv (opens in a new tab)examples/demo_meta.tsv (opens in a new tab)examples/demo_rna.tsv (opens in a new tab)examples/demo_tf.tsv (opens in a new tab)examples/make_demo.py (opens in a new tab)references/maintainer.md (opens in a new tab)scripts/mofa.py (opens in a new tab)scripts/palettes.py (opens in a new tab)scripts/plots.py (opens in a new tab)scripts/skillkit.py (opens in a new tab)scripts/theme.py (opens in a new tab)tests/test_mofa.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub mdmanurung/lucid-coder --plugin lucid-coder27 skills in this plugin
/alignInstall the lucid-coder house-style configs into this repository, one file at a time, after showing each diff and asking. Use when the user says "align this repo", "install the house style configs", "set up air/ruff/lintr", or "add the palette file"./cccLigand-receptor cell-cell communication between cell types from a log-normalised single-cell h5ad with LIANA+ rank_aggregate (CellPhoneDB, Connectome, log2FC, NATMI, SingleCellSignalR, or a subset), a bundled or exported ligand-receptor resource TSV, a fixed pass rule on magnitude and specificity ranks, a source x target count heatmap, an LR dot plot, a report and a reproducibility bundle. Optional per-sample runs. Fire on "cell-cell communication", "ligand-receptor analysis", "which cell types talk to which", "LIANA", "CellPhoneDB", "rank_aggregate", "CCC between clusters". Do NOT fire for spatial CCC (bivariate, MISTy), for factorising CCC across many samples (Tensor-Cell2cell, MOFAtalk), for DE-driven CCC between conditions, for non-human data without a translated resource, or for raw counts./compositionCell-type composition and differential abundance with crumblr: counts cells per sample and label (from a cell-level h5ad or a counts TSV), drops rare labels, runs crumblr's precision-weighted CLR and variancePartition dream (fixed and random effects, e.g. (1|donor)), and writes tables, a stacked composition bar, per-label proportion boxes, an effect forest, a report and a reproducibility bundle. Fire on "cell-type composition", "differential abundance of cell types", "do cell-type proportions change", "crumblr", "CLR of cell frequencies", "which populations expand after stimulation". Do NOT fire for neighbourhood-level DA on a KNN graph (Milo), gene expression DE (pseudobulk or cell-level), scCODA / Bayesian composition models, or a plain Wilcoxon on frequencies (group-tests).