how to get -nms for bedtools
2
2
Entering edit mode
10.3 years ago
Ann ★ 2.4k

I'd like to merge bed files and preserve the names of the merged features using bedtools -nms option.

However, this option (-nms) is deprecated in the newer bedtools.

The documentation says I can use -o option to get -nms behavior.

How do I get translate the new bedtools merge command to get:

bedtools merge -i file.bed -nms
bedtools • 3.6k views
ADD COMMENT
1
Entering edit mode

Thanks for bringing this up. I will try to improve the docs...

ADD REPLY
2
Entering edit mode
10.3 years ago

If your name field is the 4th column (as expected for BED format), you would do the following. This assumes your BED file is sorted by chromosome and then by start position.

bedtools merge -i file.bed -c 4 -o collapse
ADD COMMENT
0
Entering edit mode
10.3 years ago

If the names are in the fourth column, here's one way to get a unique list of names that map across merged elements, where the input is sorted:

$ sort-bed unsorted.file.bed > file.bed
$ bedops --merge file.bed \
    | bedmap --echo --echo-map-id-uniq --delim '\t' - file.bed \
    > answer.bed

Mapped IDs will be in the fourth column of answer.bed.

ADD COMMENT

Login before adding your answer.

Traffic: 1829 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6