pileupMismatches: Pileup Mismatches from BAM Files

View source: R/pileupMismatches.R

pileupMismatchesR Documentation

Pileup Mismatches from BAM Files

Description

This function conducts a genomic pileup on specified chromosomes or regions from a BAM file. It leverages multiple cores for parallel processing using Rsamtools pileup methods. User-defined parameters customize the operation. Outputs a .tsv file with columns: chr, start, end, ref, alt. This file can serve as input to the readBAM() function's mutation_file parameter.

Usage

pileupMismatches(
  bamfile,
  genome,
  chromosome_to_keep,
  galp_flag,
  pileup_params,
  num_cores = detectCores() - 1,
  outfile
)

Arguments

bamfile

The path to the BAM file or a BamFile object.

genome

The BSgenome object corresponding to the BAM file's genome.

chromosome_to_keep

Should be a character vector containing the seqnames to be kept in the GRanges object or boolean FALSE. FALSE means not filtering. Default is paste0("chr", 1:22).

galp_flag

ScanBamFlag object for BAM file scanning flags.

pileup_params

A list containing parameters for the pileup operation, including 'max_depth', 'min_base_quality', 'min_mapq', 'min_nucleotide_depth', 'min_minor_allele_depth', 'distinguish_strands', 'distinguish_nucleotides', 'ignore_query_Ns', 'include_deletions', 'include_insertions', and optional binning parameters 'left_bins', 'query_bins', 'cycle_bins'. For parameter descriptions, refer to 'Rsamtools::pileup' documentation.

num_cores

Number of processor cores to use for parallel processing. Defaults to all available cores minus one.

outfile

The path and filename for the output .tsv file.

Value

A dataframe of processed mutation data from specified chromosomes.

Examples

bamfile <- "/path/to/your.bam"
genome <- BSgenome.Hsapiens.UCSC.hg19
chromosomes <- c("chr1", "chr2", "chrX")
flags <- ScanBamFlag(isPaired=TRUE, isDuplicate=FALSE)
pileup_params <- list(max_depth=250, min_base_quality=20)
outfile <- "path/to/output.tsv"

result <- pileupMismatches(
    bamfile=bamfile,
    genome=genome,
    chromosome_to_keep=chromosomes,
    galp_flag=flags,
    pileup_params=pileup_params,
    num_cores=3
    outfile=outfile
)

hw538/cfDNAPro documentation built on Feb. 17, 2025, 6:09 p.m.