Skip to content

Instantly share code, notes, and snippets.

@jluebeck
Created July 16, 2020 16:55
Show Gist options
  • Save jluebeck/387f90d809d05631ba12aecde1223c5c to your computer and use it in GitHub Desktop.
Save jluebeck/387f90d809d05631ba12aecde1223c5c to your computer and use it in GitHub Desktop.
Using bedtools, create a new bed file which is the union of multiple bed files. Takes as input a file containing a list of bed files.
#!/bin/bash
cat $1 | while read f;
do
cat $f >> fullbed.bed
done
sort -k1,1 -k2,2n fullbed.bed > fullbed.sorted.bed
rm fullbed.bed
bedtools merge -i fullbed.sorted.bed > merged_bed_union.bed
rm fullbed.sorted.bed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment