I have two WIG files representing the forward and reverse strands for an RNA-seq experiment that I would like to merge into one file. There are multiple chromosomes/plasmids in the WIGs. This is the general format:
track type=wiggle_0
variableStep chrom=ZM4
166 0.0337715701129034
167 0.0337715701129034
168 0.0337715701129034
195 0.0337715701129034
200 0.0337715701129034
217 0.0337715701129034
variableStep chrom=pZM32
64 0.0337715701129034
76 0.0337715701129034
134 0.0337715701129034
139 0.0337715701129034
183 0.0675431402258068
186 0.0337715701129034
variableStep chrom=pZM32
64 0.0337715701129034
76 0.0337715701129034
134 0.0337715701129034
139 0.0337715701129034
183 0.0675431402258068
There is no overlap between the genome coordinates in the two WIG files. I would like to merge them into one WIG file. So far I have tried using wiggletools:
wiggletools write test_out.wig sum file1.wig file2.wig
That combines the files well, but reports the format as follows:
fixedStep chrom=ZM4
start=165 step=1
-0.033772
0.033772
0.033772
0.033772
fixedStep chrom=ZM4
start=195 step=1
0.033772
fixedStep chrom=ZM4
start=200 step=1
0.033772
fixedStep chrom=ZM4
start=202 step=1
What I am looking for is standard WIG format (genomic position \t value) for the two files combined while keeping the chromosomes/plasmids organized.
I found this (How To Combine Multiple Wig/Bigwig Files Into One) but it assumes separate WIG files for each chromosome/plasmid.
Any tools or ideas? I will work on my own script but wanted to ask in case someone else has solved this problem.
Thank you! I saw this after I got it working with the solution I added below, but this is super great!