This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bedops closest problem running

Hi all,

I have problem when running bedtools closest and don't know why?! I am running the following command:

bedtools closest -a gene_final.bed -b rmpk.bed > closest_file

and give me this error:

Error: unable to open file or unable to determine types for file gene_final.bed

My file(gene_final.bed) looks like that

chr1 169818772 169863408
chr1 169631245 169823221
chr1  27938575  27961788
chr1 196621008 196716634
chr1  24742284  24799466
chr1  33473585  33546597

and the repeatmasker file like:

chr1 10000 10468 (CCCTAA)n Simple_repeat
chr1 10468 11447      TAR1     Satellite
chr1 11503 11675      L1MC          LINE
chr1 11677 11780     MER5B           DNA
chr1 15264 15355      MIR3          SINE
chr1 16712 16749    (TGG)n Simple_repeat

Does anyone has an idea on why it doesn't work?

r bedtools

a. Does the actual BED file have blank spaces in line beginnings as shown here?

b. Does the file have the necessary read permissions?

c. Why does the post have an 'R' tag?

yasjas, to check if your bed file is ok, you can try bedtools sort on it. BTW, this is a required by bedtools closest. Try something like this:

bedtools closest -a <(bedtools sort -i gene_final.bed) -b <(bedtools sort -i RptM.bed)

If you get error message from sort, then there is something wrong with your bed file.

Edit

And why is your question about bedops?

1 answer

Prep your files with BEDOPS sort-bed:

$ sort-bed gene_final.bed > gene_final.sorted.bed
$ sort-bed rmpk.bed > rmpk.sorted.bed

Run the op with BEDOPS closest-features:

$ closest-features gene_final.sorted.bed rmpk.sorted.bed > answer.bed

The closest-features tool offers some additional options. Take a look at the docs for more info.

Some Bedtools operations can now take advantage of the sorting benefit in BEDOPS tools, so if you use Bedtools, you might look into sorting your data before using that.

Hi all,

Every time I try to run sort -bed it gives me an error saying

Non-numeric start coordinate. See line 1 in gene_final.bed.
(remember that chromosome names should not contain spaces.)

but I can see a space in the chromosome name?!

Make sure that your chromosome names have no spaces, that all fields are tab-delimited, and that the second and third fields are numeric. You might take a look at line 1 with a text editor or cat -t to make sure it contains tabs.

Log in to answer this question.