Question: Problems when exporting GRanges file as bigwig after hg38 to hg19 lift over using rtracklayer and annotation hub
gravatar for camerond
10 weeks ago by
camerond70 wrote:

I'm trying to use rtracklayer and AnnotationHub in R to lift over a .bw file I have that is aligned to hg38. I need the data to be aligned to hg19.

By following this vingette, I think I have successfully done this using the R packages mentioned above with the code below.


mphg_bw_hg38 <- import(con = '', format = 'bigWig')

ahub <- AnnotationHub()
ahub.chain <- subset(ahub, rdataclass == "ChainFile" & species == "Homo sapiens")
query(ahub.chain, c("hg38", "hg19"))
chain <- ahub.chain[ahub.chain$title == "hg38ToHg19.over.chain.gz"]
chain <- chain[[1]]

mphg_bw_hg19 <- liftOver(mphg_bw_hg38, chain)

My issue is that I'm having difficulty converting the file created during the liftover back to .bw for visualisation in IGV.

The output of the liftover is a compressed GRanges list. I tried to export to bigwig this using:

 export(mphg_bw_hg19, con = '', format = 'bigWig')

But I got the following: Error in .local(object, con, format, ...) : 'object' must have names

So I tried using unlist to convert the file to GRanges then export ...

mphg_bw_hg19_a <- unlist(mphg_bw_hg19)
export(mphg_bw_hg19_a, con = '', format = 'bigWig')

But this threw: Error in .local(object, con, format, ...) : Unable to determine seqlengths; either specify 'seqlengths' or specify a genome on 'object' that is known to BSgenome or UCSC

I assume I need to assign hg19 to this GRanges file somehow and/or specify the seqlengths of all the chromosomes in the file - is there a simple way to do this? Not an expert on GRanges!

ADD COMMENTlink modified 10 weeks ago by benformatics890 • written 10 weeks ago by camerond70
gravatar for benformatics
10 weeks ago by
ETH Zurich
benformatics890 wrote:

You need to get the chromosome information for the human hg19 build

My suggestion:

txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
seqinfo(bw_hg19_a) <- seqinfo(txdb)[seqnames(seqinfo(bw_hg19_a))]
export(mphg_bw_hg19_a, con = '', format = 'bigWig')

However if you have overlapping ranges (following liftOver) you will get a new error. That's because you probably shouldn't be liftOver'ing bigWig files...

ADD COMMENTlink written 10 weeks ago by benformatics890

Thanks for the suggestion, but your right that threw an overlapping error. Error in FUN(extractROWS(unlisted_X, IRanges(X_elt_start[i], X_elt_end[i])), : BigWig ranges cannot overlap

The vignettes for the packages I used suggest that it is possible to lift over using a bigwig file ...

ADD REPLYlink modified 10 weeks ago • written 10 weeks ago by camerond70
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1700 users visited in the last hour