# Pydeseq2

Differential gene expression analysis (Python DESeq2).

- Repository: https://github.com/LeonChaoX/qinyan-academic-skills (996 stars)
- Category: Testing
- License: MIT license
- Last updated: 2026-07-20
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add LeonChaoX/qinyan-academic-skills --skill pydeseq2 -g -a claude-code -y`
Codex: `npx skills add LeonChaoX/qinyan-academic-skills --skill pydeseq2 -g -a codex -y`
Cursor: `npx skills add LeonChaoX/qinyan-academic-skills --skill pydeseq2 -g -a cursor -y`
Gemini CLI: `npx skills add LeonChaoX/qinyan-academic-skills --skill pydeseq2 -g -a gemini-cli -y`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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:

```python
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

The rest: https://github.com/LeonChaoX/qinyan-academic-skills/blob/HEAD/skills/05-生物信息与基因组学/pydeseq2/SKILL.md
