Communitygithub.com

批量RNA-seq分析

端到端批量RNA-seq编排器——从原始FASTQ文件开始,经质量控制与修剪(FastQC、fastp/Trim Galore)、比对与定量(STAR、Salmon、featureCounts),构建基因级表达矩阵,然后进行差异表达分析(pydeseq2)、通路/GSEA富集分析(pathway-enrichment)并生成发表级图表(scientific-visualization)。适用于用户拥有批量RNA-seq测序读数或定量结果,并希望获得完整、可重复的差异表达工作流的情况。

批量RNA-seq分析 是什么?

该技能是一个全面的批量RNA-seq分析工作流编排器,专为需要端到端差异表达分析的研究人员设计。它自动连接从原始FASTQ读数到富集通路和可视化图表的完整流程,支持两条上游路径:通过nextflow技能运行的行业标准nf-core/rnaseq管道,以及基于独立工具的灵活路径。该技能特别强调“可辩护性”,包括可重复性、质量控制和统计严谨性。它无缝集成其他专业分析技能,如pydeseq2进行差异表达分析、pathway-enrichment进行通路富集分析,以及scientific-visualization生成发表级图表。该技能解决了整个工作流中的关键空白——从定量输出构建基因级计数矩阵,通过核心脚本build_counts_matrix.py处理不同定量工具的格式差异,并确保与下游分析技能的兼容性。它提供详细的设计和质量控制指导,帮助用户避免常见陷阱,如重复数不足、批次效应混淆和错误链式分析,确保分析结果的科学可信度。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/bulk-rnaseq

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

批量RNA-seq

概述

此技能编排一个完整的、可辩护的批量RNA-seq差异表达研究流程,从原始测序读数到富集通路和可视化图表。它是一个路由层,而非重新实现:大多数阶段本仓库中已有专用技能,此技能负责按正确顺序连接它们,填补一个关键空白(从原始读数到基因级计数矩阵),并强制执行决定最终结果可信度的设计决策和质量控制决策。

“可辩护的”意味着三个贯穿始终的原则:

  • 可重复性 — 固定管道/工具版本,尽可能使用容器,记录参数,设置固定随机种子。
  • 质量控制关卡 — 在定量前、中、后均进行检查并采取相应措施,而非跳过。
  • 统计严谨性 — 足够的生物学重复,符合生物学背景的实验设计,正确处理计数数据,并实施FDR控制的检验。

分析流程为:FastQC/修剪 → 对齐/定量(STAR/Salmon)→ 计数矩阵 → 差异表达(pydeseq2)→ 富集分析(pathway-enrichment)→ 图表生成。

何时使用此技能

当用户希望进行以下操作时使用此技能:

  • 从FASTQ文件(或一次测序运行)出发,获得差异表达基因和通路。
  • 运行或配置nf-core/rnaseq,或使用STAR、Salmon或featureCounts进行对齐/定量。
  • 将Salmon/STAR/featureCounts的输出转换为可供DESeq2/PyDESeq2使用的计数矩阵。
  • 在投入计算资源之前,设计或核查批量RNA-seq实验(重复数、批次、链特异性)。
  • 规划端到端RNA-seq分析,并决定要链接哪些工具和技能。

这是批量RNA-seq(样本为生物学标本)。单细胞/单核数据请使用scanpy;仅需差异表达统计分析请使用pydeseq2;仅需富集分析请使用pathway-enrichment。

流程概览

flowchart TD
    fastq["原始FASTQ + 样本表"] --> qc["FastQC + MultiQC"]
    qc --> trim["修剪: fastp / Trim Galore"]
    trim --> align["对齐 + 定量: STAR 和/或 Salmon"]
    align --> counts["基因级计数矩阵"]
    counts --> de["差异表达分析"]
    de --> enrich["通路 / GSEA 富集分析"]
    de --> fig["图表生成"]
    enrich --> fig
    nfcore["通过nextflow技能运行nf-core/rnaseq"] -.->|"路径A"| align
    manual["独立工具方案(此技能提供)"] -.->|"路径B"| align
    bridge["build_counts_matrix.py(此技能提供)"] -.-> counts
    pydeseq2skill["pydeseq2技能"] -.-> de
    pwskill["pathway-enrichment技能"] -.-> enrich
    vizskill["scientific-visualization技能"] -.-> fig

