Differences between revisions 2 and 3

Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
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. 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.
Line 9: Line 9:
# 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]]$"-"))) ) ) )
}

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]]$"-"))) ) ) )
}

R/GenomeData2GRanges (last edited 2010-08-26 03:15:09 by ChrisSeidel)