bedtools shift -s with -pct is dysfunctional

17 views
Skip to first unread message

nmil...@ncsu.edu

unread,
May 21, 2020, 11:03:35 PM5/21/20
to bedtools-discuss
I used the following commands:

bedtools shift -i ENCFF219OVU.bed -g mus_musculus.genome -s 0.5 -pct > peaks_centered.bed

However, peaks_centered.bed was the exact same as ENCFF219OVU.bed. I went into the source code and identified the issue. The shift is stored in an integer value. Therefore, the float value 0.5 is lost. I made the following changes in the /src/shiftBed/shiftBed.cpp file.

void BedShift::AddShift(BED &bed) {

  CHRPOS chromSize = (CHRPOS)_genome->getChromSize(bed.chrom);

  double input_shift;
  CHRPOS shift;

  if (bed.strand == "-") {
    input_shift = _shiftMinus;
  } else {
    input_shift = _shiftPlus;
  }
  if (_fractional == true) {
    shift = input_shift * (double)bed.size();
  } else {
    shift = (CHRPOS)shift;
  }


  if ((bed.start + shift) < 0)
    bed.start = 0;
  else if ((bed.start + shift) > (chromSize - 1))
    bed.start = (chromSize - 1);
  else
    bed.start = bed.start + shift;

  if ((bed.end + shift) <= 0)
    bed.end = 1;
  else if ((bed.end + shift) > chromSize)
    bed.end = chromSize;
  else
    bed.end = bed.end + shift;
}

Aaron Quinlan

unread,
May 26, 2020, 9:52:23 AM5/26/20
to nmil...@ncsu.edu, bedtools...@googlegroups.com
Thanks for reporting this. A similar fix exists in the master branch of the github repository. If you clone and compile the repository, you should see a fix for this behavior.
Best,
Aaron
--
You received this message because you are subscribed to the Google Groups "bedtools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bedtools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bedtools-discuss/8b653777-9759-4448-92be-2e1b5db7f543%40googlegroups.com.

Nikhil Milind

unread,
May 26, 2020, 12:51:38 PM5/26/20
to bedtools...@googlegroups.com, Aaron Quinlan
I see, thank you! Appreciate the help.

Regards,
Nikhil
Reply all
Reply to author
Forward
0 new messages