diffbind: exporting unique peak sets
Entering edit mode
Last seen 6.5 years ago

I have a question about the DiffBind program. I am an immunologist and have recently started to use R for data analysis. Now, I am trying to analyze our ChIP-seq data using DiffBind to identify genomic regions that are commonly or differentially bound by one transcription factor and its mutant. I have been able to analyze the data to some extent (explained below), but I would like to obtain bed files of the peak-sets unique to either wild-type (condition A) or mutant (condition B) and of the common regions. (Eventually, I will perform motif analysis to identify transcription factor binding motifs enriched in each condition.) I used the command, writefile within the dba.peakset() function, and obtained the common peak-sets. When I tried to obtain onlyA or onlyB peak-sets by using the command, write.table after dba.overlap(), however, I have failed to do so. I would appreciate it very much if you could kindly give me any suggestions to solve the problem. Thank you very much in advance for your help.


I have a total of 4 samples, two replicates for each condition.

I used R: 3.1.3 version and DiffBind: 1.14.1 version.


># set a working directory



A1_vs_Input_peaks   A  TFX resistant Full-Media 1 bed

A2_vs_Input_peaks   A  TFX resistant Full-Media 2 bed

B1_vs_Input_peaks   B  TFX responsive Full-Media 1 bed

B2_vs_Input_peaks   B  TFX responsive Full-Media 2 bed


> AB=dba.peakset(AB,consensus=DBA_CONDITION,minOverlap=0.66)

Add consensus: resistant

Add consensus: responsive


6 Samples, 30141 sites in matrix (47334 total):

   ID     Tissue   Factor  Condition   Treatment   Replicate   Caller   Intervals

1  A1_vs_Input_peaks  A  TFX   resistant  Full-Media   1   bed    19767

2  A2_vs_Input_peaks  A  TFX   resistant  Full-Media   2   bed    35525

3  B1_vs_Input_peaks  B  TFX  responsive  Full-Media   1   bed   14644

4  B2_vs_Input_peaks  B  TFX  responsive  Full-Media   2   bed   40924

5 resistant    A   TFX     resistant    Full-Media     1-2      bed    16492

6 responsive  B   TFX    responsive    Full-Media    1-2       bed    12288




>#I got a file with overlapped peaks between resistant and responsive.

>AB.OL = dba.overlap(AB, c(5,6))

>write.table(AB.OL, file=”150504.bed”)


Ruka Setoguchi


diffbind • 2.4k views
Entering edit mode
Rory Stark ★ 4.1k
Last seen 24 days ago
CRUK, Cambridge, UK

Hi Ruka-

You're on the right track!

Probably the easiest way to get the unique peaks is to work with what you have in AB.OL. If you look at:

> names(AB.OL)
[1] "onlyA" "onlyB" "inAll"

so AB.OL$onlyA and AB.OL$onlyB contain exactly the peaks you want as GRanges objects. If you want to write them to a file it is probably easier to work with them as dataframes:

> AB.OL <- dba.overlap(AB, 5:6, DataType=DBA_DATA_FRAME)

To write them to files in tab-delimited form:

> write.table(AM.OL$onlyA, row.names=F, sep="\t", file="ResistantOnly.txt")
> write.table(AM.OL$onlyB, row.names=F, sep="\t", file="ResponsiveOnly.txt")



Entering edit mode
Last seen 6.5 years ago

Hello Rory,

It worked! Thank you so much for your help!






Login before adding your answer.

Traffic: 469 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6