deeptools / pyBigWig

A python extension for quick access to bigWig and bigBed files
MIT License
218 stars 49 forks source link

Chromosome order potential issue #152

Open potulabe opened 1 week ago

potulabe commented 1 week ago

I'm not sure if this kind of problem has been already reported, but I couldn't find any clues on how to solve it, so decided to write my question here. I made a bunch of bigwig files using bedGraphToBigWig tool. The chromosome order in my bedgraph files was right (Chr1...Chr9,Chr10,..). When converting the files, I also provided the chrom.sizes file with right chromosome order.

I can open the bigWig files in the IGV browser, and they look OK, I can browse to any position and the information is displayed correctly. But when I open the files with pyBigWig, for some reason Chr10 can't be accessed. I'm not sure, but can it be related to the chromosome order problem? Because when I display the chromosome order with bw.chroms() command, I get the wrong alphabetical order (which was not originally in bedGraph files, and doesn't correspond to the genome file chromosome order):

{'Chr1': 217471166,
 'Chr10': 52432566,
 'Chr2': 181034961,
 'Chr3': 153873357,
 'Chr4': 153961319,
...
}

ucsc's bigWigInfo returns also the alphabetical order (despite the chrom.sizes file I provided for bedGraphToBigWig the chromosome order was correct):

 ~/projs/ucsc_tools/bigWigInfo -chroms PNS_female.bedgraph.bw
version: 4
isCompressed: yes
isSwapped: 0
primaryDataSize: 879,143
primaryIndexSize: 7,244
zoomLevels: 9
chromCount: 34
        Chr1 0 217471166
        Chr10 1 52432566
        Chr2 2 181034961
        Chr3 3 153873357
        Chr4 4 153961319
        Chr5 5 164033575
        Chr6 6 154486312
        Chr7 7 133565930
        Chr8 8 147241510
        Chr9 9 91218944
        Sca1 10 82299
        Sca109 11 2779
        Sca11 12 53911
        Sca110 13 2622
        Sca124 14 1584
        Sca148 15 991
        Sca151 16 803
        Sca19 17 32064
        Sca2 18 79987
        Sca20 19 31817
        Sca23 20 29586
        Sca29 21 27006
        Sca4 22 61141
        Sca41 23 13206
        Sca46 24 10342
        Sca47 25 10052
        Sca52 26 7253
        Sca59 27 6523
        Sca64 28 5339
        Sca72 29 4995
        Sca75 30 4956
        Sca80 31 4807
        Sca87 32 4214
        Sca94 33 3579
basesCovered: 4,010,903
mean: -nan
min: 0.000000
max: inf
std: -nan

I can send the examples of bedGraph and bigwig files if they are needed.

dpryan79 commented 1 week ago

Sending an example bigwig could be useful. The dictionary order in python isn't always guaranteed, depending on the version of python you're using.

potulabe commented 1 day ago

Thank you for answering! I understand that dictionary order is not guaranteed, but that shouldn't impede accessing the data, isn't it?

Here in the google drive folder there are:

When I open this bigwig with pyBigWig I get None on the Chr10: image

In IGVjs browser, embedded in my Dash application, I get smth on the Chr10: