Question: bigWig to bed for regions above/below threshold
1
gravatar for skanterakis
2.6 years ago by
skanterakis110
United Kingdom
skanterakis110 wrote:

I have a bigWig file with the following profile:

bigWigInfo uniqueness.bw
version: 4
isCompressed: yes
isSwapped: 0
primaryDataSize: 919,783,047
primaryIndexSize: 97,088,256
zoomLevels: 10
chromCount: 25
basesCovered: 3,095,693,183
mean: 0.828284
min: 0.000000
max: 1.000000
std: 0.361063

I would like to create a bed for all regions with value < 1.

More generally, I'd like to be able to threshold a bigWig on a value and get all regions above or below that value in bed format.

Thanks a lot!

bigwig bed • 2.5k views
ADD COMMENTlink modified 17 months ago by oriolebaltimore130 • written 2.6 years ago by skanterakis110

Hello skanterakis!

It appears that your post has been cross-posted to another site: https://bioinformatics.stackexchange.com/questions/2800/

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink written 2.6 years ago by Pierre Lindenbaum128k

Dear Alex and Sean, could you please help understand what is the threshold value mean in either ATAC-Seq or ChIP-Seq in wig file obtained after bigWigToWig conversion. Particularly, in bedgraph format what is the 4th column in dataValue and what are the norms for selecting the threshold. Thanks Adrian

ADD REPLYlink written 17 months ago by oriolebaltimore130

There is no fixed meaning to that value.

ADD REPLYlink written 17 months ago by Devon Ryan95k
1
gravatar for Devon Ryan
2.6 years ago by
Devon Ryan95k
Freiburg, Germany
Devon Ryan95k wrote:

Copy-pasting from where you cross-posted:

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.

ADD COMMENTlink written 2.6 years ago by Devon Ryan95k
1
gravatar for Pierre Lindenbaum
2.6 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum128k wrote:

I would like to create a bed for all regions with value < 1.

convert the wig back to bed: Any Method Of Converting Bigwig File Format Into Bed Format? , filter with awk ( awk '($4< 1.0)' ) , convert back to bigwig if needed with bedgraphtobigwig

ADD COMMENTlink written 2.6 years ago by Pierre Lindenbaum128k
1
gravatar for Sean Davis
2.6 years ago by
Sean Davis26k
National Institutes of Health, Bethesda, MD
Sean Davis26k wrote:
  1. Use import() from the rtracklayer bioconductor package to read the bigwig file.
  2. Use slice() from the GenomicRanges bioconductor package on the results from #1.
  3. Use export() from the rtracklayer bioconductor package on the results from #2 to write the BED file.
ADD COMMENTlink written 2.6 years ago by Sean Davis26k
0
gravatar for Alex Reynolds
2.6 years ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k wrote:

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
ADD COMMENTlink modified 2.6 years ago • written 2.6 years ago by Alex Reynolds30k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1309 users visited in the last hour