PriceLab / chip-seq-motif-study

to determine the how TF motifs do and do not match ChIP-seq assays
0 stars 0 forks source link

write function which creates a new bam file - a slice of an existing file #7

Open paul-shannon opened 4 years ago

paul-shannon commented 4 years ago
sliceBamFile <- function(existingBamFileNam, chrom, start, end, newBamFileName)
{
   # you write this code
}

use Rsamtools and something like this (from my notes)

   library(Rsamtools)

   #  psg1 chromloc: chr19:42866464-42879822
   which <- GRanges(seqnames = "chr19", ranges = IRanges(42866464, 42879822))
   what <- c("rname", "strand", "pos", "qwidth", "seq")
   param <- ScanBamParam(which = which, what=what)
   bamFile <- "~/github/igvR/inst/extdata/LN54310_chr19.bam"
   bam <- scanBam(bamFile, param=param)
   filterBam(bamFile, "tmp.bam", param=param)
paul-shannon commented 4 years ago

@mariam16548 here's the thread. please read back to the opening comment.