I am kind of new to R and am trying to get multiple regions from my bam file and I need to write these back to a bam file using the Rsamtools library. I am trying to do it this way:
myGR <- GRanges(seqnames=c("chrIII","chrXII","chrIV"),ranges=IRanges(start=c(50838,660716,806621),end=c(52340,662833,807748)) ) myparams1<- ScanBamParam(which=myGR) filterBam("accepted_hits.sorted.bam", "accepted_hits.specific", indexDestination=FALSE, myparams1)
but the filterBam command gives an error:
Error in as.character.default(x) :
no method for coercing this S4 class to a vector
Any ideas how to fix this?