1
$\begingroup$

I am trying to merge two bed files (more in future) to one. my bed files are something like : result of macs pea calling.

I need to merge them in a way to have the shared chromosome location.

Is there a way to do that ?

$\endgroup$

2 Answers 2

2
$\begingroup$

In my opinion, the easiest way to merge bed files is to use bedtools merge.

$\endgroup$
1
$\begingroup$
  1. Convert each of your Excel spreadsheets to tab-delimited text files (how-to).
  2. Install and run Cygwin, if using Windows. If you are using OS X, open up the Terminal app.
  3. Install the BEDOPS toolkit to get sorting and set operation tools (if you're not averse to using them).
  4. Strip out the Microsoft line endings, strip the header, and sort each of the N files:

    $ tr -d '\r' < fileN.tsv | tail -n+2 - | sort-bed - > fileN.bed
    
  5. Merge the files:

    $ bedops --merge file1.bed file2.bed ... fileN.bed > answer.bed
    

The file answer.bed will contain all merged regions from files file1.bed through fileN.bed. Merging will be done on intervals for each unique chromosome name.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks that worked $\endgroup$
    – Mariam
    Apr 4, 2020 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.