Via Kent tools, convert from bigWig to WIG:
$ bigWigToWig signal.bw signal.wig
Via BEDOPS, convert signal from WIG to BED and filter for signal that overlaps each region of interest:
$ wig2bed < signal.wig | bedops --element-of 1 - regions_A.bed > signal_over_regions_A.bed
$ wig2bed < signal.wig | bedops --element-of 1 - regions_B.bed > signal_over_regions_B.bed
...
$ wig2bed < signal.wig | bedops --element-of 1 - regions_N.bed > signal_over_regions_N.bed
Get chromosome sizes with Kent tools, e.g. for hg38
:
$ fetchChromSizes hg38 > hg38.sizes
Then convert each subset back to WIG or bigWig:
$ bedGraphToBigWig signal_over_regions_A.bed hg38.sizes signal_over_regions_A.bw
$ bedGraphToBigWig signal_over_regions_B.bed hg38.sizes signal_over_regions_B.bw
...
$ bedGraphToBigWig signal_over_regions_N.bed hg38.sizes signal_over_regions_N.bw
Then do your final merge step of bigWig files into one final bigWig product.
This process is repetitive enough to be put into a script, if it looks like a lot of typing.
Solution 1: Create a new tool from Kent's source to do exactly that, called
bigWigMergePlus
. It's downloadable here, and the buildable source is here.Solution 2: slice the bigWig through bigWigToWig, then convert them back using wigToBigWig, and finally merging them with bigWigMerge. The output is kept as a bedGraph instead of bigWig. Here is a NodeJS script to do all that in a single command: gist