text: user143: I'd like to threshold a bigWig file on a value and get all regions above or below that value in bed format. Ideally without too many file conversions. Are there any tools to do that?
  
  user77: You can do that with a bit of python:
  #!/usr/bin/env python
  import pyBigWig
  threshold = 10  # Change me
  bw = pyBigWig.open("file.bw")  # Change me
  of = open("regions.bed", "w")  # Change me
  
  for chrom, len in bw.chroms().items():
      intervals = bw.intervals(chrom)
      for interval in interals:
          if abs(interval[2]) > threshold:
              of.write("{}\t{}\t{}\n".format(chrom, interval[0], interval[1]))
  bw.close()
  of.close()
  
  You'll need to install pyBigWig (it's available via pip or conda install) and change the lines with Change me in them.
  
original_text: 143: <p>I'd like to threshold a bigWig file on a value and get all regions above or below that value in bed format. Ideally without too many file conversions. Are there any tools to do that?</p>
   77: <p>You can do that with a bit of python:</p>
  
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python
  import pyBigWig
  threshold = 10  # Change me
  bw = pyBigWig.open("file.bw")  # Change me
  of = open("regions.bed", "w")  # Change me
  
  for chrom, len in bw.chroms().items():
      intervals = bw.intervals(chrom)
      for interval in interals:
          if abs(interval[2]) &gt; threshold:
              of.write("{}\t{}\t{}\n".format(chrom, interval[0], interval[1]))
  bw.close()
  of.close()
  </code></pre>
  
  <p>You'll need to install pyBigWig (it's available via <code>pip</code> or <code>conda install</code>) and change the lines with <code>Change me</code> in them.</p>
  