I'm trying to use
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 = 'CEPBb_macrophage.bw', 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[]
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 = 'CEPBb_macrophage_hg19.bw', 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 = 'CEPBb_macrophage_hg19.bw', 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!