Reference Code backup Executable files
Merge together multiple bigWigs into a single output bedGraph.
bigWigMerge [options] in1.bw in2.bw .. inN.bw out.bedGraph
This tool is part of UCSC Genome Browser's utilities.
bigWigMerge
merge bigWig files by adding together the signal values.
bedGraphToBigWig
to make the output bigWig.bigWigMerge
will ignore these loci with non-positive values. To avoid this behavior, you need to set -threshold=-10000.0
(replace -10000.0 with a value you think is smaller than the smallest value in your file). One caveat is that loci with no signal will also be dumped; if you want to remove these records, consider using awk
to do a quick filtering. Alternatively, you can use wiggletools sum
to merge bigwig files, which directly handles negative values.
# first use bigWigMerge to merge files
# remember to override the default value of -threshold to a negative number
bigWigMerge -threshold=-10000.0
file1_with_negative_values.bw file2_with_negative_values.bw merged.bg
# use awk to remove loci with 0 signal
awk 'BEGIN{FS="\t"}{if ($4!=0) print $0}' merged.bg > merged.filtered.bg
Assume you want to merge three bigWig files (a.bw, b.bw, and c.bw) into a single one (merged.bw). This will involve two tools bigWigMerge
and bedGraphToBigWig
:
$ bigWigMerge a.bw b.bw c.bw merged.bg $ bedGraphToBigWig merged.bg hg38.chrom.sizes merged.bw