Learn R Programming

TarSeqQC (version 1.2.0)

pileupCounts: Function to obtain the pileup counts for a bam file.

Description

pileupCounts waits a TargetExperiment object containing the bed file information in order to obtain pileup counts only for the specified genomic regions. The resulting object is a data.frame instance, in which each row represents one position of the specified features across the bed file. The first three columns called 'pos', 'seqnames' and 'which_label,' represent the position in the seqnames (e.g. pos=10183795 and seqnames=chr3) and the associated feature. According to the 'pileupP' parameters setted before, the number of next columns could change. If 'distinguish_nucleotide' was set as TRUE, then one column per ntd will appear containing the counts obtained for each of them. Same will occur when 'distinguish_strands' is set as TRUE. The last column, called 'counts', contains the total counts obtained for the corresponding position.

Usage

pileupCounts(bed, bamFile, fastaFile, scanBamP = NULL, pileupP = NULL, BPPARAM = bpparam())

Arguments

bed
a Granges object containing the bed file information.
bamFile
Character indicating the alignment and index bam files full path.
fastaFile
Character indicating the full path to the genome reference and index files.
scanBamP
ScanBamParam indicating the parameters the BAM file read.
pileupP
PileupParam indicating the parameters for the pileup build.
BPPARAM
An optional BiocParallelParam instance defining the parallel back-end to be used during evaluation.

Value

data.frame object.

References

  1. Morgan M, Pages H, Obenchain V and Hayden N. Rsamtools: Binary alignment (BAM), FASTA, variant call (BCF), and tabix file import. R package version 1.20.1

See Also

Rsamtools-pileup

Examples

Run this code
##Obtain the pileup matrix for the first amplicon
data(ampliPanel, package="TarSeqQC")
bed<-getBedFile(ampliPanel)[1]
## Defining bam file and fasta file names and paths
bamFile<-system.file("extdata", "mybam.bam", 
    package="TarSeqQC", mustWork=TRUE)
fastaFile<-system.file("extdata", "myfasta.fa", 
    package="TarSeqQC", mustWork=TRUE)
## extracting the pileup matrix
myCounts<-pileupCounts(bed, bamFile, fastaFile)
head(myCounts)

Run the code above in your browser using DataLab