omics.co.in logo omics.co.in

Differential Binding Analysis with DiffBind & DESeq2 in R

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 6 of 10 0% Course Completed
PHASE 3 • DIFFBIND & DESEQ2 Track 24 • 10 Modular Chapters Huntington's Disease H3K4me3 Case Study

Differential Binding Analysis with DiffBind & DESeq2 in R

Configuring DiffBind sample sheets, building a consensus peak matrix across biological replicates, affinity score normalization (TMM / RLE), contrast design (Huntington's Disease vs Healthy Controls), and executing negative binomial GLMs via DESeq2 to detect hyper- and hypo-methylated promoter regions.

⏱️ Estimated Study: 50–60 mins 🧪 Workflows: FastQC, Bowtie2, SAMtools, MACS3, DiffBind, ChIPseeker, deepTools, IGV 📋 Level: Hands-On Epigenomics • Real HD Post-Mortem Data

1. Differential Binding Analysis Workflow with DiffBind

While peak callers like MACS3 identify where binding occurs in individual samples, comparing chromatin occupancy between conditions (Huntington's Disease vs. Control) requires quantitative statistical modeling of read counts across a consensus peak set. The Bioconductor package DiffBind integrates with DESeq2 to evaluate differential affinity.

2. Configuring the DiffBind Sample Sheet (samplesheet.csv)

SampleID,Tissue,Factor,Condition,Replicate,bamReads,bamControl,Peaks,PeakCaller
HD_1,Striatum,H3K4me3,HD,1,03_filtered/HD_Rep1.clean.bam,03_filtered/HD_Input.clean.bam,04_peaks/HD_Rep1_peaks.narrowPeak,narrow
HD_2,Striatum,H3K4me3,HD,2,03_filtered/HD_Rep2.clean.bam,03_filtered/HD_Input.clean.bam,04_peaks/HD_Rep2_peaks.narrowPeak,narrow
Ctrl_1,Striatum,H3K4me3,Control,1,03_filtered/Control_Rep1.clean.bam,03_filtered/Control_Input.clean.bam,04_peaks/Control_Rep1_peaks.narrowPeak,narrow
Ctrl_2,Striatum,H3K4me3,Control,2,03_filtered/Control_Rep2.clean.bam,03_filtered/Control_Input.clean.bam,04_peaks/Control_Rep2_peaks.narrowPeak,narrow

3. Complete DiffBind & DESeq2 R Script

library(DiffBind)
library(DESeq2)
library(ggplot2)
library(EnhancedVolcano)

# 1. Load experiment from samplesheet
dbObj <- dba(sampleSheet = "samplesheet.csv")

# 2. Count reads in consensus peaks (replicate overlap >= 2)
dbObj <- dba.count(dbObj, minOverlap = 2, score = DBA_SCORE_READS)

# 3. Establish contrast: HD vs Control
dbObj <- dba.contrast(dbObj, categories = DBA_CONDITION, minMembers = 2)

# 4. Perform differential binding using DESeq2 negative binomial GLM
dbObj <- dba.analyze(dbObj, method = DBA_DESEQ2)

# 5. Extract differential report
dbReport <- dba.report(dbObj, method = DBA_DESEQ2, th = 1)
dfReport <- as.data.frame(dbReport)

# Export significant differential peaks (FDR < 0.05 and |log2FC| >= 1)
sigPeaks <- subset(dfReport, FDR < 0.05 & abs(Fold) >= 1)
write.csv(dfReport, "05_diffbind/all_peaks_deseq2.csv", row.names = FALSE)
write.csv(sigPeaks, "05_diffbind/significant_differential_peaks.csv", row.names = FALSE)

# Generate publication Volcano Plot
pdf("05_diffbind/diffbind_volcano.pdf", width = 8, height = 7)
EnhancedVolcano(dfReport,
    lab = rownames(dfReport),
    x = 'Fold',
    y = 'FDR',
    pCutoff = 0.05,
    FCcutoff = 1.0,
    pointSize = 2.0,
    labSize = 3.0,
    title = "H3K4me3 Promoter Dynamics: Huntington's Disease vs Control",
    subtitle = "DiffBind + DESeq2 Statistical Significance",
    legendPosition = 'right')
dev.off()
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