bed entries collapse based on score column I have a bed file where some entries have the exact same chr:start-end but change in the name and score column. I would like to apply bedtools or a similar tool to obtain a filtered file where for each set of chr:start-end entries, only the one with the highest score (column 5) is used, the others filtered out. I would like to do this with a bed format toolkit (bedtools, etc) rather than scripting it.
Use BEDOPS bedmap --max-element or bedmap --max-element-rand to grab the maximal-scoring element over mapped intervals, e.g.:

$ sort-bed elements.unsorted.bed5 &gt; elements.bed5
$ bedops --merge elements.bed5 &gt; merged.bed3
$ bedmap --max-element merged.bed3 elements.bed5 &gt; answer.bed


The file answer.bed will contain the maximal-scored element from elements.bed5 that overlaps the merged intervals in merged.bed3.

The --max-element and --max-element-rand options differ on handling ties. The first option grabs the first match from ties by sort-bed (lexiographical) sort order; the second option grabs a random match on ties. 

The option you pick would depend on what you're doing with the answer. Picking a random hit might be better if you're doing downstream statistical tests, for instance. 

You can add --sci and --prec &lt;int&gt; options to format the score output to your desired level of precision. I think the default assumption is six digits of precision; adjust as needed.

There are also --min-element and --min-element-rand options for, conversely, reporting minimal-scoring elements.

For more information: http://bedops.readthedocs.io/en/latest/content/reference/statistics/bedmap.html#score-operations