Exactly one page like "R/BAM2GenomeDataObject" found, redirecting to page.

Clear message

GenomeData to GRanges Object

GenomeData objects are deprecated (as of Summer 2010), and have been replaced as a method for storing read locations by GRanges objects. So what do you do if you have pipelines that depend on GenomeData objects, or legacy GD objects laying around? Rather than re-run all your code from the original sequence files (such as Eland export files), you can convert your GenomeData objects to GRanges. There's probably a better way to do this, but I couldn't find it, so this is what I came up with.

library(chipseq)

# get chromosome names
chrnames <- names(GD)

gr <- GRanges()
for( i in 1:length(GD) ){
   repval <- length(GD[[i]]$"+") + length(GD[[i]]$"-")
   gr <- c(gr, GRanges(seqnames = Rle(rep(chrnames[i], repval)),
                  ranges = IRanges(start=c(GD[[i]]$"+", GD[[i]]$"-"), width=1),
                  strand = Rle(c(rep("+", length(GD[[i]]$"+")), rep("-", length(GD[[i]]$"-"))) ) ) )
}