<p>As noted in another answer, it's relatively easy to tell if a file is bigWig or not by opening it up with, say, standard <a href="https://github.com/ENCODE-DCC/kentUtils" rel="nofollow noreferrer">UCSC Kent utilities</a> like <code>bigWigToBedGraph</code> or <code>bigWigToWig</code>, or other bigWig readers, and seeing if you get data back.</p>

<p>Depending on what you're doing with the bigWig file, the trickier part can be how the original data was indexed. </p>

<p>If the bigWig file was originally made from a bedGraph or BAM file, its coordinates will be 0-indexed when converted to human-readable form. If the bigWig file was originally made from a wig file, its coordinates will be 1-indexed when converted to a human readable form. How the file's coordinates were originally indexed may change how you work with them downstream for set operations, for instance.</p>

<p>I think the only way to know about the source is to look at the header contained within the bigWig file, after extraction to human-readable form with UCSC tools. A bigWig file made from a bedGraph file will generally contain the header <code>#bedGraph section &lt;coords&gt;</code> in it somewhere (after conversion), for example.</p>

CC BY-SA 3.0
2018-02-03T15:28:07.123Z
You can actually have multiple representations (bedGraph and wiggle) within a single bigWig file, provided they're in different blocks. If Kent's tools don't enforce 0-based coordinates then I would consider that a bug, as the bigWig structure itself is 0-based.
Devon Ryan
CC BY-SA 3.0
2018-02-03T13:13:31.710Z
2018-02-03T16:59:12.200Z
2018-02-03T16:59:12.200Z
Alex Reynolds
<p>There's no standard validation method, but a simple one would be <code>python -c "import pyBigWig; bw = pyBigWig.open('your_file.bw'); print(bw.IsBigWig());"</code>. If you get <code>True</code> then it's a bigWig file. If you get <code>False</code> or an error then it's not (<code>False</code> indicates a bigBed file).</p>

<p>Alternatively, <code>file your_file.bw</code> should return <code>data</code>.</p>

CC BY-SA 3.0
2018-02-26T22:06:13.883Z
Link for future readers: https://github.com/deeptools/pyBigWig
ShanZhengYang
CC BY-SA 3.0
2018-02-03T07:50:42.860Z
2018-02-03T07:50:42.860Z
Devon Ryan
<p>I have a bigWig file of extension <code>*.bw</code> (which is standard), but I am suspicious that this file may be of an incorrect format. </p>

<p>Is there a standard method in the field to validate a *.bigWig file? </p>

<bigwig><validation>
Is there a standard method to validate whether a bigWig file is correct?
# Is there a standard method to validate whether a bigWig file is correct?

(Asked by: username_0 on 2018-02-02)

I have a bigWig file of extension `*.bw` (which is standard), but I am suspicious that this file may be of an incorrect format.

Is there a standard method in the field to validate a \*.bigWig file?

**Tags:** bigwig, validation

---

## 2 answers

### Answer by username_1 on 2018-02-03. Score: 1 | Accepted answer

As noted in another answer, it's relatively easy to tell if a file is bigWig or not by opening it up with, say, standard [UCSC Kent utilities](https://github.com/ENCODE-DCC/kentUtils) like `bigWigToBedGraph` or `bigWigToWig`, or other bigWig readers, and seeing if you get data back.

Depending on what you're doing with the bigWig file, the trickier part can be how the original data was indexed.

If the bigWig file was originally made from a bedGraph or BAM file, its coordinates will be 0-indexed when converted to human-readable form. If the bigWig file was originally made from a wig file, its coordinates will be 1-indexed when converted to a human readable form. How the file's coordinates were originally indexed may change how you work with them downstream for set operations, for instance.

I think the only way to know about the source is to look at the header contained within the bigWig file, after extraction to human-readable form with UCSC tools. A bigWig file made from a bedGraph file will generally contain the header `#bedGraph section`  in it somewhere (after conversion), for example.

> **Comments:**
> **username_2**: You can actually have multiple representations (bedGraph and wiggle) within a single bigWig file, provided they're in different blocks. If Kent's tools don't enforce 0-based coordinates then I would consider that a bug, as the bigWig structure itself is 0-based.  

---

### Answer by username_2 on 2018-02-03. Score: 2

There's no standard validation method, but a simple one would be `python -c "import pyBigWig; bw = pyBigWig.open('your_file.bw'); print(bw.IsBigWig());"`. If you get `True` then it's a bigWig file. If you get `False` or an error then it's not (`False` indicates a bigBed file).

Alternatively, `file your_file.bw` should return `data`.

> **Comments:**
> **username_0**: Link for future readers: https://github.com/deeptools/pyBigWig  

---