两条上游路径——任选其一

reads→counts阶段可通过两种方式运行。它们产生等价的基因计数;根据情境选择,然后坚持使用该路径。

使用路径A — nf-core/rnaseq 当…使用路径B — 独立工具 当…
你需要行业标准、经过审计、可引用的管道,只需一条命令你只有少量样本,并希望学习/检查每一步
样本量大,或计划扩展到HPC/云端没有Nextflow/容器可用,或环境受限
可重复性和完整MultiQC报告至关重要你需要管道未暴露的非标准步骤
→ 通过**nextflow** 技能驱动→ 遵循references/upstream-manual.md

当不确定时,优先选择路径A:nf-core/rnaseq已连接FastQC→修剪→STAR/Salmon→定量→tximport→MultiQC,并使用了经过审核的合理默认值,这是最可辩护的选择。路径B的存在是为了透明度和受限环境下的使用。

两条路径最终汇聚于基因级计数矩阵,之后的工作流完全相同。

环境配置

# 此技能的胶水代码(桥接 + 交接)— Python
uv pip install pytximport pandas

# 下游技能安装各自的依赖:
#   pydeseq2技能 -> uv pip install pydeseq2
#   pathway-enrichment技能 -> uv pip install gseapy gprofiler-official

# 路径A(nf-core):仅需Nextflow + 容器引擎——请参阅nextflow技能。

# 路径B(独立工具):通过bioconda安装。固定版本以确保可重复性。
conda create -n rnaseq -c bioconda -c conda-forge \
  fastqc fastp trim-galore "star=2.7.11b" "salmon=1.10.3" subread multiqc

记录你使用的确切版本(管道版本、工具版本、参考基因组+注释版本)——它们属于方法部分,并使分析可重复。

快速开始

路径A — nf-core/rnaseq(推荐)

# 0. 首先验证样本表(可提前捕获最常见的失败)
python scripts/validate_samplesheet.py --samplesheet samplesheet.csv

# 1. 使用附带的小型测试数据对环境进行冒烟测试
nextflow run nf-core/rnaseq -r 3.26.0 -profile test,docker --outdir test_results

# 2. 实际运行:固定版本,选择比对器,传入样本表和参考基因组
nextflow run nf-core/rnaseq -r 3.26.0 \
  -profile docker \
  --input samplesheet.csv \
  --genome GRCh38 \
  --aligner star_salmon \
  --outdir results \
  -resume

nf-core/rnaseq内部运行tximport,因此基因计数已合并——无需桥接脚本。直接使用results/star_salmon/salmon.merged.gene_counts_length_scaled.tsv进行差异表达分析。样本表格式、比对器选择和输出文件:references/upstream-nfcore.md。有关引擎/HPC/云端/容器详情,请使用**nextflow** 技能。

路径B — 独立STAR/Salmon(缩略版)

