2
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ Welcome to Bioinformatics. What have you found? Where did you look up ? (To avoid looking at the same sites) What have you tried? I think that we have some other questions in this site about bed and bigwig. Aren't they helpful? $\endgroup$ – llrs Nov 8 '17 at 15:01
  • $\begingroup$ cross posted: biostars.org/p/282410 $\endgroup$ – Pierre Nov 8 '17 at 15:11
1
$\begingroup$

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.

| improve this answer | |
$\endgroup$
0
$\begingroup$

Convert bigWig to WIG via bigWigToWig:

$ bigWigToWig signal.bw signal.wig

Convert WIG to BED via BEDOPS wig2bed:

$ wig2bed < signal.wig > signal.bed

Filter BED by its score column with awk:

$ awk '($5 < 1)' signal.bed > signal.filtered.bed
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.