multiIntersectBed : Report score rather than 0 or 1

445 views
Skip to first unread message

mathieu.gi...@gmail.com

unread,
Jul 13, 2013, 10:44:49 AM7/13/13
to bedtools...@googlegroups.com
Dear Bedtools developers and users,

multiIntersectBed is a great tool. It would be the perfect tool if it could report scores from each original bed file instead of 0 or 1.

Here is an example :

Let's consider the first line from 3 different bed files :
K27ac.bed :
KhC1    236    725    ChIP-K27ac-R1+R2_CiA-KH2012_macs2_g99M_s73_dupauto_SPMR_peak_1    22.56072

K4me1.bed :
KhC1    66651    66898    ChIP-K4me1-R1+R2_CiA-KH2012_macs2_g99M_s73_dupauto_SPMR_peak_1    10.39472

K4me3.bed :
KhC1    139    596    ChIP-K4me3-R1+R2_CiA-KH2012_macs2_g99M_s73_dupauto_SPMR_peak_1    99.42199


multiIntersectBed output would be :
chrom    start    end    num    list    K27ac    K4me1    K4me3
KhC1    0    139    0    none    0    0    0
KhC1    139    236    1    K4me3    0    0    1
KhC1    236    596    2    K27ac,K4me3    1    0    1
KhC1    596    725    1    K27ac    1    0    0

... and I would like it to be :
chrom    start    end    num    list    K27ac    K4me1    K4me3
KhC1    0    139    0    none    0    0    0
KhC1    139    236    1    K4me3    0    0    99.42199
KhC1    236    596    2    K27ac,K4me3    22.56072    0    99.42199
KhC1    596    725    1    K27ac    22.56072    0    0

How easy/hard would it be to implement a -score option in multiIntersectBed to achieve this ?

Otherwise, if you have any suggestion on how to achieve such an output, I'd be glad to hear it !
Thanks for your help on this precise point.
Mathieu

Mathieu Gineste

unread,
Jul 13, 2013, 5:02:24 PM7/13/13
to bedtools...@googlegroups.com
Well... I found a - rather heavy - way to achieve this.

Briefly, I intersected the original bed files containing the scores with the multiintersected file to retrieve the score on the same intervals (bedtools intersect). I also retrieved the empty intervals (bedtools intersect -v). Then I concatenated, sorted and merged (bedtools merge -d -1 -scores collapse) those files to retrieve my multiintersected file with the original scores.

The output looks like this :
head ChIP_CiB-eg_R1+R2_multiinter_scores.bed
KhC1     0     139     0,0,0
KhC1     139     236     0,0,99.42199
KhC1     236     596     22.56072,0,99.42199
KhC1     596     725     22.56072,0,0

Nevertheless, the -score option would be useful for bedtools multiinter !

Mathieu

Aaron Quinlan

unread,
Jul 16, 2013, 8:44:17 PM7/16/13
to bedtools...@googlegroups.com
Hi Mathieu,

I will look into this, but as I recall (it has been awhile since I looked at that code) there was a technical challenge to doing this.  However, if your input files have non-overlapping intervals, you could convert them to BEDGRAPH format (score is the fourth column) and use the unionBedGraphs tool which does exactly what you want.

I will also revisit adding this to multiintersect, as I agree with you.

Best,

--
You received this message because you are subscribed to the Google Groups "bedtools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bedtools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mathieu Gineste

unread,
Jul 17, 2013, 4:42:27 AM7/17/13
to bedtools...@googlegroups.com
Hi Aaron,

Thanks for your reply.

Unfortunately, the input intervals are indeed overlaping.

Good luck with the code if you are keen to have a look into it,
Best,

Mathieu


Le samedi 13 juillet 2013 16:44:49 UTC+2, Mathieu Gineste a écrit :

limwai...@gmail.com

unread,
Sep 29, 2018, 5:07:31 PM9/29/18
to bedtools-discuss
Dear Aaron,

Good day to you. I'm looking for function as per suggested by Mathieu Gineste with output

chrom    start    end    num    list    K27ac    K4me1    K4me3
KhC1    0    139    0    none    0    0    0
KhC1    139    236    1    K4me3    0    0    99.42199
KhC1    236    596    2    K27ac,K4me3    22.56072    0    99.42199
KhC1    596    725    1    K27ac    22.56072    0    0

Any updates on this function?

Thank you very much and have a nice day!

Best wishes,
Wai Feng
Reply all
Reply to author
Forward
0 new messages