fastqc -o qc/ reads/*.fastq.gz                      # 1. 原始读数的QC
fastp -i s1_R1.fq.gz -I s1_R2.fq.gz \
      -o s1_R1.trim.fq.gz -O s1_R2.trim.fq.gz \
      --thread 4 -j s1.fastp.json                   # 2. 修剪接头/低质量碱基
salmon quant -i salmon_index -l A \
      -1 s1_R1.trim.fq.gz -2 s1_R2.trim.fq.gz \
      --gcBias --seqBias -p 8 -o quant/s1            # 3. 定量(每样本)

完整方案(FastQC、fastp/Trim Galore、STAR索引+对齐+--quantMode GeneCounts、Salmon诱饵感知索引、featureCounts、链特异性判断):references/upstream-manual.md。

计数矩阵→差异表达→富集分析(两条路径)

# 仅路径B:组装基因×样本计数矩阵 + PyDESeq2的元数据模板
python scripts/build_counts_matrix.py --from salmon \
  --quant-dir quant/ --tx2gene tx2gene.tsv --output-dir counts/

# 然后交接至(请参阅专门技能):
#   pydeseq2:           counts.csv + metadata.csv -> 差异表达表格(log2FC, padj, stat)
#   pathway-enrichment: 按`stat`排序(GSEA)或按padj+|LFC|筛选列表(ORA)
#   scientific-visualization / matplotlib:火山图、MA图、热图、PCA、富集气泡图

分阶段工作流

按从上到下的顺序执行。每个阶段注明了负责的技能或文件。不要跳过设计/质量控制阶段——它们正是批量RNA-seq研究最容易出问题的地方。

  1. 设计与样本表。 确认每组≥3个生物学重复,识别批次/混杂变量,选择比较组。构建样本表并使用scripts/validate_samplesheet.py验证。原理和规则:references/design-and-qc.md。
  2. 原始读数质量控制。 对每个文件运行FastQC;使用MultiQC汇总。检查每个碱基质量、接头含量、重复序列和过度代表序列。阈值:references/design-and-qc.md。
  3. 修剪。 移除接头和低质量尾部(通过fastp或Trim Galore)。重新运行FastQC确认。方案:references/upstream-manual.md(路径A自动完成此步骤)。
  4. 对齐/定量。 STAR(基因组对齐 + --quantMode GeneCounts)和/或Salmon(转录本准映射,诱饵感知)。确定链特异性——这一步容易出错,会悄无声息地减少一半计数。详情:references/upstream-manual.md;管道参数:references/upstream-nfcore.md。
  5. 构建计数矩阵。 将定量输出转换为基因×样本整数矩阵和元数据模板(scripts/build_counts_matrix.py)。估计计数和基因ID映射的细微差别在references/counts-and-handoff.md中。
  6. 差异表达→pydeseq2技能。 加载counts.csv + metadata.csv,设置设计公式(例如~batch + condition),拟合模型,进行FDR控制的检验。检查PCA和p值直方图作为质量控制。
  7. 富集分析→pathway-enrichment技能。 对于GSEA,按DESeq2的stat排序完整基因列表;对于ORA,传入阈值筛选后的列表(padj < 0.05,可选|log2FC| > 1)。先进行基因ID到符号的映射。
  8. 图表生成→scientific-visualization技能。 火山图、MA图、样本距离热图、PCA和富集气泡图,以及用于质量控制叙述的MultiQC报告。

计数到差异表达的桥接(核心粘合剂)

这是唯一一个没有上游/下游技能的阶段,因此由此技能负责。scripts/build_counts_matrix.py将定量输出转换为pydeseq2期望的格式:

  • Salmon (--from salmon):使用pytximport按样本聚合quant.sf,以counts_from_abundance="length_scaled_tpm"(基因级差异表达的正确选择)聚合到基因水平,需要tx2gene映射文件。
  • STAR (--from star):读取每个ReadsPerGene.out.tab文件,根据--strandedness(非链特异性/正向/反向)选择相应列。
  • featureCounts (--from featurecounts):解析合并的featureCounts矩阵。

它输出counts.csv(基因×样本,整数)和metadata_template.csv(每样本一行),供你填写。Salmon/RSEM的计数是估计值(非整数);它们会被四舍五入为整数,因为PyDESeq2需要整数计数——请参阅references/counts-and-handoff.md了解为什么这对length_scaled_tpm是可接受的,以及它与基于偏移量的DESeq2+tximport路径的区别。该参考文件也涵盖了Ensembl→符号映射(在富集分析前需要)以及PyDESeq2期望的具体格式。

常见陷阱

以下是导致大多数错误或不可重复的批量RNA-seq结果的原因:

  1. 重复数太少。 每组<3个生物学重复几乎无统计功效,且离散度估计不稳定。增加重复比加深测序更有效。
  2. 批次和条件混杂。 如果每个处理样本与对照样本在不同天/泳道处理,则效应无法恢复。随机化处理,并将已知批次纳入模型(~batch + condition)。见references/design-and-qc.md。
  3. 链特异性选择错误。 选择错误的STAR列或featureCounts的-s/Salmon文库类型会悄无声息地丢弃约一半读数。使用Salmon的-l A或推断链特异性,并检查分配读数的比例。
  4. 向DESeq2输入TPM/FPKM。 DESeq2需要原始(或长度缩放)计数,绝不能是TPM/FPKM/归一化值。桥接脚本会处理这一点。
  5. 非整数计数。 PyDESeq2要求整数;将Salmon的估计值四舍五入为整数(桥接脚本会处理)。
  6. 基因ID不匹配导致富集分析失败。 DESeq2的输出通常是Ensembl ID;Enrichr/MSigDB需要符号。在pathway-enrichment之前映射ID,否则“所有基因都不显著”。
  7. 跳过定量后的质量控制。 在信任差异表达结果之前,务必检查PCA和样本距离热图——它们能暴露标签交换、离群值和隐藏批次。
  8. 跨样本混合使用不同比对器。 所有样本使用相同的工具、版本、参考序列和参数进行定量。
  9. 未固定版本。 “最新”的管道/基因组会使结果不可重复;使用-r固定版本,并固定工具版本和基因组/注释版本。

与其他技能的集成

  • 上游执行: nextflow(运行nf-core/rnaseq,路径A;HPC/云端/容器)。
  • 参考数据/基因ID: gget(gget ref获取基因组+GTF,gget info/gget search用于ID映射),database-lookup(Ensembl/NCBI),biopython/pysam(FASTA/BAM处理)。
  • 差异表达: pydeseq2(此技能将计数矩阵传递给的差异表达分析引擎)。
  • 富集分析: pathway-enrichment(ORA + GSEA;其scripts/run_enrichment.py可直接读取DESeq2结果CSV)。
  • 图表生成与报告: scientific-visualization、matplotlib、seaborn;scientific-writing用于方法/结果叙述。
  • 相关但不同: scanpy(单细胞),statistical-analysis(多重检验深度)。

参考文件

当需要深入了解时,请阅读相关文件——每个都是独立的:

  • references/upstream-nfcore.md — 路径A:样本表格式、--aligner/--pseudo_aligner选择、关键参数、salmon.merged.gene_counts*.tsv输出文件、MultiQC以及传递给pydeseq2的内容。
  • references/upstream-manual.md — 路径B:FastQC、fastp/Trim Galore、STAR基因组索引+对齐+--quantMode GeneCounts、Salmon诱饵感知索引+quant、featureCounts以及如何确定链特异性。
  • references/counts-and-handoff.md — 将定量输出转换为PyDESeq2就绪的counts.csv/metadata.csv(pytximport、STAR列选择、featureCounts)、整数/估计计数细微差别、Ensembl→符号映射以及差异表达→富集分析的排序/筛选列表方案。
  • references/design-and-qc.md — 实验设计(重复、批次、混杂、设计公式)和质量控制指标解读(比对率、重复率、rRNA、复杂度、PCA/离群值)——可辩护管道的基础。

资源

引用科学智能体技能

此技能是K-Dense的“科学智能体技能”套件的一部分。如果它实质性地贡献了一篇手稿、报告、演示或代码发布,请将论文添加到参考文献或软件部分,并告知用户你已这样做:

Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent Skills: A Library of Procedural Knowledge for Research Agents. arXiv:26

…

[已截断,因翻译]

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

cobrapy

Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

相关技能