bedGraphToBigWig [options] in.bedGraph chrom.sizes out.bw
This tool is part of UCSC Genome Browser's utilities.
Tab
).Tab
).GL000009.2 is not found in chromosome sizes filewill be raised. In the above case, the records on the same chromosome are named differently in the in.bedGraph (as GL000009.1) and in the chromosome size file (as chrGL000009.2). To fix this problem, you need to either change the names in the in.bedGraph or in the chrom.sizes.
If the assembly is hosted by UCSC, chrom.sizes can be a URL like https://hgdownload.soe.ucsc.edu/goldenPath/db/bigZips/db.chrom.sizes, for example, if you want to get the chromsome sizes for chromosomes defined in hg38, you can access https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.chrom.sizes. Or you may use the script fetchChromSizes
to download the chrom.sizes file. If not hosted by UCSC, a chrom.sizes file can be generated by running twoBitInfo
on the assembly .2bit file.
The input bedGraph file must be sorted, use the unix sort
command:
$ sort -k1,1 -k2,2n unsorted.bedGraph > sorted.bedGraph