This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Combine Multiple Wig/Bigwig Files Into One

Hi,

I have wiggle files for each chromosome generated from MACS peak calling. Instead create a custom track for each chromosome from these wiggle files, is there a way to combine them into a single wig/bigwig so that I can look at them on UCSC genome browser? Thanks in advance!

chip-seq wiggle format ucsc conversion

Please accept one of the many good answers to your question.

4 answers

Thanks alot, this was very helpfull to me aswell. To remove heades and combine the wig files in a bigwig file i used:

zcat *.wig.gz | grep -v ^track | wigToBigWig -clip stdin genome.table output.bigwig

Mvh Anders

What is genome.table exactly, please?

that would be a list of chromosome names and lengths (two columns, tab separated, often called chrom.sizes at ucsc)

If there is only one chromosome per file, you can just concatenate those wig:

cat chr*.wig > genome.wig

I was wondering why they were using -clip. But your answer seems to suggest that -clip is not necessary

If you have multiple wig files (and MACS wig are gzipped) you should concatenate:

zcat *.wig.gz | wigToBigWig -clip stdin chromsizes.tab output.bigwig

If you have only one file (and macs14 allows this) you can directly go with

wigToBigWig -clip stdin chromsizes.tab output.bigwig

As recent wigToBigWig support gziped input.

Where do I get chromsizes.tab, please?

In case you didn't already know MACS 1.4 beta has a function to create a single WIG file, use '--wig --single-wig'.

The important point is that you MUST remove the track header from the top of each WIG file before you merge them and convert them to bigWig. I like to keep a copy of the header.

Keep header:

head -n 1 *chr1.wig > header

Remove first line (track header):

sed -i '1d' *wig

Hope this helps!

Log in to answer this question.