Learn R Programming

rbamtools (version 2.16.17)

extractGeneRegions: Extraction of alignments from given genetic regions and BAM files into a set of output BAM files.

Description

The function extractGeneRegions writes aligns or some part of the stored aligns in a BAM file as reads into a BAM output file.

Usage

extractGeneRegions(src, trg, gl)

Arguments

src

sampleBamFiles: List of source BAM files where alignments are read from. BAM index files must exist and be present in src object.

trg

sampleBamFiles: List of target BAM files where alignments are written to.

gl

geneList: Objects from which genetic regions are taken.

Value

Numeric. Number of written alignments for each file.

Details

Reference sequence names in geneList object must all match sequence names in source BAM files.

Examples

Run this code
# NOT RUN {
# + + + + + + + + + + + + + + + + + + #
# A) Create sampleBamFiles objects
# + + + + + + + + + + + + + + + + + + #
bam <- system.file("extdata","accepted_hits.bam",package="rbamtools")
outdir <- tempdir()
# Input sampleBamFiles object
ibs <- sampleBamFiles(bam)
# Output sampleBamFiles object
obs <- sampleBamFiles(file.path(outdir, "outu.bam"))
# + + + + + + + + + + + + + + + + + + #
# B) Create geneList Object
# + + + + + + + + + + + + + + + + + + #
rfile <- system.file("extdata",
            "hs.ucsc.small.RData",
                package="refGenome")

ucr <- loadGenome(rfile)
gt <- getGeneTable(ucr)
gl <- geneList(ucr, gt$gene_id)
# }
# NOT RUN {
extractGeneRegions(ibs, obs, gl)
bamFiles(obs) <- file.path(outdir, bamSort(obs, "out"))
bamIdxFiles(obs) <- paste(bamFiles(obs), "bai", sep=".")
createIndex(obs)
# }

Run the code above in your browser using DataLab