NMF 元程序分析

SKILLAI 工具
AI 工具 未标注权限 许可证不明确
安装这个技能

Chat2Research Al科研工作台:Use when decomposing a cell-state expression matrix into NMF gene meta-programs. Scans ranks per sample, filters robust programs, and merges them into consensus meta-programs (MPs).(Skill由Chat2Research Al科研工作台:https://icell.abiosciences.cn/?source=20e0489c 提供,登录平台可享免费算力和Token及更多分析组学Skills)

一句话选型结论

按资料字段整理

NMF 元程序分析是AI 工具类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类AI 工具 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_7ece4fea/nmf-metaprogram-analysis
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

AI 工具
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_7ece4fea仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791623245
正文体量16.3 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
组合多个 AI 能力

把写作、检索、总结串成一条流程。

搭工作流

把固定流程做成可重复调用的步骤。

做提示词与评测

整理提示词并对比输出效果。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在AI 工具场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
NMF 元程序分析当前 未标注权限 未标注 未标注 未标注 有
执行计划 只读 GitHub 仓库 151.5 万 Codex、Claude、Cursor 有
Playwright MCP 测试 浏览器控制 ClawHub 市场 136.5 万 OpenClaw 有
完成前的验证 未标注权限 GitHub 仓库 131.9 万 Codex、Claude、Cursor 有
子 Agent 驱动开发 只读 GitHub 仓库 131.2 万 Codex、Claude、Cursor 有
前端设计 执行命令 GitHub 仓库 125.6 万 Codex、Claude、Cursor 有

SKILL.md 全文

16.3 KB
模型实际读到的说明书原文,来自技能仓库

NMF Meta-Program (MP) Analysis

Overview

NMF meta-program analysis asks a different question from clustering. Clustering groups cells
into discrete states; NMF factorises a cell-state expression matrix V ≈ W·H into

  • W — a gene loading matrix (genes x rank): each column is one non-negative "program"
    (a set of genes that go up together), scored by contribution to the factor;
  • H — a cell loading matrix (rank x cells): how strongly each cell expresses each program.

Programs are reusable, partly overlapping axes of variation (cell cycle, stress, hypoxia,
interferon, lineage programs…), not exclusive clusters — a cell can score high on several.
Because a single sample's programs are noisy, the standard workflow (Tirosh-lab lineage,
Gavish et al., Nature 2023, doi:10.1038/s41586-023-06130-4 — 41 consensus MPs across
1,163 tumours, K = 4–9 per sample) is:

  1. run NMF per sample over a range of ranks, giving many candidate programs;
  2. keep only robust programs (recovered at several ranks / overlapping programs);
  3. cluster the surviving programs by their shared top genes (Jaccard/overlap) and merge
    each cluster into one meta-program (MP) = the genes most frequently shared inside it.

Upstream package: NMF (Gaujoux & Seoighe 2010) — <https://cran.r-project.org/package=NMF>.

Inputs

Input Notes
Seurat object .rds any Seurat v4/v5 object with a counts/data layer for the target assay; the script normalises and scales itself
target cell population --subset-col + --subset-value (e.g. sub == Neutrophils); omit to use all cells
sample / patient column --sample-col (default sample) — NMF is run per value of this column, and samples with &lt; --min-cells cells are dropped (default 30)
gene selection global FindVariableFeatures(method = &quot;vst&quot;, nfeatures = 2000) on the whole object, then the same HVG list is used to scale every sample, so programs are comparable
optional group column --group-col (e.g. group, response) → extra MP-score violin plot
optional embedding --reduction (default umap) → MP activity scatter plots

The reference run in this container: neutrophil.rds, 34,058 genes x 1,449 cells,
samples NP10-AMZ-2 (72 cells), NP11-DP-1 (68), NP12-AMZ-1 (1,309); meta.data columns
include sample, percent.mt, sub, group, response, and reductions pca, harmony, umap.

Steps

