How to split the .bigWig file into equal size of bin?
2
0
Entering edit mode
3.7 years ago
solarchan7 • 0

I am trying to output a .bedgraph like the following:

chrom start    end   mean
chr1  554300  554400  34 
chr1  554400  554500  43 
chr1  554500  554600  45 
chr1  554600  554700  65 
chr1  554700  554800  34

from a .bigWig file. how can i do this?

programming mapping alignment • 1.1k views
ADD COMMENT
2
Entering edit mode
3.7 years ago

use the UCSC tool bigWigAverageOverBed (not tested)

ADD COMMENT
0
Entering edit mode
3.7 years ago

Here's another way that lets you control more parameters:

$ assembly=hg38
$ bin_size=100
$ bigWigToWig signal.bw signal.wig
$ wig2bed < signal.wig > signal.bed
$ fetchChromSizes ${assembly} \
    | grep -v '_*_' \
    | awk -v FS="\t" -v OFS="\t" '{ print $1, "0", $2 }' \
    | sort-bed - \
    | bedops --split ${bin_size} - \
    | bedmap --echo --mean --delim '\t' - signal.bed \
    > answer.bg

The bedmap tool will let you swap out --mean with various other statistical operations, for instance (median, max, min, etc.).

ADD COMMENT

Login before adding your answer.

Traffic: 2978 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6