This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BedTools options - Overlap exons for various bed files

Hi,

Does anyone know whether we can use bedtools for finding overlap exons for more than a few bed files, i.e for a list of bed files?

I know there is the -b option for more than 1 bed file, but I need to do it for hundreds of bed files. Is this possible?

Thank you,
Maria

bedtools

2 answers

You can try something like this:

intersectBed -wa -wb -s -a exons -b yourBEDFile.bed

Now, you can loop this, something like this:

for name in $(ls *bed)
do
    intersectBed -wa -wb -s -a exons -b $name > yourOutputFile_$name
done

It seems that it's possible to use wildcards with -b option, from bedtools webpage:

"NEW!!!: -b may be followed with multiple databases and/or wildcard (*) character(s).*"

So it wouldn't be necessary to perform a loop, just -b *.bed. But I've never use it.

I just tried this but it gets the error: Segmentation fault (core dumped).. Is there a restriction for the amount of bed files we put?

Thank you

Thank you both. I will try both these. Hope it works!

If you can use BEDOPS, you can specify as many BED files as you want:

$ bedops -e 1 exons.bed file1.bed file2.bed ... fileN.bed > answer.bed

Hi Alex,

Thank you for your response. Is it possible that I use a whole file which includes all the bed files instead of putting them on the command line manually? When they are too many, it will be impossible to put them all there.

Thank you

Log in to answer this question.