Reusable, fully command-line driven script: scripts/nmf_metaprogram.R.txt
(no hard-coded paths, no source() of external helper files — the palette and the
robust-program filter are inlined).

  1. Inspect the object first (column names are the #1 failure source):

r srt &lt;- readRDS(&quot;neutrophil.rds&quot;); print(colnames(srt@meta.data)) print(names(srt@reductions)); print(table(srt$sample))

  1. Run the pipeline:

bash Rscript scripts/nmf_metaprogram.R.txt \ --input-rds /path/to/neutrophil.rds \ --output-dir /path/to/out \ --subset-col sub --subset-value Neutrophils \ --sample-col sample --min-cells 30 \ --ranks 4:9 --nrun 10 --seed 123 --cores 8 \ --top-genes 50 --reduction umap --group-col group

The per-sample core (per sample: subset → NormalizeData → ScaleData(hvg) → clip → NMF):

r hvg &lt;- VariableFeatures(srt)[1:2000] # after FindVariableFeatures(method=&quot;vst&quot;) sub &lt;- NormalizeData(sub, normalization.method = &quot;LogNormalize&quot;, scale.factor = 10000) sub &lt;- ScaleData(sub, features = hvg, vars.to.regress = &quot;percent.mt&quot;) d &lt;- as.matrix(SeuratObject::LayerData(sub, &quot;scale.data&quot;)) d[!is.finite(d)] &lt;- 0; d[d &lt; 0] &lt;- 0 # NMF refuses negatives d &lt;- d[rowSums(d) &gt; 0, ] # NMF refuses all-zero rows (empty program) set.seed(123) fit &lt;- NMF::nmf(d, rank = 4:9, method = &quot;snmf/r&quot;, nrun = 10) # -&gt; NMF.rank object W &lt;- lapply(fit$fit, NMF::basis) # fit$fit[[&quot;4&quot;]] is NMFfitX1; W = genes x 4

  1. Programs → MPs (what the script does after the loop): top-50 genes per program
    (uppercased), robust filter, overlap matrix, hclust on 2*top - overlap, reorder columns,
    then a greedy expansion — start a cluster from the most-connected program, add programs with
    &gt;= --min-intersect-cluster shared genes, redefine the cluster gene set as the 50 most
    frequently shared genes (border ties broken by raw W scores), repeat while the best
    remaining program still has &gt; --min-group-size partners.

r nmf_programs &lt;- lapply(out1, function(x) apply(x, 2, function(y) toupper(names(sort(y, decreasing = TRUE))[1:50]))) sel &lt;- robust_nmf_programs(nmf_programs, intra_min = 35, intra_max = 10, inter_filter = TRUE, inter_min = 10) inter &lt;- crossprod(program_indicator) # == pairwise length(intersect(a, b)) hc &lt;- hclust(as.dist(2 * 50 - inter), method = &quot;average&quot;)

  1. Read the results (see Outputs) and, if too few/many MPs, relax or tighten the thresholds
    in proportion to --top-genes (see Pitfalls).

  2. Map MPs onto cells (optional, on by default): AddModuleScore with each MP gene set →
    Stat/mp_cell_scores.csv + per-MP UMAP pages + violin per --group-col.

Parameters

Param Meaning Default (= the value used by the source NMF.R)
--input-rds Seurat object required
--output-dir output root (Rdata/ Stat/ Img/ auto-created) ./NMF_metaprogram
--subset-col / --subset-value target cell population (multi-value: comma list) NULL (all cells)
--sample-col per-sample split column sample
--min-cells drop samples with fewer cells 30
--nfeatures HVGs for scaling 2000
--ranks NMF rank range (4:9 or 4,5,6,7,8,9) 4:9
--method NMF algorithm key: snmf/r, snmf/l, brunet, lee, nsNMF, … snmf/r
--nrun restarts per rank 10
--seed RNG seed (set.seed before nmf) 123
--seeding NMF start: random, nndsvd, ica, none random (NMF default)
--cores &gt;1 → doParallel backend (P&lt;n&gt; + .pbackend=&quot;par&quot;) 1
--top-genes genes per program / per MP 50
--nmp max MPs to output (0 = determined by thresholds) 0
--intra-min min 2nd-largest overlap with a same-sample program 35
--intra-max max overlap allowed between kept same-sample programs 10
--inter-filter / --inter-min require overlap with programs from other samples TRUE / 10
--min-intersect-initial overlap needed to start an MP 15
--min-intersect-cluster overlap needed to join an MP 10
--min-group-size min programs to form an MP 3
--regress ScaleData(vars.to.regress=); none disables percent.mt
--reduction / --score-umap / --plot-mps / --group-col MP scoring & plotting umap / TRUE / 6 / NULL
--max-cells-per-sample subsample per sample (speed/memory) 0 (all)
--jac-max Jaccard heat-map colour ceiling (%) 25

Outputs

&lt;out&gt;/Rdata/&lt;sample&gt;_SP_NMF.RData          # NMF.rank object per sample (object name: NMFs_per_sample)
&lt;out&gt;/Rdata/&lt;prefix&gt;.Genes.nmf.All.RData   # out1: named list of W matrices, genes x programs
&lt;out&gt;/Rdata/&lt;prefix&gt;.MP_list.RData         # MP_list (MP -&gt; genes), Cluster_list (MP -&gt; programs), params
&lt;out&gt;/Stat/&lt;prefix&gt;.MPs.csv                # MP x top genes (wide, NA-padded)   &lt;- the deliverable table
&lt;out&gt;/Stat/mp_gene_list.csv                # long: MP, rank_in_MP, gene
&lt;out&gt;/Stat/program_cluster_membership.csv  # MP, program (&lt;sample&gt;_rank&lt;k&gt;_&lt;i&gt;), sample
&lt;out&gt;/Stat/jaccard_intersect_matrix.csv    # programme x program shared-gene counts (ordered by cluster)
&lt;out&gt;/Stat/jaccard_long.csv                # long + jaccard_pct = 100*x/(2*top - x)
&lt;out&gt;/Stat/rank_measures.csv               # per sample x rank: evar, cophenetic, residuals, silhouette.consensus…
&lt;out&gt;/Stat/mp_sample_composition.csv       # how many programs of each sample build each MP (confounding check)
&lt;out&gt;/Stat/mp_cell_scores.csv              # cell, sample, [subset/group cols], MP scores (AddModuleScore)
&lt;out&gt;/Stat/nmf_metaprogram.log, sessionInfo.txt
&lt;out&gt;/Img/&lt;prefix&gt;_cells-2MetaProgram.pdf  # program similarity heat map (magma palette, Jaccard %)
&lt;out&gt;/Img/&lt;prefix&gt;_rank_survey.pdf         # cophenetic / evar / silhouette.consensus vs rank
&lt;out&gt;/Img/&lt;prefix&gt;_MP_sample_heatmap.pdf   # MP x sample program counts
&lt;out&gt;/Img/&lt;prefix&gt;_MP_umap.pdf             # one page per MP: cells coloured by MP score
&lt;out&gt;/Img/&lt;prefix&gt;_MP_score_by_&lt;group&gt;.pdf # violin of MP score per group (when --group-col given)

Structure of the per-sample object (this is the layout the original NP*_SP_NMF.RData files have):

load(&quot;&lt;out&gt;/Rdata/NP10-AMZ-2_SP_NMF.RData&quot;)        # NMFs_per_sample
class(NMFs_per_sample)          # &quot;NMF.rank&quot;  (from nmf(rank = c(4,...))) ; names: measures, consensus, fit
NMFs_per_sample$measures        # matrix, one row per rank: evar, cophenetic, residuals, silhouette.consensus, nrun…
NMFs_per_sample$fit$`4`         # NMFfitX1 (consensus of the 10 runs); slots: fit(NMF), method, seed, rng, nrun
W &lt;- NMFs_per_sample$fit$`4`@fit@W   # == NMF::basis(fit), genes x 4, rownames = genes, non-negative
H &lt;- NMFs_per_sample$fit$`4`@fit@H   # == NMF::coef(fit),  4 x cells

out1 (from &lt;prefix&gt;.Genes.nmf.All.RData) is the concatenation of all bases per sample with
column names &lt;sample&gt;_rank&lt;k&gt;_&lt;i&gt; (e.g. NP10-AMZ-2_rank4_1), 39 columns for ranks 4:9.
Those column names are what the merge step parses (sub(&quot;_rank.*$&quot;, &quot;&quot;) → sample).

Pitfalls

  • Randomness and seed. nrun &gt; 1 runs multiple random starts, so programs shift with the RNG.
    Always fix --seed and record it (the run config is saved into &lt;prefix&gt;.MP_list.RData$params).
    Two runs that differ only by seed produce program sets that are highly similar but not identical;
    if you compare groups/conditions, use the same seed and the same --ranks.
  • Rank: the scan is for candidate generation, not model selection. The workflow concatenates the
    programs of every rank and merges them, so a bigger rank gives more (finer) candidates rather
    than "the right K". Use Stat/rank_measures.csv / rank_survey.pdf as diagnostics: evar
    increases monotonically with rank (here 0.139 → 0.240 for ranks 4 → 9 — useless for selection),
    the NMF vignette's rule of thumb is cophenetic &gt;= 0.9 for a reproducible rank (this dataset scores
    0.987–0.995 at every rank, so it does not discriminate here), and silhouette.consensus peaks at
    the most reproducible rank (rank 7, 0.867, in the reference run). Also remember the overlap
    thresholds are counts of shared genes, so larger ranks need proportionally larger thresholds.
  • --top-genes and the overlap thresholds are coupled. 35 / 15 / 10 were tuned for
    --top-genes 50 on a multi-sample dataset. Lowering --top-genes to 20 while keeping them makes
    an MP impossible to form (max possible overlap is 20) — the script then falls back to
    same-sample-only filtering and warns, and may return 0 MPs. Scale the thresholds with --top-genes.
  • Sample/patient confounding (most common scientific error). Every program carries its sample of
    origin, and a sample with 10x more cells contributes 10x more programs. Always check
    mp_sample_composition.csv: an MP built exclusively from one sample is sample-specific, not a
    consensus program. Long-tail sample sizes (e.g. 72 vs 1,309 cells) can be equalised with
    --max-cells-per-sample.
  • Batch regression eats the signal. --regress percent.mt (the source default) removes
    mitochondrial-content-driven covariance; regression is per sample, and regressing out too many
    covariates flattens the programs. Use --regress none to keep raw scaled expression.
  • Scaling + clipping = "up-regulation only". After z-scoring per gene, negative values are set to
    0, so a program describes genes above the sample mean; a gene below the mean contributes nothing.
    Genes with constant expression in a sample become all-zero rows and are dropped — the reference run
    keeps 1,221 of the 2,000 HVGs for the 72-cell sample. That is expected, not a bug.
  • nmf() compatibility traps (all verified in this container, NMF 0.28):
    sparse dgCMatrix is rejected (no inherited method for signature x = &quot;dgCMatrix&quot;) → always
    as.matrix(); a matrix with negatives aborts the fit (input matrix x contains some negative entries); all-zero rows/columns yield degenerate programs.
  • Seurat v5 API traps. VariableFeatures(srt, selection.method = &quot;vst&quot;) is defunct in
    SeuratObject >= 5.0.0 (the original script was written against an older version) → call
    FindVariableFeatures(...) then VariableFeatures(srt)[1:n]. Read layers with
    SeuratObject::LayerData(obj, &quot;scale.data&quot;), not @scale.data. A stale scale.data layer inherited
    from the input object triggers Different features in new layer data than already exists for scale.data; the script drops it before re-scaling.
  • AddModuleScore can fail on small matrices: control genes are sampled without replacement inside
    expression bins, so ctrl = 100, nbin = 24 may be impossible when few genes are available; the script
    retries with decreasing ctrl/nbin. MP gene sets smaller than 5 matched genes are skipped (usually a
    species / gene-symbol naming mismatch, e.g. mouse Xkr4 vs human XKR4).
  • The MP table is uppercased. Genes are upper-cased before comparing programs, so MPs.csv contains
    uppercase symbols (HES4, ISG15); map back with toupper(rownames(obj)) when scoring or plotting.
  • Cost. length(ranks) * nrun NMF fits per sample, each on genes x cells. In the reference run
    the recorded per-rank cpu.all for the 72-cell sample (rank 4:9, nrun 10) sums to ~198 s
    (~3.3 min), and the 1,309-cell sample is far heavier — which is why the source's
    NP12-AMZ-1_SP_NMF.RData is 167 MB, ~20x the 72-cell object. Use --cores for the restarts and
    --max-cells-per-sample when a sample is much larger than the others.

Environment

  • Interpreter used here: /opt/conda/bin/Rscript (R 4.5.3); libraries
    /opt/user_R_libs, /opt/public_R_libs, /opt/conda/lib/R/library.
  • Installed and verified: NMF 0.28, Seurat 5.5.1, SeuratObject 5.4.0,
    SingleCellExperiment 1.32.0, ComplexHeatmap 2.26.1, tidyverse 2.0.0, ggplot2 4.0.3,
    reshape2 1.4.5, viridis 0.6.5, RColorBrewer 1.1.3, matrixStats 1.5.0, AnnotationDbi 1.72.0,
    future 1.75.0, doParallel 1.0.17, ggsci 5.2.0, tidydr 0.0.6.
  • Not installed: doFuture — future::plan() does not parallelise NMF runs unless the foreach
    backend is registered and nmf(.pbackend = NULL) is used; the script instead uses NMF's own
    doParallel backend (--cores, .options = &quot;P&lt;cores&gt;&quot;).
  • The original analysis ran in a Singularity/Apptainer base image with conda activate R.4.4.3
    (per that project's README); the two helper files it source()d
    (custom_magma.R, robust_nmf_programs.R) are inlined in this script.

> Packaging note. Scripts and tables in this skill carry a .txt suffix on their
> original extension (e.g. .R.txt, .tsv.txt) because the SkillHub upload allowlist
> does not accept .R or .tsv. This is cosmetic: Rscript is extension-agnostic, so
> Rscript scripts/&lt;name&gt;.R.txt ... behaves exactly like .R, and tab-separated data
> parses identically from .tsv.txt. Keep the suffix when repackaging.

常见问题

5 问
答案由本站依据条目字段整理
NMF 元程序分析怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_7ece4fea/nmf-metaprogram-analysis。安装方式为未标注。装完刷新技能列表或重开客户端。

NMF 元程序分析支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

NMF 元程序分析权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

NMF 元程序分析收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

NMF 元程序分析用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。