There are two elements in the wig file which have start coordinates of 0:
balsamea:Github alexpreynolds$ sed -n '15859650, 15859660'p wgEncodeSydhTfbsK562Pol3StdSig.wig
chr16 90289051 90289078 0
chr16 90292542 90292837 0
#bedGraph section chr17:0-70149
chr17 0 256 0
chr17 256 331 4.3
chr17 331 507 0
chr17 507 510 4.4
chr17 510 558 4.3
chr17 558 582 4.2
chr17 582 834 0
chr17 834 839 4.8
balsamea:Github alexpreynolds$ sed -n '43067090, 43067100'p wgEncodeSydhTfbsK562Pol3StdSig.wig
chr9 141146429 141146462 0
chr9 141146472 141146505 0
#bedGraph section chrM:0-1297
chrM 0 1 2146.8
chrM 1 2 2202.4
chrM 2 3 2200.8
chrM 3 4 2217.7
chrM 4 5 2243.6
chrM 5 6 2259.8
chrM 6 7 2257.8
chrM 7 8 2264.7
I'm contacting the UCSC folks to see if the bigWigToWig tool is not applying the correct indexing, or if the wig data itself is not indexed as expected, or if the indexing problem is specific to this particular bigWig file.
There will likely be one of the following two fixes applied:
1. Skip over 0-indexed elements and print a warning message to standard error; or,
2. Remove adjustments by wig2bed to the wig coordinates
We'll see what UCSC has to say and then I'll probably post an update later today or tomorrow.
Regarding headers, the wig2bed tool strips headers before reaching sort-bed, unless the --keep-headers option is specified. However, --keep-headers rewrites header lines as pseudo-BED elements, so that they can be sorted with sort-bed. So this may not be exactly what you were expecting, although this would resolve line count questions.
The disparity in line numbers between input wig and output bed files is specifically due to the removal of header lines from the wig input, during conversion. We can compare "before" and "after" line counts to see how this works:
balsamea:Github alexpreynolds$ grep '^#' wgEncodeSydhTfbsK562Pol3StdSig.wig | wc -l
43572
balsamea:Github alexpreynolds$ grep -v '^#' wgEncodeSydhTfbsK562Pol3StdSig.wig | wc -l
44605785
balsamea:Github alexpreynolds$ grep '^#' wgEncodeSydhTfbsK562Pol3StdSig.bed | wc -l
0
balsamea:Github alexpreynolds$ wc -l wgEncodeSydhTfbsK562Pol3StdSig.bed
44605783 wgEncodeSydhTfbsK562Pol3StdSig.bed
In other words, there are 43572 header lines in the original wig file, and 44605785 non-header lines. In the resulting bed file, a modified version of wig2bed that skips the two 0-based elements has 44605783 lines. (If the two skipped elements were included, we would then have all 44605785 elements from the original wig file.)