bio-expression-matrix-normalization
БесплатноЗапускает вложенные скриптыНе проверенNormalize and transform RNA-seq count matrices for differential expression, visualization, and clustering. Covers between-sample (TMM, RLE, upper quartile)…
от gabrielmoreira★ 23 звезды на GitHubОб этом скилле
Version Compatibility
Reference examples tested with: DESeq2 1.42+, edgeR 4.0+, pandas 2.2+, numpy 1.26+, scanpy 1.10+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - R:
packageVersion('<pkg>')then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Expression Matrix Normalization
Why Normalization Matters: Composition Bias
Simple library-size normalization (dividing by total counts) fails because RNA populations differ between samples. If a treatment massively upregulates a few genes, those genes consume a disproportionate share of sequencing reads, making every other gene appear downregulated even if unchanged. This composition bias is not a theoretical edge case -- it occurs routinely in stress responses, viral infection, and knockout experiments.
All robust normalization methods (TMM, RLE/DESeq2, upper quartile) address composition bias by estimating scaling factors from the majority of non-differentially-expressed genes.
Normalization Decision Table
| Task | Method | Tool | Input |
|---|---|---|---|
| DE analysis (DESeq2) | RLE / median-of-ratios | DESeq() handles internally |
Raw integer counts |
| DE analysis (edgeR) | TMM | calcNormFactors() |
Raw integer counts |
| DE analysis (limma-voom) | TMM + voom | calcNormFactors() then voom() |
Raw integer counts |
| PCA, heatmaps, clustering | VST or rlog | vst(dds) or rlog(dds) |
DESeqDataSet |
| PCA/clustering (edgeR/limma) | log-CPM | edgeR::cpm(y, log=TRUE) |
DGEList |
| WGCNA | VST or log-CPM | vst(dds, blind=FALSE) |
DESeqDataSet |
| GSVA / ssGSEA | log2(TPM+1) or VST | Precomputed | TPM or DESeqDataSet |
| Machine learning / biomarkers | VST | vst(dds, blind=FALSE) |
DESeqDataSet |
| Reporting expression levels | TPM (within-sample) | Quantification tool output | N/A |
| Cross-sample comparison | DESeq2 normalized counts | counts(dds, normalized=TRUE) |
DESeqDataSet |
| Single-cell RNA-seq | scran deconvolution | scran::computeSumFactors() |
SingleCellExperiment |
Critical rule: DE tools (DESeq2, edgeR, limma-voom) normalize internally from raw counts. Never provide pre-normalized data to these tools.
Between-Sample Normalization
RLE / Median of Ratios (DESeq2)
Goal: Estimate per-sample size factors that correct for library size and composition bias.
Approach: Compute a pseudo-reference sample (geometric mean per gene across all samples), then take the median of per-gene ratios between each sample and the reference. The median is robust to the minority of DE genes.
library(DESeq2)
dds <- DESeqDataSetFromMatrix(countData=counts, colData=coldata, design=~condition)
dds <- estimateSizeFactors(dds)
sizeFactors(dds)
# Normalized counts for export/visualization
norm_counts <- counts(dds, normalized=TRUE)
Size factor interpretation: a factor of 1.2 means the sample has 20% more sequencing depth (after composition adjustment) than the reference. Genes with zero counts in any sample are excluded from the geometric mean calculation.
Size factor alternatives for special cases:
| Scenario | Solution |
|---|---|
| High zero-inflation (single-cell) | estimateSizeFactors(dds, type='poscounts') |
| Very small libraries | estimateSizeFactors(dds, type='iterate') |
| Known stable reference genes | estimateSizeFactors(dds, controlGenes=stable_idx) |
| Majority of genes DE (e.g., prokaryotic stress) | Spike-in normalization or controlGenes |
TMM (edgeR)
Goal: Compute normalization factors that account for composition bias using trimmed mean of M-values.
Approach: Select a reference sample, compute gene-wise log-ratios (M-values) and average expression (A-values) relative to the reference, trim extreme values, and compute a weighted mean scaling factor.
library(edgeR)
y <- DGEList(counts=counts, group=metadata$condition)
y <- calcNormFactors(y, method='TMM')
# TMM trims 30% of M-values and 5% of A-values by default
# Normalization factors are stored in y$samples$norm.factors
# Effective library size = lib.size * norm.factors
# Python equivalent using edgepy or manual calculation
import numpy as np
import pandas as pd
def tmm_norm_factors(counts):
'''Simplified TMM normalization factors.'''
lib_sizes = counts.sum(axis=0)
ref_idx = np.argmin(np.abs(np.log(lib_sizes) - np.mean(np.log(lib_sizes))))
ref = counts.iloc[:, ref_idx]
factors = np.ones(counts.shape[1])
for i in range(counts.shape[1]):
if i == ref_idx:
continue
sample = counts.iloc[:, i]
keep = (ref > 0) & (sample > 0)
m = np.log2(sample[keep] / lib_sizes[i]) - np.log2(ref[keep] / lib_sizes[ref_idx])
a = 0.5 * (np.log2(sample[keep]
Установить bio-expression-matrix-normalization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bio-expression-matrix-normalization?
Normalize and transform RNA-seq count matrices for differential expression, visualization, and clustering. Covers between-sample (TMM, RLE, upper quartile), within-sample (TPM, FPKM), variance-stabilizing (VST, rlog), and single-cell (scran) methods. Use when choosing or applying normalization to expression data.
Как установить скилл bio-expression-matrix-normalization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-expression-matrix-normalization запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic