SKILL.md
Version Compatibility
Reference examples tested with: MACS3 3.0+, clusterProfiler 4.10+
Before using code patterns, verify installed versions match. If versions differ:
- 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.
Peak Annotation with ChIPseeker
"Annotate my ChIP-seq peaks to genes" → Assign peaks to genomic features (promoter, exon, intron, intergenic), find nearest genes, and calculate TSS distances.
- R:
ChIPseeker::annotatePeak(peaks, TxDb=txdb)
Load Peaks and Annotations
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(org.Hs.eg.db)
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
# Read peaks from MACS3
peaks <- readPeakFile('sample_peaks.narrowPeak')
Annotate Peaks
Goal: Assign each ChIP-seq peak to its nearest gene and genomic feature category.
Approach: Use annotatePeak with a TxDb annotation database to classify peaks as promoter, exon, intron, or intergenic and retrieve the nearest gene symbol.
# Annotate with default settings
peak_anno <- annotatePeak(
peaks,
TxDb = txdb,
annoDb = 'org.Hs.eg.db'
)
# View annotation summary
peak_anno
Custom Promoter Definition
# Define promoter region (-3kb to +3kb from TSS)
peak_anno <- annotatePeak(
peaks,
TxDb = txdb,
tssRegion = c(-3000, 3000), # Promoter definition
annoDb = 'org.Hs.eg.db'
)
Extract Annotated Data Frame
# Convert to data frame
anno_df <- as.data.frame(peak_anno)
# Key columns: seqnames, start, end, annotation, distanceToTSS, SYMBOL, GENENAME
head(anno_df)
# Export to CSV
write.csv(anno_df, 'annotated_peaks.csv', row.names = FALSE)
