getBamMultiMatching: getBamMultiMatching

Description Usage Arguments Value Author(s) See Also Examples

Description

Get the numbers of multi-hits for bam file

Usage

1
  getBamMultiMatching(bamFile, pairedMode = c("paired", "first", "second"))

Arguments

bamFile

The filenames of input bam file. The input bam files have to be sorted and indexed, which means ".bai" file must exit.

pairedMode

The pairedMode can be "paired", "first", "second". "paired" will load proper pairs; "first" will load all the first reads; "second" will load all mapped mate reads. This argument is ignored when it's single-end read.

Value

It returns a integer vector that holds the numbers of unmapped reads (If the input read count cannot be retrieved from bam file), the reads that have exactly one hit, the reads that have exactly two hits, and so on.

Author(s)

Ge Tan

See Also

getBamInputReadCount

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  
  ## This example is not tested because it requires external software "samtools"
  ### Prepare the bam files
  bamfile <- system.file("extdata", "ex1.bam", package="Rsamtools",
                         mustWork=TRUE)
  tempBamFile <- tempfile(fileext=".bam")
  file.copy(bamfile, tempBamFile)
  reads1 <- file.path(system.file("extdata", package="NGS"), "fastq",
                    "nanocage_ACAGAT_carp_embryo_R1.fastq")
  addInputReadCounts(bamFiles=tempBamFile, reads1s=reads1, binary="samtools")
  tempBamFile2 <- tempfile(fileext=".bam")
  tempBamFile2 <- sortBam(tempBamFile, 
                     sub("\\.bam$", "", tempBamFile2, ignore.case=TRUE))
  file.copy(tempBamFile2, tempBamFile, overwrite=TRUE)
  file.remove(tempBamFile2)
  indexBam(tempBamFile)
  
  ### Get the multiMatching; 
  ### Due to small reads number in the exmaples, we have negative counts for "0"
  getBamMultiMatching(tempBamFile)
  file.remove(tempBamFile)
  

ge11232002/NGS documentation built on May 17, 2019, 12:13 a.m.