I changed it into tab-delimited and still does not work.
sed 's/ /\t/g' my.genome >my.genome1
cat my.genome1
chr1 1000
chr2 800
Hi I have an error from bedtools. What might be happening? I have two bed files:
cat A.bed
chr1 100 200
chr1 400 500
chr1 500 800
cat my.genome
chr1 1000
chr2 800
when I run this:
bedtools complement -i A.bed -g your.genome
It gives
Error: The genome file your.genome has no valid entries. Exiting.
your.genome must be tab-delimited.
I changed it into tab-delimited and still does not work.
sed 's/ /\t/g' my.genome >my.genome1
cat my.genome1
chr1 1000
chr2 800
If your files were tab-delimited, it would work. You probably substituted the wrong delimiter in your sedcommand. Probably it is a double-whitespace or something, and after your command you now have a hybrid tab-whitespace delimiter.

Could you please show your command lines who you generated bed files? I am still having problem.
In this case I simply did it manually by tiping it in a text editor. What organism are you working on? There are genome.sizes files available for download for most species.
Try replacing all [[:space:]]+ with \t. That should work.
Here's a one-liner that should work:
$ bedops --complement <( sort-bed A.bed ) <( awk -v OFS="\t" '{ print $1, "0", $2 }' my.genome | sort-bed - ) > answer.bed
This part is called a process substitution in the bash shell:
... <( awk -v OFS="\t" '{ print $1, "0", $2 }' my.genome | sort-bed - ) ...
It uses awk to turn the file my.genome into a sorted BED file, on which you can do set operations with bedops. Basically, everything within <( ... ) returns operational intervals that are fed to the bedops process as a standard input stream.
Here's what the one-liner looks like when broken down into separate commands:
$ sort-bed A.bed > A.sorted.bed
$ awk -v OFS="\t" '{ print $1, "0", $2 }' my.genome | sort-bed - > my.genome.sorted.bed
$ bedops --complement A.sorted.bed my.genome.sorted.bed > answer.bed
$ rm A.sorted.bed my.genome.sorted.bed
Process substitutions might look a little odd, at first, but they help avoid creating intermediate files, which slow down operations on whole-genome scale work. Intermediate files also require disk space and need cleaning up. It's useful to avoid intermediate files, when possible.
I added a whitespace between all awk -v and OFS=. Hope you don't mind :)
Hi @Alex Reynolds,
I was just exploring the bedpos --complement option instead of bedtools complement option to get coordinates which are present in genome.bed but not in target.bed, I found --difference is more suitable to get the result.bed, instead of --complement.
Do correct me if my understanding of the tool is wrong.
Thanks!
The manual states:
The --complement operation calculates the genomic regions in the gaps between the contiguous per-chromosome ranges defined by one or more inputs.
The --difference operation calculates the genomic regions found within the first (reference) input file, excluding regions in all other input files
Clearly, an operation of the sort A.bed minus B.bed requires the use of --difference as --complement works on a completely different problem.
Log in to answer this question.