This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BigWig from ensembl assembly to UCSC session

Dear Community,

I am having trouble in viewing my data in UCSC and I am not sure what is going wrong.

Situation#: I have my bam files aligned using ensembl assembly and then preprocessed and generated bigwigs (deep tools) and then uploaded at UCSC (no errors). But as soon as I visualise the tracks, I get blanks in the section of tracks and says no data. I find this strange because as my data file is not empty.

Could anyone suggest a reason/solution.

Thank you in advance

bigwig ucsc ensembl

chromosome name differences is what first comes to mind.

I know how to fix this in wiggle files but I have no clue how to fix this in bigwigs.

There is a command in ucsc tool kit called bigWigToWig . You can convert bigwig to wig and then use wigToBigWig tool to reconvert ?

2 answers

The issue is just the chromosome names. You can convert the chromosome names in a bigWig file with this:

The input is the bigWig file and a chromosome name map, such as from here. If you have deepTools installed already then the pyBigWig python package is already installed as well.

Hey Devon, Thank you for your message. I have taken this file from GRCh37_ensembl2UCSC.txt the link.

I am doing this in terminal python convertBigWigChroms.py GRCh37_ensembl2UCSC.txt Sort.Ref.ER.DSG.bam.bw ER.DSG.bw and I get this error:

Traceback (most recent call last):
  File "convertBigWigChroms.py", line 16, in <module>
    if cols[1] == "":
IndexError: list index out of range

Could you please let me know how to make it run.

Thank you

That's what I get for not actually testing the script on a use case with blanks like that. Change line 34 to the following:

if len(cols) < 2 or cols[1] == "":

Edit: I've updated the gist to include this now.

Hi, Thanks for this code, works for me even to convert bigwig aligned on dm6 version using the chromosome name map of dm3, if you are not interested in the 1860 1.5kbp pieces of genome added on dm6.

I just add between lines 26-27 to consider only chromosome names already known in dm3:

 
if chrom not in d.keys():
        continue

Hi @ Devon_Ryan,

I am trying to change the chromosomes name in a bigwig file, but the script fails at ints = bw.intervals(chrom, 0, length) with the following error:

Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

I believe the error is due to excessive memory usage. DO you have any suggestions on how to solve this issue?

Weird, you can always use Kent's tools from UCSC to convert to bedGraph, modify that, and then convert it back to a bigWig file.

thank you for your response.

I am trying to change the chromosome names in the bw file. After adding the header with the new mapping, I start with adding the entries, but in the original bw file, there are some positions that do not have any value. when i use bw.intervals(chr, start, end), I see [nan].

How can I add entries with nan values to an output bw file? I currently get the following error if there are nan values:

The entries you tried to add are out of order, precede already added entries, or otherwise use illegal values. Please correct this and try again.

You can remove those. You'll presumably need to sort the bedGraph file, since Kent's tools are very picky about that sort of thing.

If you used Ensembl assembly for analysis then why not use custom tracks feature at Ensembl to view the data?

Note: Chromosomal identifier styles are different between UCSC and Ensembl so this is not going to work on UCSC without additional work.

Reviewer wants UCSC session and I don't want to realign the data.

Perhaps they are unaware of the option to view these at Ensembl. Any chance of suggesting this option?

I can try but not sure if these guys will accept it.

Could you suggest something. I don't want to realign as it will cost a lot of time and the other option is to generate wiggle track (add chr)and convert them into bigwigs. But is it possible to add "chr" to the existing bigwigs and make them work?

Log in to answer this question.