Question: diffbind: exporting unique peak sets
gravatar for ruka.setoguchi
4.6 years ago by
ruka.setoguchi0 wrote:

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.1k views
ADD COMMENTlink modified 4.6 years ago • written 4.6 years ago by ruka.setoguchi0
Answer: diffbind: exporting unique peak sets
gravatar for Rory Stark
4.6 years ago by
Rory Stark3.0k
CRUK, Cambridge, UK
Rory Stark3.0k wrote:

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")



ADD COMMENTlink written 4.6 years ago by Rory Stark3.0k
Answer: diffbind: exporting unique peak sets
gravatar for ruka.setoguchi
4.6 years ago by
ruka.setoguchi0 wrote:

Hello Rory,

It worked! Thank you so much for your help!





ADD COMMENTlink written 4.6 years ago by ruka.setoguchi0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 158 users visited in the last hour