Chuyển đến nội dung
Skillpedia
Phân tích và bảng tính33k · #9001

pydeseq2

Skill này làm gì

Skill này cho agent của bạn PyDESeq2, một triển khai Python của phương pháp DESeq2 để phân tích biểu hiện vi sai. Skill dành cho nhà tin sinh học và nhà sinh học phân tích thí nghiệm RNA-seq.

Khi nào nên dùng

  • ✓Khi bạn muốn so sánh biểu hiện gene giữa mẫu xử lý và mẫu đối chứng.
  • ✓Khi thí nghiệm của bạn có nhiều yếu tố, như lô hoặc giới tính, cần tính đến.
  • ✓Khi bạn đang chuyển phân tích DESeq2 từ R sang Python.

Liên kết skill

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/pydeseq2/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/pydeseq2/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“So sánh biểu hiện gene giữa mẫu xử lý và mẫu đối chứng trong file đếm này, và liệt kê 20 gene hàng đầu theo giá trị p đã điều chỉnh.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent tải dữ liệu đếm và siêu dữ liệu mẫu, lọc các gene có số đếm thấp, khớp mô hình DESeq2, rồi chạy kiểm định Wald với hiệu chỉnh kiểm định nhiều lần.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

PyDESeq2

Overview

PyDESeq2 is a Python implementation of DESeq2 for differential expression analysis with bulk RNA-seq data. Design and execute complete workflows from data loading through result interpretation, including single-factor and multi-factor designs, Wald tests with multiple testing correction, optional apeGLM shrinkage, and integration with pandas and AnnData.

When to Use This Skill

This skill should be used when:

  • Analyzing bulk RNA-seq count data for differential expression
  • Comparing gene expression between experimental conditions (e.g., treated vs control)
  • Performing multi-factor designs accounting for batch effects or covariates
  • Converting R-based DESeq2 workflows to Python
  • Integrating differential expression analysis into Python-based pipelines
  • Users mention "DESeq2", "differential expression", "RNA-seq analysis", or "PyDESeq2"

Quick Start Workflow

For users who want to perform a standard differential expression analysis:

import pandas as pd
from pydeseq2.dds import DeseqDataSet
from pydeseq2.ds import DeseqStats

# 1. Load data
counts_df = pd.read_csv("counts.csv", index_col=0).T  # Transpose to samples × genes
metadata = pd.read_csv("metadata.csv", index_col=0)

# 2. Filter low-count genes
genes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]
counts_df = counts_df[genes_to_keep]

# 3. Initialize and fit DESeq2
dds = DeseqDataSet(
    counts=counts_df,
    metadata=metadata,
    design="~condition",
    refit_cooks=True
)
dds.deseq2()

# 4. Perform statistical testing
ds = DeseqStats(dds, contrast=["condition", "treated", "control"])
ds.summary()

# 5. Access results
results = ds.results_df
significant = results[results.padj < 0.05]
print(f"Found {len(significant)} significant genes")

Core Workflow Steps

Step 1: Data Preparation

Input requirements:

  • Count matrix: Samples × genes DataFrame with non-negative integer read counts
  • Metadata: Samples × variables DataFrame with experimental factors

Common data loading patterns:

# From CSV (typical format: genes × samples, needs transpose)
counts_df = pd.read_csv("counts.csv", index_col=0).T
metadata = pd.read_csv("metadata.csv", index_col=0)

# From TSV
counts_df = pd.read_csv("counts.tsv", sep="\t", index_col=0).T

# From AnnData
import anndata as ad
adata = ad.read_h5ad("data.h5ad")
counts_df = pd.DataFrame(adata.X, index=adata.obs_names, columns=adata.var_names)
metadata = adata.obs

Data filtering:

# Remove low-count genes
genes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]
counts_df = counts_df[genes_to_keep]

# Remove samples with missing metadata
samples_to_keep = ~metadata.condition.isna()
counts_df = counts_df.loc[samples_to_keep]
metadata = metadata.loc[samples_to_keep]

Step 2: Design Specification

The design formula specifies how gene expression is modeled.

Single-factor designs:

design = "~condition"  # Simple two-group comparison

Multi-factor designs:

design = "~batch + condition"  # Control for batch effects
design = "~age + condition"     # Include continuous covariate
design = "~group + condition + group:condition"  # Interaction effects

Design formula guidelines:

  • Use Wilkinson formula notation (R-style)
  • Put adjustment variables (e.g., batch) before the main variable of interest
  • Ensure variables exist as columns in the metadata DataFrame
  • Use appropriate data types (categorical for discrete variables)

Step 3: DESeq2 Fitting

Initialize the DeseqDataSet and run the complete pipeline:

from pydeseq2.dds import DeseqDataSet

dds = DeseqDataSet(
    counts=counts_df,
    metadata=metadata,
    design="~condition",
    refit_cooks=True,  # Refit after removing outliers
    n_cpus=1           # Parallel processing (adjust as needed)
)

# Run the complete DESeq2 pipeline
dds.deseq2()

What deseq2() does:

  1. Computes size factors (normalization)
  2. Fits genewise dispersions
  3. Fits dispersion trend curve
  4. Computes dispersion priors
  5. Fits MAP dispersions (shrinkage)
  6. Fits log fold changes
  7. Calculates Cook's distances (outlier detection)
  8. Refits if outliers detected (optional)

Step 4: Statistical Testing

Perform Wald tests to identify differentially expressed genes:

from pydeseq2.ds import DeseqStats

ds = DeseqStats(
    dds,
    contrast=["condition", "treated", "control"],  # Test treated vs control
    alpha=0.05,   
Câu hỏi thường gặp

Hiệu chỉnh kiểm định nhiều lần làm gì?

Nó điều chỉnh giá trị p để có ít dương tính giả hơn khi kiểm tra nhiều gene.

Nó có xử lý được nhiều hơn một yếu tố không?

Có. Skill bao gồm thiết kế nhiều yếu tố để tính đến hiệu ứng lô hoặc biến đồng hành.

Nó có vẽ được biểu đồ volcano hoặc MA không?

Có. Skill đề cập đến biểu đồ volcano và MA.

Chi tiết

Mô tả gốc của tác giả

Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.

repo: davila7/claude-code-templates

Độ phổ biến

Sao GitHub
33k
Vị trí xếp hạng
#9001
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự